Bug 36582

Summary: Add option to set library, desk, and register from user menu
Product: Koha Reporter: Owen Leonard <oleonard>
Component: Staff interfaceAssignee: Owen Leonard <oleonard>
Status: Pushed to main --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: blawlor, david, gmcharlt, jonathan.druart, julian.maurice, kyle, lucas, martin.renvoize
Version: MainKeywords: additional_work_needed
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00
Bug Depends on: 30123    
Bug Blocks: 36844    
Attachments: Screen recording showing the menu interaction
Bug 36582: Add option to set library, desk, and register from user menu
Bug 36582: Add option to set library, desk, and register from user menu
Bug 36582: Add option to set library, desk, and register from user menu
Bug 36582: Add option to set library, desk, and register from user menu
Bug 36582: Add option to set library, desk, and register from user menu
Bug 36582: Add option to set library, desk, and register from user menu
Bug 36582: Fix regressions.t

Description Owen Leonard 2024-04-11 15:19:06 UTC
Created attachment 164769 [details]
Screen recording showing the menu interaction

I'm proposing a change to the staff interface's user dropdown menu so that one can set their library, desk, and register right from the dropdown menu. See the attached gif.
Comment 1 Lucas Gass 2024-04-11 15:26:34 UTC
Big +1 from me.
Comment 2 Katrin Fischer 2024-04-13 10:56:36 UTC
+2 :)
Comment 3 Owen Leonard 2024-04-15 17:00:34 UTC Comment hidden (obsolete)
Comment 4 Owen Leonard 2024-04-15 17:01:13 UTC
This is technically BLOCKED but I thought I'd get eyes on it since it's otherwise ready.
Comment 5 Martin Renvoize 2024-04-19 05:18:18 UTC
Nice
Comment 6 Owen Leonard 2024-04-22 10:59:34 UTC Comment hidden (obsolete)
Comment 7 Owen Leonard 2024-04-23 11:20:02 UTC Comment hidden (obsolete)
Comment 8 Lucas Gass 2024-04-23 14:21:06 UTC
Not a blocker but a question. If I log in as STAFF C ( not a superlibrarian and no logged in library permission ) I don't see the gear icon for switching desk/register but if I visit circ/set-library.pl I can set either my desk or register. Is this the intended behavior?
Comment 9 Owen Leonard 2024-04-23 14:47:23 UTC
Yes the logic needs to be a little more complex.
Comment 10 Brendan Lawlor 2024-04-23 15:00:32 UTC
The interface for this is a big improvement. Nice!

I think there is a currently a small bug in the register_selection.js that needs to be fixed for this to work.

With this patch applied it's possible to set your cash register to one that is not associated with the branch that is selected.

To reproduce:
1. Create a few circulation desks and cash registers
2. Set your circulation desk and cash register for library A
3. Return to the set library page and choose library B
4. Notice the cash registers options have updated for library B but the default selected cash register did not change
5. Clicking submit sets the cash register to one that should not be available for library A
Comment 11 Owen Leonard 2024-04-25 16:28:52 UTC Comment hidden (obsolete)
Comment 12 David Nind 2024-05-05 00:31:50 UTC
Created attachment 166164 [details] [review]
Bug 36582: Add option to set library, desk, and register from user menu

This patch adds an expandable "panel" in the user dropdown menu in the
staff client. Expanding the panel will load the form from
set-library.pl, including library, desk and register options if present.

The patch moves the contents of desk_selection.js and
register_selection.js into staff-global.js so that the functionality is
available on every page.

To test, apply the patch and rebuild the staff interface CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

Test plan stolen from Bug 36572:

1. Have 3 staff accounts to test:
  -STAFF A: superlibrarian
  -STAFF B: loggedinlibrary permission
  -STAFF C: no loggedinlibrary or superlibrarian permission
2. Enable 'UseCirculationDesks' and create some desks. (Admin >
   Circulation desks)
3. Enable 'UseCashRegisters' and create some registers ( Admin > Cash
   registers)
4. Use STAFF A ( superlibrarian ) and make sure you can change branch,
   desk and register.
5. Use STAFF B ( loggedinlibrary permission ) and make sure you can
   change branch, desk and register.
6. Use STAFF C ( no loggedinlibrary or superlibrarian permission ) and
   make sure you can change branch, desk and register.
7. Each time you change you should be redirected to the page you were
   previously on.
8. Turn off UseCirculationDesks, make sure everything still works.
9. Turn off UseCashRegisters, make sure everthing still works.

Signed-off-by: David Nind <david@davidnind.com>
Comment 13 David Nind 2024-05-05 01:35:47 UTC
I like the change, and have signed off as it works as expected (behavour before and after the patch remains the same as far as I can tell).

However, the behavour with choosing the cash register confuses me (both before and after the patch). Maybe I'm over thinking things!

