Bugzilla – Attachment 166164 Details for
Bug 36582
Add option to set library, desk, and register from user menu
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36582: Add option to set library, desk, and register from user menu
Bug-36582-Add-option-to-set-library-desk-and-regis.patch (text/plain), 22.87 KB, created by
David Nind
on 2024-05-05 00:31:50 UTC
(
hide
)
Description:
Bug 36582: Add option to set library, desk, and register from user menu
Filename:
MIME Type:
Creator:
David Nind
Created:
2024-05-05 00:31:50 UTC
Size:
22.87 KB
patch
obsolete
>From 4dda2bf311c1e983c7611adedb8436a41fcabe82 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Fri, 26 Jan 2024 18:14:04 +0000 >Subject: [PATCH] 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> >--- > .../prog/css/src/staff-global.scss | 57 ++++++++++++- > .../intranet-tmpl/prog/en/includes/header.inc | 81 ++++++++++++------- > .../prog/en/includes/html_helpers.inc | 2 +- > .../prog/en/modules/circ/set-library.tt | 22 +++-- > .../prog/en/modules/intranet-main.tt | 4 +- > .../intranet-tmpl/prog/js/desk_selection.js | 29 ------- > .../prog/js/register_selection.js | 27 ------- > .../intranet-tmpl/prog/js/staff-global.js | 74 +++++++++++++++++ > 8 files changed, 193 insertions(+), 103 deletions(-) > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/desk_selection.js > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/register_selection.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >index 121030e70f..f048744e8f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -4367,7 +4367,7 @@ input.renew { > left: 0; > right: 0; > bottom: 0; >- background-color: #ccc; >+ background-color: #CCC; > -webkit-transition: .4s; > transition: .4s; > border-radius: 34px; >@@ -4746,6 +4746,61 @@ div .suggestion_note { > } > } > >+#set_library_controls { >+ align-items: center; >+ display: flex; >+ >+ div:first-child { >+ flex-grow: 1; >+ } >+ >+ a.btn { >+ border-radius: 0; >+ font-size: 13px; >+ } >+} >+ >+#setlibrary_panel { >+ .setlibrary_panel_open { >+ border-bottom:1px solid #CCC; >+ border-top:1px solid #CCC; >+ } >+ >+ fieldset { >+ background-color: #554B4D; >+ margin: 0; >+ >+ &.rows { >+ float: none; >+ padding: 0; >+ width: auto; >+ } >+ >+ &.action { >+ padding: .5em 0 1em 1em; >+ } >+ } >+ >+ legend { >+ display: none; >+ } >+ >+ label { >+ color: #FFF; >+ display: block; >+ float: none; >+ font-weight: normal; >+ margin: 0; >+ padding-bottom: .2em; >+ text-align: left; >+ width: unset; >+ } >+ >+ select { >+ width: 80%; >+ } >+} >+ > @import "header"; > @import "toolbar"; > @import "forms"; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >index 783271b18d..78cacbd6ed 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >@@ -3,6 +3,7 @@ > [% USE Desks %] > [% USE Registers %] > [% USE Koha %] >+[% PROCESS 'i18n.inc' %] > [% IF Koha.Preference( 'CookieConsent' ) %] > [% USE JSConsents %] > [% END %] >@@ -85,7 +86,7 @@ > > <ul id="user-menu" class="nav navbar-nav navbar-right"> > [% IF ( loggedinusername ) %] >- <li class="dropdown"> >+ <li class="dropdown" id="logged-in-dropdown"> > <a href="#" id="logged-in-menu" role="button" class="dropdown-toggle" data-toggle="dropdown"> > <span id="logged-in-info-brief"> > <i class="fa fa-user"></i> >@@ -163,39 +164,61 @@ > </li> > [% END %] > >- [% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary ) %] >- <li role="separator" class="loggedin-menu-label divider"></li> >- <li> >- [% IF Koha.Preference('UseCirculationDesks') && Koha.Preference('UseCashRegisters') %] >- <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library, desk and register</a> >- [% ELSIF Koha.Preference('UseCirculationDesks') %] >- <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library and desk</a> >- [% ELSIF Koha.Preference('UseCashRegisters') %] >- <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library and cash register</a> >- [% ELSE %] >- <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library</a> >- [% END %] >- </li> >+ [% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary || Koha.Preference('UseCirculationDesks') || Koha.Preference('UseCashRegisters') ) %] >+ <li role="separator" class="loggedin-menu-label divider"></li> >+ <li> >+ <div id="set_library_controls"> >+ <div> >+ <a class="btn btn-link" href="/cgi-bin/koha/circ/set-library.pl"> >+ [% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary ) %] >+ [% IF ( Koha.Preference('UseCirculationDesks') && Koha.Preference('UseCashRegisters') ) %] >+ [% t("Set library, desk, and register") | html %] >+ [% ELSIF ( Koha.Preference('UseCirculationDesks') ) %] >+ [% t("Set library and desk") | html %] >+ [% ELSIF ( Koha.Preference('UseCashRegisters') ) %] >+ [% t("Set library and cash register") | html %] >+ [% ELSE %] >+ [% t("Set library") | html %] >+ [% END %] >+ [% ELSIF ( Koha.Preference('UseCirculationDesks') && Koha.Preference('UseCashRegisters') ) %] >+ [% t("Set desk and cash register") | html %] >+ [% ELSIF ( Koha.Preference('UseCashRegisters') ) %] >+ [% t("Set cash register") | html %] >+ [% ELSIF ( Koha.Preference('UseCirculationDesks') ) %] >+ [% t("Set desk") | html %] >+ [% END %] >+ </a> >+ </div> >+ [% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary || Koha.Preference('UseCirculationDesks') || Koha.Preference('UseCashRegisters') ) %] >+ <div> >+ <a id="branch_select_cog" class="btn btn-link" href="#"><i class="fa fa-cog" aria-label="Toggle panel for login settings"></i></a> >+ </div> >+ [% END %] >+ </div> >+ </li> >+ >+ <li id="setlibrary_panel" style="display:none"></li> >+ <li> > [% ELSIF Koha.Preference('UseCirculationDesks') && Koha.Preference('UseCashRegisters') %] >- <li role="separator" class="loggedin-menu-label divider"></li> >- <li> >- <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set desk and cash register</a> >- </li> >+ <li role="separator" class="loggedin-menu-label divider"></li> >+ <li> >+ <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set desk and cash register</a> >+ </li> > [% ELSIF Koha.Preference('UseCirculationDesks') %] >- <li role="separator" class="loggedin-menu-label divider"></li> >- <li> >- <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set desk</a> >- </li> >+ <li role="separator" class="loggedin-menu-label divider"></li> >+ <li> >+ <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set desk</a> >+ </li> > [% ELSIF Koha.Preference('UseCashRegisters') %] >- <li role="separator" class="loggedin-menu-label divider"></li> >- <li> >- <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set cash register</a> >- </li> >+ <li role="separator" class="loggedin-menu-label divider"></li> >+ <li> >+ <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set cash register</a> >+ </li> > [% END %] > [% IF EnableSearchHistory %] >- <li> >- <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a> >- </li> >+ <li> >+ <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a> >+ </li> > [% END %] > > [% IF loggedinusernumber %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >index 5b514f5736..cbac52202b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -32,7 +32,7 @@ > <option class="[%- r.branch | html -%][%- IF r.branch_default -%] default[%- END -%]" value="[% r.id | html %]">[% r.name | html %]</option> > [% END%] > [% ELSE %] >- <option class="[%- r.branch | html -%][%- IF r.branch_default -%] default[%- END -%]" value="[% r.id | html %]" disabled style="display: none">[% r.name | html %]</option> >+ <option class="[%- r.branch | html -%][%- IF r.branch_default -%] default[%- END -%]" value="[% r.id | html %]" disabled="disabled" style="display: none">[% r.name | html %]</option> > [% END %] > [% END %] > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt >index 3a25d31297..79897c6cff 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt >@@ -49,21 +49,21 @@ > [% END %] > [% INCLUDE 'messages.inc' %] > <h1>Set library</h1> >- <form method="post" action="set-library.pl"> >+ <form method="post" action="/cgi-bin/koha/circ/set-library.pl" id="set-library-form"> > [% INCLUDE 'csrf-token.inc' %] > <input type="hidden" name="op" value="cud-set-library" /> > [% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary ) %] > <fieldset class="rows"> > <legend>Set library</legend> > <ol> >- <li><label for="branch">Choose library:</label> >- <select name="branch" id="branch"> >+ <li><label for="set-library-branch">Choose library:</label> >+ <select name="branch" id="set-library-branch"> > [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %] > </select></li> > </ol> > </fieldset> > [% ELSE %] >- <select name="branch" id="branch" style="visibility:hidden;"> >+ <select name="branch" id="set-library-branch" style="visibility:hidden;"> > [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %] > </select> > [% END %] >@@ -72,8 +72,8 @@ > <fieldset class="rows"> > <legend>Set desk</legend> > <ol> >- <li><label for="desk_id">Choose desk:</label> >- <select name="desk_id" id="desk_id"> >+ <li><label for="set-library-desk_id">Choose desk:</label> >+ <select name="desk_id" id="set-library-desk_id"> > [% PROCESS options_for_desks desks => Desks.all(), selected => desk_id %] > </select></li> > </ol> >@@ -84,9 +84,9 @@ > <legend>Set cash register</legend> > <ol> > <li> >- <label for="register_id">Choose cash register:</label> >- <select name="register_id" id="register_id"> >- <option id="noregister" selected="selected" value="">-- None --</option> >+ <label for="set-library-register_id">Choose cash register:</label> >+ <select name="register_id" id="set-library-register_id"> >+ <option id="set-library-noregister" selected="selected" value="">-- None --</option> > [% PROCESS options_for_registers registers => Registers.all() %] > </select> > </li> >@@ -114,9 +114,5 @@ > </main> > </div> <!-- /.col-sm-12 --> > </div> <!-- /.row --> >-[% MACRO jsinclude BLOCK %] >- [% Asset.js("js/desk_selection.js") | $raw %] >- [% Asset.js("js/register_selection.js") | $raw %] >-[% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >index 70da106b61..0449ddfd1a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >@@ -301,14 +301,12 @@ > > [% MACRO jsinclude BLOCK %] > <script> >- //<![CDATA[ >- var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this news item? This cannot be undone."); >+ var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this news item? This cannot be undone."); > $(document).ready(function(){ > $(".news_delete").on("click", function(){ > return confirmDelete(MSG_CONFIRM_DELETE); > }); > }); >- //]]> > </script> > [% END %] > <!-- the main div is closed in intranet-bottom.inc --> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/desk_selection.js b/koha-tmpl/intranet-tmpl/prog/js/desk_selection.js >deleted file mode 100644 >index 2b58e367b0..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/desk_selection.js >+++ /dev/null >@@ -1,29 +0,0 @@ >-$(document).ready(function() { >- >- $("#branch").on("change", function() { >- >- $("#desk_id").children().each(function() { >- var selectedBranch = $("#branch"). children("option:selected"). val(); >- if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element >- $(this).prop("selected", true); >- $(this).prop("disabled", false); >- $(this).show(); >- } >- else if ($(this).hasClass(selectedBranch)) { >- $('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option >- $('#nodesk').hide(); >- $(this).prop("disabled", false); >- $(this).show(); >- if ( selectedBranch == $(".logged-in-branch-code").html() ) { >- $("#desk_id").val($(".logged-in-desk-id").html()); >- } >- else { >- $("#desk_id").val($("#desk_id option:not([disabled]):first").val()); >- } >- } else { >- $(this).prop("disabled", true); >- $(this).hide(); >- } >- }); >- }); >-}); >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/js/register_selection.js b/koha-tmpl/intranet-tmpl/prog/js/register_selection.js >deleted file mode 100644 >index b4d68590c6..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/register_selection.js >+++ /dev/null >@@ -1,27 +0,0 @@ >-$(document).ready(function() { >- $("#branch").on("change", function() { >- var selectedBranch = $("#branch").children( >- "option:selected").val(); >- >- $("#register_id").children().each(function() { >- // default to no-register >- if ($(this).is("#noregister")) { >- $(this).prop("selected", true) >- } >- // display branch registers >- else if ($(this).hasClass(selectedBranch)) { >- $(this).prop("disabled", false); >- $(this).show(); >- // default to branch default if there is one >- if ($(this).hasClass("default")) { >- $(this).prop("selected", true) >- } >- } >- // hide non-branch registers >- else { >- $(this).hide(); >- $(this).prop("disabled", true); >- } >- }); >- }); >-}); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 71db55ae88..e2b9d175d9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -284,6 +284,7 @@ $(document).ready(function () { > $("#bookbag_form a[href*='detail.pl?']").click(function () { > resetSearchContext(); > }); >+ > // add back to top button on each staff page > $("body").append('<button id="backtotop" class="btn btn-default" aria-label="' + __("Back to top") + '"><i class="fa fa-arrow-up" aria-hidden="true"></i></button>'); > $("#backtotop").hide(); >@@ -298,6 +299,79 @@ $(document).ready(function () { > e.preventDefault(); > $("html,body").animate({scrollTop: 0}, "slow"); > }); >+ >+ $("body").on("change", "#set-library-branch", function () { >+ var selectedBranch = $("#set-library-branch").val(); >+ $("#set-library-desk_id") >+ .children() >+ .each(function () { >+ console.log( $(this) ); >+ if ($(this).attr("id") === "nodesk") { >+ // set no desk by default, should be first element >+ $(this).prop("selected", true); >+ $(this).prop("disabled", false); >+ $(this).show(); >+ } else if ( $(this).hasClass(selectedBranch) ) { >+ $("#nodesk").prop("disabled", true); // we have desk, no need for nodesk option >+ $("#nodesk").hide(); >+ $(this).prop("disabled", false); >+ $(this).show(); >+ if ( selectedBranch == $(".logged-in-branch-code").html() ) { >+ $("#set-library-desk_id").val( $(".logged-in-desk-id").html() ); >+ } else { >+ $("#nodesk").hide(); >+ $("#set-library-desk_id").val( >+ $("#set-library-desk_id option:not([disabled]):first").val() >+ ); >+ } >+ } else { >+ $(this).prop("disabled", true); >+ $(this).hide(); >+ } >+ }); >+ >+ $("#set-library-register_id").children().each(function() { >+ // default to no-register >+ if ($(this).is("#noregister")) { >+ $(this).prop("selected", true) >+ } else if ($(this).hasClass(selectedBranch)) { >+ // display branch registers >+ $(this).prop("disabled", false); >+ $(this).show(); >+ // default to branch default if there is one >+ if ($(this).hasClass("default")) { >+ $(this).prop("selected", true) >+ } >+ } else { >+ // hide non-branch registers >+ $(this).hide(); >+ $(this).prop("disabled", true); >+ } >+ }); >+ }); >+ >+ $("body").on("click", "#setlibrary_panel #cancel_set_library", function(e){ >+ e.preventDefault(); >+ $("#setlibrary_panel").removeClass("setlibrary_panel_open").html("").hide(); >+ }); >+ >+ $("#branch_select_cog").on("click", function(e){ >+ e.stopPropagation(); >+ let setlibrary_panel = $("#setlibrary_panel"); >+ if( setlibrary_panel.hasClass("setlibrary_panel_open") ){ >+ setlibrary_panel.removeClass("setlibrary_panel_open").html("").hide(); >+ } else { >+ setlibrary_panel.addClass("setlibrary_panel_open").show(); >+ $("#setlibrary_panel").load( "/cgi-bin/koha/circ/set-library.pl #set-library-form", function(){ >+ // setLibraryDeskOptions(); >+ }); >+ } >+ }); >+ >+ $("#logged-in-dropdown").on('hidden.bs.dropdown', function () { >+ $("#setlibrary_panel").removeClass("setlibrary_panel_open").html("").hide(); >+ }); >+ > }); > > function removeLastBorrower() { >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36582
:
164769
|
164895
|
165261
|
165377
|
165573
|
166164
|
166346
|
166500