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

[bug] Volunteer view in Supervisor/Admin dashboard should not default to search results from previous sessions. #451

Closed
Zrrrpy opened this issue Jul 26, 2020 · 9 comments · Fixed by #483
Labels
📋 Supervisor Work relating to the case supervisor role 👑 Admin Work relating to the admin role Priority: Medium

Comments

@Zrrrpy
Copy link
Collaborator

Zrrrpy commented Jul 26, 2020

Part of epic #105

What type of user is this for? [admin/supervisor/volunteer/all]
supervisors and admins

Where does/should this occur?
Volunteer view in supervisor and admin dashboard.

Current behavior
The volunteer view in supervisor/admin dashboard defaults to display only search results from the last session.

Intended behavior
The volunteer view in supervisor/admin dashboard should default to display all volunteers assigned to supervisor – in alphabetical order – first, followed by other volunteers.
For admins, it should display all active volunteers in alphabetical order, followed by all inactive volunteers in alphabetical order.

Screenshots
The volunteer view should not look like this at login.
Screen Shot 2020-07-26 at 12 39 24 PM (2)

@Zrrrpy Zrrrpy created this issue from a note in CASA Volunteer Portal (To do) Jul 26, 2020
@Zrrrpy Zrrrpy changed the title [bug] Volunteer view in Supervisor dashboard should not default to search results from previous sessions. [bug] Volunteer view in Supervisor/Admin dashboard should not default to search results from previous sessions. Jul 26, 2020
@Zrrrpy Zrrrpy added 📋 Supervisor Work relating to the case supervisor role 👑 Admin Work relating to the admin role Help Wanted This is a special label that enables github to showcase issues that want help Priority: Medium labels Jul 26, 2020
@cliftonmcintosh
Copy link
Collaborator

Is there guidance on how to reproduce this?

I have tried logging in as a supervisor, changing the filters, logging out and then back in. When I log back in, the filters I had set in the previous session are no longer there. They have been reset so that the logged-in supervisor sees only that supervisor's volunteers and sees all of them.

I've also tried filtering, closing a browser window without logging out, then opening a new window. In that scenario, the filters that I had set before are no longer there. As with the other scenario, they have been reset so that the logged-in supervisor sees only that supervisor's volunteers and sees all of them.

@cliftonmcintosh
Copy link
Collaborator

NVM. I see now. It's the "search" box over on the right that affects the behavior. I didn't see that when experimenting earlier.

@cliftonmcintosh
Copy link
Collaborator

cliftonmcintosh commented Jul 27, 2020

This occurs because the search is cached in the browser's local storage. From what I can tell, this capability is driven by the jquery-datatables-rails gem. I have looked through the README for that project, but I don't see information there on how to control this behavior.

Does anyone have any guidance on this? Neither looking through that project's issues nor Googling has yielded anything for me. I also took a look at an alternative gem, jquery-datatables, and the manual for the underlying jquery library, but I haven't found anything there that might help.

Here is a screenshot showing a cached search for "Lucinda". Note that the user has logged out but the search cache has remained in browser's local storage. The cache also affects any other user who might log in from the same browser on the same computer. I don't know how often this scenario occurs.

data-tables-in-local-storage

@compwron
Copy link
Collaborator

Hmm, thanks for digging into this! I think a good solution for this would be to delete the DataTables part of localstorage on logout.
https://developer.mozilla.org/en-US/docs/Web/API/Storage/removeItem
localStorage.setItem("key", value);
localStorage.removeItem(keyName);

@cliftonmcintosh
Copy link
Collaborator

@compwron
Copy link
Collaborator

I think that if we wanted to run js on logout, we might attach it to the click event of the logout link/button.

@bklang
Copy link
Collaborator

bklang commented Aug 1, 2020

Can I propose an alternative: What if we cleared all localStorage on login? This has a couple of advantages:

  • It clears all potentially stale data, rather than just the DataTables values mentioned here, which protects against cached data format changes on login
  • If a user loses their session for other reasons (for example, because they cleared cookies) the data will still be safely cleared
  • (probably not a problem in this case) This approach also protects any user who logs out prior to this change being made

@cliftonmcintosh
Copy link
Collaborator

I'm unlikely to work on this in the near term, so anyone else interested should please feel free to pick it up.

@alindeman
Copy link
Collaborator

I gave this a go in #483. Feedback welcomed: JavaScript is not my primary language.

@Zrrrpy Zrrrpy moved this from To do to In progress in CASA Volunteer Portal Aug 2, 2020
CASA Volunteer Portal automation moved this from In progress to Done Aug 2, 2020
@Zrrrpy Zrrrpy removed the Help Wanted This is a special label that enables github to showcase issues that want help label Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📋 Supervisor Work relating to the case supervisor role 👑 Admin Work relating to the admin role Priority: Medium
Projects
CASA Volunteer Portal
Done (in prod!)
Development

Successfully merging a pull request may close this issue.

5 participants