With desks - makes sense
------------------------

With both UseCirculationDesks and UseCashRegisters enabled, or just UseCirculationDesks enabled, the behavour for the desks makes sense to me. 

Example:
- No desks set for current library (Centerville)
- Desk displays as ---, from dropdown list can change to the desks for that library (select CENTDESK1 and Submit)
- Change to a library with desks: desks is set to the first desk for that library, can choose any of the other the desks for that library from the dropdown list
- Change to a library without desks: desks is set to ---, no options to choose for that library (as expected, as there aren't any)
- If you log in again, don't set a desk for Centerville, change to another library with desks, desks is set to the first desk for that library, can choose any of the other the desks for that library from the dropdown list
- Rationale: desks are physical, so can't be shared between libraries
- Notes:
  . If no desk is selected, it displays as --- (for cash registers, it displays as -- None --). Maybe they should be changed so they are consistent?
  . If no desks are yet selected or set, should it display as --- or the first desk available for that library?

Cash registers - doesn't make sense to me
-----------------------------------------

However, with the cash registers (with or without desks enabled), I find the behavour confusing and doesn't make sense to me. Most likely, it is my understanding at fault.

Example:
- No cash register set for current library (Centerville)
- Cash register displays as -- None --, from dropdown list can change to the cash registers for that library 
- For Centerville, select CENTCASH1 and Submit
- Change to a library with cash registers: it displays as CENTCASH1, can choose any of the other the cash registers for that library from the dropdown list
- Change to a library without cash registers: cash registers displays as CENTCASH1, no options to choose for that library (as expected, as there aren't any)
- For a library with or without cash register, with CENTCASH1 shown, select Submit - displays as CENTCASH1 in top right-hand of the screen
- Go to change the cash register for that library again:
  . A library with cash registers: displays as -- None --, can choose from the cash registers for that library
  . A library without cash registers: displays as -- None --, no options from the dropdown list to choose
- Rationale: I don't understand the rationale, maybe the same cash registers can be used by multiple libraries?

How I set things up
===================

I set up two desks each for three libraries:
- Centerville: CENTDESK1, CENTDESK2
- Midway: MIDDESK1, MIDDESK2
- Springfield: SPRINGDESK1, SPRINGDESK2

I set up two cash registers each for three libraries:
- Centerville: CENTCASH1, CENTCASH2
- Midway: MIDCASH1, MIDCASH2
- Springfield: SPRINGCASH1, SPRINGCASH2

I didn't set a default cash register.
Comment 14 Kyle M Hall 2024-05-07 18:56:24 UTC
Created attachment 166346 [details] [review]
Bug 36582: Add option to set library, desk, and register from user menu

This patch adds an expandable "panel" in the user dropdown menu in the
staff client. Expanding the panel will load the form from
set-library.pl, including library, desk and register options if present.

The patch moves the contents of desk_selection.js and
register_selection.js into staff-global.js so that the functionality is
available on every page.

To test, apply the patch and rebuild the staff interface CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

Test plan stolen from Bug 36572:

1. Have 3 staff accounts to test:
  -STAFF A: superlibrarian
  -STAFF B: loggedinlibrary permission
  -STAFF C: no loggedinlibrary or superlibrarian permission
2. Enable 'UseCirculationDesks' and create some desks. (Admin >
   Circulation desks)
3. Enable 'UseCashRegisters' and create some registers ( Admin > Cash
   registers)
4. Use STAFF A ( superlibrarian ) and make sure you can change branch,
   desk and register.
5. Use STAFF B ( loggedinlibrary permission ) and make sure you can
   change branch, desk and register.
6. Use STAFF C ( no loggedinlibrary or superlibrarian permission ) and
   make sure you can change branch, desk and register.
7. Each time you change you should be redirected to the page you were
   previously on.
8. Turn off UseCirculationDesks, make sure everything still works.
9. Turn off UseCashRegisters, make sure everthing still works.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 15 Katrin Fischer 2024-05-08 16:25:11 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 16 Jonathan Druart 2024-05-10 08:05:16 UTC
Created attachment 166500 [details] [review]
Bug 36582: Fix regressions.t
Comment 17 Katrin Fischer 2024-05-10 11:13:25 UTC
Follow-up pushed to main.
Comment 18 Julian Maurice 2024-05-13 12:51:13 UTC
This bug removes desk_selection.js and register_selection.js but there are references to these files in koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt and koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt
This should be fixed
Comment 19 Katrin Fischer 2024-05-13 13:07:21 UTC
(In reply to Julian Maurice from comment #18)
> This bug removes desk_selection.js and register_selection.js but there are
> references to these files in koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt
> and koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt
> This should be fixed

Hi Julian, please set the additional_work_needed keyword in such cases, so we can track these a bit better!