Bugzilla – Attachment 160733 Details for
Bug 35329
Move patron searches to a modal
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35329: move patron search to modal - Add guarantor
Bug-35329-move-patron-search-to-modal---Add-guaran.patch (text/plain), 14.75 KB, created by
Jonathan Druart
on 2024-01-10 08:45:18 UTC
(
hide
)
Description:
Bug 35329: move patron search to modal - Add guarantor
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-01-10 08:45:18 UTC
Size:
14.75 KB
patch
obsolete
>From f79071192e0435f2ada32dd69a70df02f67ecc98 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 4 Jan 2024 16:13:49 +0100 >Subject: [PATCH] Bug 35329: move patron search to modal - Add guarantor > >This is the first of many patches to come. > >We will rewrite the patron search popup to convert it to a Bootstrap's modal. > >I faced different problems on different pages, it is preferable to test >each page on top of the whole patchset, to make sure a futur change will >not break previous pages (and this is why they are all on the same bug >report). > >For each page we will test that: >* the different filters work >* the "Clear" filters button work >* the "Add" or "Select" patron button works >* the nested modal to display patron's details (when clicking on their > name or cardnumber) works > >On this patch we are testing the guarantor search: >Create a edit a patron and click "Add guarantor" to open the modal. >--- > .../prog/css/src/staff-global.scss | 32 +++++ > .../prog/en/includes/patron-search.inc | 117 +++++++++++------- > .../prog/en/modules/members/memberentrygen.tt | 9 +- > koha-tmpl/intranet-tmpl/prog/js/members.js | 5 - > 4 files changed, 113 insertions(+), 50 deletions(-) > >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 99b2ad0d896..5e7819be4df 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -2341,6 +2341,38 @@ td.bundle { > &.modal-wide { > width: 80%; > } >+ >+} >+ >+.modal-full { >+ top: -5px; >+ >+ .modal-dialog { >+ width: 95%; >+ } >+} >+ >+.basicModal { >+ background: #FFF; >+ left: 50%; >+ margin-left: -300px; >+ max-height: 100%; >+ max-width: 600px; >+ min-height: 350px; >+ min-width: 575px; >+ opacity: 0; >+ padding: 1em; >+ pointer-events: none; >+ position: fixed; >+ top: 25%; >+ transition: all .1s ease-out; >+ z-index: 1100; >+} >+ >+.basicModal.show { >+ box-shadow: 0 5px 15px rgba( 0, 0, 0, .5 ); >+ opacity: 1; >+ pointer-events: auto; > } > > #cartDetails { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index cb22731a99f..306ab20fad3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -2,6 +2,7 @@ > [% USE I18N %] > [% USE Branches %] > [% USE ExtendedAttributeTypes %] >+[% USE Categories %] > [% USE raw %] > [% USE Asset %] > [% USE To %] >@@ -55,7 +56,7 @@ > <label for="categorycode_filter">Category:</label> > <select id="categorycode_filter"> > <option value="">Any</option> >- [% FOREACH category IN categories %] >+ [% FOREACH category IN Categories.limited.unblessed %] > <option value="[% category.categorycode | html %]">[% category.description | html %]</option> > [% END %] > </select> >@@ -109,6 +110,10 @@ > [%# columns: See patron_search_js %] > [% BLOCK patron_search_table %] > >+ [% UNLESS table_id %] >+ [% SET table_id = "memberresultst" %] >+ [% END %] >+ > [% IF filter == 'suggestions_managers' %] > <div class="hint">Only staff with superlibrarian or suggestions_manage permissions are returned in the search results</div> > [% ELSIF filter == 'orders_managers' %] >@@ -130,7 +135,6 @@ > [% END %] > </div> > >- > <h3 style="display: none;">Patrons found for: <span id="searchpattern"></span></h3> > > <div id="[% table_id | html %]_search_results" style="display:none;"> >@@ -175,18 +179,11 @@ > <div class="modal" id="patronPreview" tabindex="-1" role="dialog" aria-labelledby="patronPreviewLabel"> > <div class="modal-dialog" role="document"> > <div class="modal-content"> >- <div class="modal-header"> >- <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> >- <h4 class="modal-title" id="patronPreviewLabel"></h4> >- </div> > <div class="modal-body"> > <div id="loading"> > <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading > </div> > </div> >- <div class="modal-footer"> >- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> >- </div> > </div> > </div> > </div> >@@ -213,6 +210,8 @@ > [% END %] > > <script> >+ [% SET libraries = Branches.all %] >+ [% SET categories = Categories.limited.unblessed %] > let categories = [% To.json(categories) | $raw %].map(e => { > e['_id'] = e.categorycode.toLowerCase(); > e['_str'] = e.description; >@@ -650,22 +649,26 @@ > e.preventDefault(); > var borrowernumber = $(this).data("borrowernumber"); > var borrower_data = JSON.parse($("#borrower_data"+borrowernumber).val()); >- add_user( borrowernumber, borrower_data.firstname + " " + borrower_data.surname ); >+ modal_add_user( borrowernumber, borrower_data.firstname + " " + borrower_data.surname ); > }); >- > $("body").on("click",".select_user",function(e){ > e.preventDefault(); > var borrowernumber = $(this).data("borrowernumber"); > var borrower_data = JSON.parse($("#borrower_data"+borrowernumber).val()); >- select_user( borrowernumber, borrower_data ); >+ modal_select_user( borrowernumber, borrower_data ); >+ $(this).closest(".modal").modal('hide'); > }); > > $("body").on("click",".patron_preview", function( e ){ > e.preventDefault(); > var borrowernumber = $(this).data("borrowernumber"); > var page = "/cgi-bin/koha/members/moremember.pl?print=brief&borrowernumber=" + borrowernumber; >- $("#patronPreview .modal-body").load( page + " div.container-fluid" ); >- $('#patronPreview').modal({show:true}); >+ $("#patron_preview_modal").load( page + " div.container-fluid", function(){ >+ $("#patron_preview_modal").find(".close").on("click", function(){ >+ $('#patron_preview_modal').html(_("Loading...")).removeClass("show"); >+ }); >+ }); >+ $("#patron_preview_modal").addClass("show"); > }); > > $("#patronPreview").on('hidden.bs.modal', function (e) { >@@ -827,40 +830,68 @@ > } > > // modify parent window owner element >- function add_user(borrowernumber, borrowername) { >- var p = window.opener; >- // In one place (serials/routing.tt), the page is reload on every add >- // We have to wait for the page to be there >- function wait_for_opener () { >- if ( ! $(opener.document).find('body').size() ) { >- setTimeout(wait_for_opener, 500); >- } else { >- [%# Note that add_user could sent data instead of borrowername too %] >- $("#info").hide(); >- $("#error").hide(); >- if ( p.add_user(borrowernumber, borrowername) < 0 ) { >- $("#error").html(_("Patron '%s' is already in the list.").format(borrowername)); >- $("#error").show(); >- } else { >- $("#info").html(_("Patron '%s' added.").format(borrowername)); >- $("#info").show(); >- } >- } >+ function modal_add_user(borrowernumber, borrowername) { >+ [%# Note that add_user could sent data instead of borrowername too %] >+ $("#info").hide(); >+ $("#error").hide(); >+ if ( add_user(borrowernumber, borrowername) < 0 ) { >+ $("#error").html(_("Patron '%s' is already in the list.").format(borrowername)); >+ $("#error").show(); >+ } else { >+ $("#info").html(_("Patron '%s' added.").format(borrowername)); >+ $("#info").show(); > } >- wait_for_opener(); > } >- function select_user(borrowernumber, data) { >- var p = window.opener; >- if ( p.document.getElementById("selected_patron_id") ) { >- p.document.getElementById("selected_patron_id").value = borrowernumber; >+ function modal_select_user(borrowernumber, data) { >+ if ( document.getElementById("selected_patron_id") ) { >+ document.getElementById("selected_patron_id").value = borrowernumber; > } else { >- [% IF callback %] >- p.[% callback | html %](borrowernumber, data); >- [% ELSE %] >- p.select_user(borrowernumber, data); >+ [% IF callback %] >+ [% callback | html %](borrowernumber, data); >+ [% ELSE %] >+ select_user(borrowernumber, data); > [% END %] > } >- window.close(); > } > </script> > [% END %] >+ >+ >+[% BLOCK patron_search_modal %] >+ [% UNLESS patron_search_modal_id %] >+ [% patron_search_modal_id = "patron_search_modal" %] >+ [% END %] >+ <div id="[% patron_search_modal_id | html %]" class="modal modal-full" tabindex="-1" role="dialog" aria-labelledby="patronSearchLabel" aria-hidden="true" data-backdrop=""> >+ <div class="modal-dialog" role="document"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> >+ <h4 class="modal-title" id="patronSearchLabel">[% modal_title | html %]</h4> >+ </div> >+ <div class="modal-body"> >+ [% PROCESS patron_search_filters filters => ['branch','category','sort1','sort2'] %] >+ >+ <div id="searchresults"> >+ [% IF columns.grep('checkbox').size %] >+ <div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;"> >+ <div> >+ <a href="#" class="btn btn-link" id="select_all"><i class="fa fa-check"></i> Select all</a> >+ | >+ <a href="#" class="btn btn-link" id="clear_all"><i class="fa fa-remove"></i> Clear all</a> >+ [% IF selection_type == 'add' %] >+ <button id="add-selected" class="btn btn-sm btn-default" type="submit">Add selected patrons</button> >+ [% END %] >+ </div> >+ </div> >+ [% END %] >+ [% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %] >+ </div> >+ </div> >+ <div class="modal-footer"> >+ <a href="#" class="btn btn-default cancel" data-dismiss="modal" aria-hidden="true">Close</a> >+ </div> >+ </div> >+ </div> >+ </div> >+ <div id="patron_preview_modal" class="basicModal"></div> >+[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 645040707b4..4b4370641b2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -10,6 +10,7 @@ > [% PROCESS 'restriction-types.inc' %] > [% PROCESS 'i18n.inc' %] > [% SET footerjs = 1 %] >+[% PROCESS 'patron-search.inc' %] > [% INCLUDE 'doc-head-open.inc' %] > <title>[% FILTER collapse %] > [% UNLESS blocking_error %] >@@ -587,7 +588,7 @@ legend:hover { > <input name="guarantor_firstname" id="guarantor_firstname" type="hidden" /> > > <li> >- <a href="#" id="guarantor_search" class="btn btn-default"><i class="fa fa-plus"></i> Add guarantor</a> >+ <a href="#patron_search_modal" class="btn btn-default" data-toggle="modal"><i class="fa fa-plus"></i> Add guarantor</a> > </li> > > [% IF Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %] >@@ -1674,7 +1675,6 @@ legend:hover { > </div> <!-- /.col-sm-2.col-sm-pull-10 --> > [% END %] > </div> <!-- /.row --> >- > [% MACRO jsinclude BLOCK %] > [% Asset.js("lib/hc-sticky.js") | $raw %] > [% INCLUDE 'calendar.inc' %] >@@ -1972,6 +1972,11 @@ legend:hover { > [% Asset.js("js/members.js") | $raw %] > [% Asset.js("js/messaging-preference-form.js") | $raw %] > [% PROCESS 'password_check.inc' new_password => 'password', category_selector => '#categorycode_entry', minPasswordLength => patron.category.effective_min_password_length, RequireStrongPassword => patron.category.effective_require_strong_password %] >+ >+ [% INCLUDE 'select2.inc' %] >+ [% SET columns = ['cardnumber','name','category','branch','dateofbirth','address-library','action'] %] >+ [% PROCESS patron_search_modal columns => columns, modal_title => t("Add guarantor") %] >+ [% PROCESS patron_search_js columns => columns, actions => ["select"], preview_on_name_click => 1 %] > [% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js >index dad7ead3a35..f2e2e22681a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/members.js >@@ -199,11 +199,6 @@ $(document).ready(function(){ > > $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); > >- $('body').on('click', '#guarantor_search', function(e) { >- e.preventDefault(); >- var newin = window.open('/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,dateofbirth,address-library,action','popup','width=1024,height=768,resizable=no,toolbar=false,scrollbars=yes,top'); >- }); >- > $('#guarantor_relationships').on('click', '.guarantor_cancel', function(e) { > e.preventDefault(); > $(this).parents('fieldset').first().remove(); >-- >2.34.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 35329
:
160698
|
160699
|
160700
|
160701
|
160702
|
160703
|
160704
|
160705
|
160706
|
160728
|
160729
|
160733
|
160734
|
160735
|
160736
|
160737
|
160738
|
160739
|
160740
|
160741
|
160742
|
160743
|
160759
|
160760
|
160761
|
160762
|
160763
|
160768
|
160769
|
160770
|
160771
|
160773
|
160774
|
160940
|
160941
|
160943
|
160944
|
160945
|
160946
|
160947
|
160948
|
160949
|
160950
|
160951
|
160952
|
160953
|
160954
|
160955
|
160956
|
160957
|
160958
|
160959
|
161165
|
161166
|
161183
|
161184
|
161185
|
161186
|
161187
|
161188
|
161189
|
161190
|
161191
|
161192
|
161193
|
161194
|
161195
|
161196
|
161197
|
161198
|
161199
|
161259
|
161260
|
161274
|
161275
|
161276
|
161277
|
161278
|
161279
|
161280
|
161281
|
161282
|
161283
|
161284
|
161285
|
161286
|
161287
|
161288
|
161289
|
161290
|
161291
|
161292
|
161293
|
161294
|
161295
|
161398
|
161399
|
161400
|
161401
|
161402
|
161403
|
161404
|
161405
|
161406
|
161407
|
161408
|
161409
|
161410
|
161411
|
161412
|
161413
|
161414
|
161415
|
161416
|
161417
|
162436
|
162437
|
162438
|
162439
|
162440
|
162441
|
162442
|
162443
|
162444
|
162445
|
162446
|
162447
|
162448
|
162449
|
162450
|
162451
|
162452
|
162453
|
162454
|
162455
|
162456
|
162457
|
162670
|
162671
|
162713
|
162714