Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for sharing table views via link #168

Merged
merged 4 commits into from
Oct 24, 2023

Conversation

clevelandcs
Copy link
Contributor

Updated PR changing UX to follow discussion in #164
What does this do?

  • Automatically sets table sorts, filters, pagination, and columns on load when visiting Spoolman with full share link
  • Updates URL hash fragment to reflect current state of table
  • Adds share button
  • Uses share API or current URL to provide sharable link when clicking share

What is the use case for this feature?

  • Enables sharing of views in multi-user environments via simple link
  • Adds support for simple and quick location and/or material based inventory counts - in my case writing the link for the shelf or drybox location filter to NFC tags and QR codes attached to the shelf.

What is missing?

  • Possible translation issues. I'm not a linguist but did my best to add translations for the share button where applicable
  • Testing, I spent about an hour testing different scenarios but it would be nice to have more than one pair of eyes
  • QR code generation could possibly be added using this type of link for shelf ID labels
  • In the future Refine's syncWithLocation could potentially support customization (I could not find a good way to do this) so that state is reflected in URL without this extra logic

Please let me know if you see problems or things you'd like changed to get this merged. This is my first open-source contribution and I'm not a React developer (Vue+.NET is my wheelhouse). Thanks for the work you've done on this great tool!

@Donkie
Copy link
Owner

Donkie commented Oct 23, 2023

This seems very nice, I like that you managed to make it all without having to touch the components themselves.
I have tried it and the functionality seems to work well. One thing I noticed is that it doesn't seem to update when I click the "Clear Filters" button.

I'm also thinking if showColumns should be part of the hash. Is that really something you want to share?

I'm also wondering if perhaps the hash could be cleaned up a bit. This actually goes for the data saved in the localStorage as well. Sometimes it stores an empty filter, so perhaps we should filter out empty filters before saving and adding to the hash?

@clevelandcs
Copy link
Contributor Author

I was thinking about excluding the columns bit myself too. I don't think it is entirely necessary and would reduce complexity a bit.

I agree that the data could be shortened a bit and it does seem like empty filters are being stored in localStorage. I didn't want to add additional logic that would be specific to the hash and have a disconnect between what is visible in the URL and what is stored in localStorage.

I would love to see empty/default/unused filtering data excluded from localStorage and the hash to make both more concise. Do you have any suggestions or insight into a way to do that? Right now all I can think of is another function that would take the field in question and check if it is empty or default so there could be an if statement around each of the filter/sort/pagination save logic.

@Donkie
Copy link
Owner

Donkie commented Oct 23, 2023

I agree that the data could be shortened a bit and it does seem like empty filters are being stored in localStorage. I didn't want to add additional logic that would be specific to the hash and have a disconnect between what is visible in the URL and what is stored in localStorage.

I would love to see empty/default/unused filtering data excluded from localStorage and the hash to make both more concise. Do you have any suggestions or insight into a way to do that? Right now all I can think of is another function that would take the field in question and check if it is empty or default so there could be an if statement around each of the filter/sort/pagination save logic.

I think you could add a simple filtering function for excluding any CrudFilters that have an empty list as value. You don't need to have any specific logic for specific fields, it should be generic

@clevelandcs clevelandcs changed the title Add support for sharing table views via link v2 Add support for sharing table views via link Oct 23, 2023
@clevelandcs
Copy link
Contributor Author

clevelandcs commented Oct 24, 2023

I've changed the table setting updater functions as discussed. Both localStorage and the URL hash are only being set if the change differs from the default table behavior. In addition, in the case of filters only filters that actually contain a filter value are being saved, this significantly reduces the number of characters that needed to be saved.

@Donkie
Copy link
Owner

Donkie commented Oct 24, 2023

I think it looks good now, so I'll go ahead and merge it. Thanks for the contribution again!

@Donkie Donkie merged commit 2bd6722 into Donkie:master Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants