From be0aed90bdffeb85935a51f864d3cf78df491574 Mon Sep 17 00:00:00 2001 From: Nicolas Legrand Date: Tue, 28 Apr 2020 12:02:15 +0200 Subject: [PATCH] Bug 24201: (follow-up) add desk choice with library choice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You should be able to add desk choice when you are logging in or changing library. Test plan: 1. apply patch 2. log in, you should see desks if they are defined. All are disabled. 3. when choosing a library, it should enabled all desks it has and pick one. 4. the desk should be in your session (not working yet, I don't undersand how to do it) 5. change library from intranet 6. you should have the same behaviours PROBLEMS: 1. I don't know how to send desk from login page 2. What about multiple libraries with some not having desk? This patch assume that when you use desks, you use it for every libraries 3. when changing library, the bar displaying the library and the desk (up right) doesn't update the desk when arriving on the updated page of set-library.tt. It is changed only after having clicked on “continue” 4. should we keep a separate desk changing page or is it redundant? --- Koha/Template/Plugin/Desks.pm | 6 ++++++ circ/set-library.pl | 22 +++++++++++++++++++++- .../prog/en/includes/html_helpers.inc | 10 ++++++++++ .../prog/en/includes/intranet-bottom.inc | 1 + .../intranet-tmpl/prog/en/includes/js_includes.inc | 4 ++++ koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt | 16 ++++++++++++++++ .../prog/en/modules/circ/set-library.tt | 20 ++++++++++++++++++-- koha-tmpl/intranet-tmpl/prog/js/desk_selection.js | 17 +++++++++++++++++ 8 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/desk_selection.js diff --git a/Koha/Template/Plugin/Desks.pm b/Koha/Template/Plugin/Desks.pm index 27d0297..266cc3a 100644 --- a/Koha/Template/Plugin/Desks.pm +++ b/Koha/Template/Plugin/Desks.pm @@ -87,4 +87,10 @@ sub ListForLibrary { ); } +sub all { + + my ( $self ) = @_; + return Koha::Desks->search( )->unblessed; +} + 1; diff --git a/circ/set-library.pl b/circ/set-library.pl index 375a7f7..7a7ff34 100755 --- a/circ/set-library.pl +++ b/circ/set-library.pl @@ -26,6 +26,7 @@ use C4::Auth qw/:DEFAULT get_session/; use C4::Koha; use Koha::BiblioFrameworks; use Koha::Libraries; +use Koha::Desks; my $query = CGI->new(); @@ -42,7 +43,9 @@ my $sessionID = $query->cookie("CGISESSID"); my $session = get_session($sessionID); my $branch = $query->param('branch' ); +my $desk_id = $query->param('desk_id'); my $userenv_branch = C4::Context->userenv->{'branch'} || ''; +my $userenv_desk = C4::Context->userenv->{'desk_id'} || ''; my @updated; # $session lddines here are doing the updating @@ -56,11 +59,27 @@ if ( $branch and my $library = Koha::Libraries->find($branch) ) { $session->flush(); push @updated, { updated_branch => 1, - old_branch => $userenv_branch, + old_branch => $userenv_branch, }; } # else branch the same, no update + if ( !$userenv_desk or $userenv_desk ne $desk_id ) { + my $desk = Koha::Desks->find( { desk_id => $desk_id } ); + my $old_desk_name = ''; + if ($userenv_desk) { + $old_desk_name = Koha::Desks->find( { desk_id => $userenv_desk })->desk_name; + } + $template->param( LoginDeskname => $desk->desk_name ); + $template->param( LoginDeskid => $desk->desk_id ); + $session->param( desk_name => $desk->desk_name ); + $session->param( desk_id => $desk->desk_id ); + push @updated, { + updated_desk => 1, + old_desk => $old_desk_name, + }; + } } else { $branch = $userenv_branch; # fallback value + $desk_id = $userenv_desk; } $template->param(updated => \@updated) if (scalar @updated); @@ -87,6 +106,7 @@ if (scalar @updated and not scalar @recycle_loop) { $template->param( referer => $referer, branch => $branch, + desk_id => $desk_id, recycle_loop=> \@recycle_loop, ); 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 b761688..fc8a96d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc @@ -8,6 +8,16 @@ [% END %] [% END %] +[% BLOCK options_for_desks %] + [% FOREACH d IN desks %] + [% IF d.branchcode == branch %] + + [% ELSE %] + + [% END%] + [% END %] + [% END %] + [% BLOCK options_for_authorised_value_categories %] [% FOREACH avc IN authorised_value_categories %] [% IF avc.selected %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc index e0bce02..27ba415 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc @@ -73,5 +73,6 @@ [% jsinclude | $raw # Parse the page template's JavaScript block if necessary %] [% END %] [% KohaPlugins.get_plugins_intranet_js | $raw %] + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc index bd833a4..81e8832 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc @@ -26,6 +26,9 @@ [% Asset.js("js/staff-global.js") | $raw %] [% Asset.js("js/commons.js") | $raw %] +[% IF setdesk %] +[% Asset.js("js/desk_selection.js") | $raw %] +[% END %] [% INCLUDE 'validator-strings.inc' %] [% IF ( IntranetUserJS ) %] @@ -146,3 +149,4 @@ [% END %] + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt index 4d73d26..3d5dd13 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt @@ -1,8 +1,12 @@ [% USE raw %] [% USE Koha %] [% USE Branches %] +[% USE Desks %] [% USE Categories %] [% SET footerjs = 1 %] +[% IF Desks.all %] + [% SET setdesk = 1 %] +[% END %] [% INCLUDE 'doc-head-open.inc' %] Koha › [% IF ( nopermission ) %]Access denied[% END %] @@ -81,6 +85,18 @@ [% END %] </select> </p> + [% IF Desks.all %] + <p> + <label for="desk">Desk:</label> + <select name="desk_id" id="desk_id" class="input" tabindex="3"> + <option value="">My desk</option> + [% FOREACH d IN Desks.all %] + <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" disabled >[% d.desk_name | html %]</option> + [% END %] + </select> + </p> +</fieldset> +[% END %] [% END %] <!-- <p><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />Remember me</label></p> --> 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 127332e..d8ba29f 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 @@ -1,5 +1,9 @@ [% USE Branches %] +[% USE Desks %] [% USE Koha %] +[% IF Desks.all %] + [% SET setdesk = 1 %] +[% END %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Circulation › Set library [% INCLUDE 'doc-head-close.inc' %] @@ -36,7 +40,9 @@ Updated: