Bugzilla – Attachment 107093 Details for
Bug 24201
Attach desk to intranet session
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24201: (follow-up) add desk choice with library choice
Bug-24201-follow-up-add-desk-choice-with-library-c.patch (text/plain), 19.79 KB, created by
Martin Renvoize (ashimema)
on 2020-07-20 12:46:33 UTC
(
hide
)
Description:
Bug 24201: (follow-up) add desk choice with library choice
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-07-20 12:46:33 UTC
Size:
19.79 KB
patch
obsolete
>From 615652846ad4406d8eaf969816b5cfb1db3fe1b7 Mon Sep 17 00:00:00 2001 >From: Nicolas Legrand <nicolas.legrand@bulac.fr> >Date: Tue, 28 Apr 2020 12:02:15 +0200 >Subject: [PATCH] Bug 24201: (follow-up) add desk choice with library choice > >You should be able to add desk choice when you are logging in or >changing library. > >Test plan: > >1. apply patch >2. have at least three libraries, one without desk, one with one and >one with a few. >3. At login, when choosing a library, it should enable all desks it >has. Pick one. >4. the desk id and name should be set in your session and appear in >the top right, next to the library name. >5. change library and desks from intranet (at the set-library.pl page) >6. you should have the same behaviours >7. if you have a library without a desk, it should prompt you a '---' >option and no desks will be attached to the session. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Auth.pm | 11 ++- > Koha/Template/Plugin/Desks.pm | 17 +++- > circ/selectdesk.pl | 87 ------------------- > circ/set-library.pl | 24 ++++- > .../prog/en/includes/circ-nav.inc | 4 - > .../intranet-tmpl/prog/en/includes/header.inc | 5 -- > .../prog/en/includes/html_helpers.inc | 11 +++ > .../prog/en/includes/intranet-bottom.inc | 1 + > .../prog/en/includes/js_includes.inc | 3 + > .../intranet-tmpl/prog/en/modules/auth.tt | 16 ++++ > .../prog/en/modules/circ/circulation-home.tt | 6 -- > .../prog/en/modules/circ/set-library.tt | 20 ++++- > .../intranet-tmpl/prog/js/desk_selection.js | 42 +++++++++ > 13 files changed, 139 insertions(+), 108 deletions(-) > delete mode 100755 circ/selectdesk.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/desk_selection.js > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 28cb8f42d8..6ea435eda8 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -1070,7 +1070,7 @@ sub checkauth { > C4::Context->_unset_userenv($sessionID); > } > my ( $borrowernumber, $firstname, $surname, $userflags, >- $branchcode, $branchname, $emailaddress ); >+ $branchcode, $branchname, $emailaddress, $desk_id, $desk_name ); > > if ( $return == 1 ) { > my $select = " >@@ -1114,6 +1114,11 @@ sub checkauth { > my $library = Koha::Libraries->find($branchcode); > $branchname = $library? $library->branchname: ''; > } >+ if ( $query->param('desk_id') ) { >+ $desk_id = $query->param('desk_id'); >+ my $desk = Koha::Desks->find($desk_id); >+ $desk_name = $desk ? $desk->desk_name : ''; >+ } > my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search }; > if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) { > >@@ -1149,6 +1154,8 @@ sub checkauth { > $session->param( 'surname', $surname ); > $session->param( 'branch', $branchcode ); > $session->param( 'branchname', $branchname ); >+ $session->param( 'desk_id', $desk_id); >+ $session->param( 'desk_name', $desk_name); > $session->param( 'flags', $userflags ); > $session->param( 'emailaddress', $emailaddress ); > $session->param( 'ip', $session->remote_addr() ); >@@ -1164,7 +1171,7 @@ sub checkauth { > $session->param('surname'), $session->param('branch'), > $session->param('branchname'), $session->param('flags'), > $session->param('emailaddress'), $session->param('shibboleth'), >- $session->param('desk_id'), $session->param('desk_name') >+ $session->param('desk_id'), $session->param('desk_name') > ); > > } >diff --git a/Koha/Template/Plugin/Desks.pm b/Koha/Template/Plugin/Desks.pm >index 27d0297081..42164976e7 100644 >--- a/Koha/Template/Plugin/Desks.pm >+++ b/Koha/Template/Plugin/Desks.pm >@@ -73,7 +73,7 @@ sub GetLoggedInDeskName { > > [% Desks.ListForLibrary %] > >-returns all desks existing at the library >+returns all desks existing at the current library > > =cut > >@@ -87,4 +87,19 @@ sub ListForLibrary { > ); > } > >+=head3 all >+ >+[% Desks.all %] >+ >+returns all desks existing at all libraries >+ >+=cut >+ >+ >+sub all { >+ >+ my ( $self ) = @_; >+ return Koha::Desks->search( )->unblessed; >+} >+ > 1; >diff --git a/circ/selectdesk.pl b/circ/selectdesk.pl >deleted file mode 100755 >index 7589bac5c3..0000000000 >--- a/circ/selectdesk.pl >+++ /dev/null >@@ -1,87 +0,0 @@ >-#!/usr/bin/perl >- >-# Copyright (C) 2020 BULAC >-# >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >-use CGI qw ( -utf8 ); >- >-use C4::Context; >-use C4::Output; >-use C4::Auth qw/:DEFAULT get_session/; >-use C4::Koha; >-use Koha::Desks; >- >-my $query = CGI->new(); >- >-my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >- { >- template_name => "circ/selectdesk.tt", >- query => $query, >- type => "intranet", >- debug => 1, >- authnotrequired => 0, >- flagsrequired => { catalogue => 1, }, >- } >-); >- >-my $sessionID = $query->cookie("CGISESSID"); >-my $session = get_session($sessionID); >- >-my $branch = C4::Context->userenv->{'branch'}; >-my $searchfield = $query->param('searchfield'); >-my $desks_lists; >-if ($branch) { >- $desks_lists = Koha::Desks->search( { branchcode => $branch } )->unblessed; >-} >-else { >- $desks_lists = Koha::Desks->search( )->unblessed; >-} >- >-my $desk_id = $query->param('desk_id'); >- >-my $userenv_desk = C4::Context->userenv->{'desk_id'} || ''; >-my $updated = ''; >- >-if ($desk_id) { >- if ( !$userenv_desk or $userenv_desk ne $desk_id ) { >- my $desk = Koha::Desks->find( { desk_id => $desk_id } ); >- $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 ); >- $updated = 1; >- } >-} >-else { >- $desk_id = $userenv_desk; >-} >- >-$template->param( updated => \$updated ); >- >-my $referer = $query->param('oldreferer') || $ENV{HTTP_REFERER}; >-if ($updated) { >- print $query->redirect( $referer || '/cgi-bin/koha/mainpage.pl' ); >-} >- >-$template->param( >- referer => $referer, >- desks_list => $desks_lists, >- desk_id => $desk_id, >-); >- >-output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/circ/set-library.pl b/circ/set-library.pl >index 375a7f7809..775d824ab2 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,28 @@ 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 ( $desk_id && (!$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 ); >+ $session->flush(); >+ 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); >@@ -69,6 +89,7 @@ my @recycle_loop; > foreach ($query->param()) { > $_ or next; # disclude blanks > $_ eq "branch" and next; # disclude branch >+ $_ eq "desk_id" and next; # disclude desk_id > $_ eq "oldreferer" and next; # disclude oldreferer > push @recycle_loop, { > param => $_, >@@ -87,6 +108,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/circ-nav.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc >index 574224cdd6..979871a0b9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc >@@ -1,5 +1,4 @@ > [% USE Branches %] >-[% USE Desks %] > <div id="navmenu"> > <div id="navmenulist"> > >@@ -18,9 +17,6 @@ > [% IF ( AutoLocation ) %][% ELSE %][% IF ( IndependentBranches ) %][% ELSE %] > <li><a href="/cgi-bin/koha/circ/set-library.pl">Set library</a></li> > [% END %][% END %] >- [% IF Desks.ListForLibrary.count %] >- <li><a href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a></li> >- [% END %] > [% IF ( fast_cataloging ) %][% IF ( CAN_user_editcatalogue_fast_cataloging ) %] > <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li> > [% END %][% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >index 1f7f03d3df..d4fb9bf453 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >@@ -139,11 +139,6 @@ > <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library</a> > </li> > [% END %] >- [% IF Desks.ListForLibrary.count %] >- <li> >- <a class="toplinks" href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a> >- </li> >- [% END %] > [% IF EnableSearchHistory %] > <li> > <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a> >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 b7616886d4..e1f0ee28b1 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,17 @@ > [% END %] > [% END %] > >+[% BLOCK options_for_desks %] >+ <option id="nodesk" value="">---</option> >+ [% FOREACH d IN desks %] >+ [% IF d.branchcode == branch %] >+ <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" >[% d.desk_name | html %]</option> >+ [% ELSE %] >+ <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" disabled hidden>[% d.desk_name | html %]</option> >+ [% 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 e0bce02522..27ba415943 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 %] >+ > </body> > </html> >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 6bc755838d..6770e48b4b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -25,6 +25,9 @@ > [% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %] > <!-- koha core js --> > [% Asset.js("js/staff-global.js") | $raw %] >+[% IF setdesk %] >+[% Asset.js("js/desk_selection.js") | $raw %] >+[% END %] > > [% INCLUDE 'validator-strings.inc' %] > [% IF ( IntranetUserJS ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt >index 4d73d26355..c200fac1a4 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' %] > <title>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 id="nodesk" value="">---</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/circulation-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt >index caf7f3db52..fbabec6745 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt >@@ -1,7 +1,6 @@ > [% USE raw %] > [% USE Koha %] > [% USE Branches %] >-[% USE Desks %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Circulation</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -34,11 +33,6 @@ > <a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set library</a> > </li> > [% END %] >- [% IF Desks.ListForLibrary.count %] >- <li> >- <a class="circ-button" href="/cgi-bin/koha/circ/selectdesk.pl"><i class="fa fa-location-arrow"></i> Set desk</a> >- </li> >- [% END %] > [% IF ( fast_cataloging ) %] > [% IF ( CAN_user_editcatalogue_fast_cataloging ) %] > <li> >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 127332e20c..d8ba29f14c 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</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -36,7 +40,9 @@ > Updated:<ul> > [% FOREACH update IN updated %] > [% IF ( update.updated_branch ) %] >- <li>Library: [% update.old_branch or "?" | html %] ⇒ [% update.LoginBranchcode or "?" | html %]</li> >+ <li>Library: [% update.old_branch or "?" | html %] ⇒ [% LoginBranchcode or "?" | html %]</li> >+ [% ELSIF (update.updated_desk) %] >+ <li>Desk: [% update.old_desk or "?" | html %] ⇒ [% LoginDeskname or "?" | html %]</li> > [% ELSE %] > <li>ERROR - unknown</li> > [% END %] >@@ -63,11 +69,21 @@ Updated:<ul> > <li><label for="branch">Choose library:</label> > <select name="branch" id="branch"> > [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %] >- [% PROCESS options_for_yallah yallah => Branches.all( selected => branch ) %] > </select></li> > [% END %] > </ol> > </fieldset> >+[% IF Desks.all %] >+<fieldset class="rows"> >+ <legend>Set Desk</legend> >+ <ol> >+ <li><label for="desk">Choose Desk:</label> >+ <select name="desk_id" id="desk_id"> >+ [% PROCESS options_for_desks desks => Desks.all( selected => desk_id ) %] >+ </select></li> >+ </ol> >+</fieldset> >+[% END %] > <fieldset class="action"> > <input type="submit" value="Submit" /> > <a class="cancel" id="cancel_set_library" href="[% referer or '/cgi-bin/koha/circ/circulation.pl' %]">Cancel</a> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/desk_selection.js b/koha-tmpl/intranet-tmpl/prog/js/desk_selection.js >new file mode 100644 >index 0000000000..ab42768d13 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/desk_selection.js >@@ -0,0 +1,42 @@ >+$(document).ready(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(); >+ $(this).prop("selected", true) >+ } else { >+ $(this).prop("disabled", true); >+ $(this).hide(); >+ } >+ }); >+ >+ $("#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(); >+ $(this).prop("selected", true) >+ } else { >+ $(this).prop("disabled", true); >+ $(this).hide(); >+ } >+ }); >+ }); >+}) ; >-- >2.20.1
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 24201
:
96158
|
96164
|
96165
|
96166
|
101452
|
101564
|
101684
|
101697
|
101704
|
101705
|
101848
|
101865
|
101866
|
101877
|
101878
|
101879
|
101880
|
101881
|
101882
|
101883
|
103839
|
103840
|
105795
|
105869
|
105873
|
105874
|
105875
|
106576
|
107089
|
107090
|
107091
|
107092
|
107093
|
107094
|
107095
|
107096
|
107097
|
107667
|
107668
|
107669
|
107670
|
107671
|
107672
|
107673
|
107674
|
107675
|
107676
|
107677
|
107678
|
107679
|
107680
|
107728
|
107729
|
107730
|
107731
|
107732
|
107750
|
107751
|
107752
|
107815
|
107816
|
107817
|
107818
|
107951
|
107952
|
107967
|
107968
|
107980
|
107981