Bugzilla – Attachment 105795 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), 10.10 KB, created by
Nicolas Legrand
on 2020-06-12 13:22:40 UTC
(
hide
)
Description:
Bug 24201: (follow-up) add desk choice with library choice
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2020-06-12 13:22:40 UTC
Size:
10.10 KB
patch
obsolete
>From be0aed90bdffeb85935a51f864d3cf78df491574 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 >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 %] >+ <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 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 %] >+ > </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 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 @@ > <!-- koha core js --> > [% 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 @@ > </script> > [% END %] > <!-- / js_includes.inc --> >+ >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' %] > <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 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</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 0000000..a07322a >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/desk_selection.js >@@ -0,0 +1,17 @@ >+<script> >+$(document).ready(function() { >+ $("#branch").on("change", function() { >+ var selectedBranch = $("#branch"). children("option:selected"). val(); >+ $("#desk_id").children().each(function() { >+ if ($(this).hasClass(selectedBranch)) { >+ $(this).prop("disabled", false); >+ $(this).hide(true); >+ $(this).prop("selected", true) >+ } else { >+ $(this).prop("disabled", true); >+ $(this).hide(false); >+ } >+ }); >+ }); >+}) ; >+</script> >-- >2.1.4
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