From 5751fcf044677794141b70a46b9dd85178200f8a Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Wed, 22 Mar 2023 15:25:43 +0000 Subject: [PATCH] Bug 26597: (follow-up) Add disabling / enabled the save button while waiting from api to respond I've updated the test plan since the REST API route takes a little time to respond To test: 1) Apply patch 2) Search PrefillGuaranteeField preference and make sure some fields are selected 3) Select a user that can have a guarantor 4) In the edit form, click on "Search to add" in "Patron guarantor" fieldset 5) Choose a patron who has at least one of the fields in 1) set 6) Click Select 7) Wait until save button is enabled 8) Confirm guarantee's information is filled from the guarantor's record 9) Check that any preexisting information is not overwritten --- .../prog/en/modules/members/memberentrygen.tt | 2 ++ koha-tmpl/intranet-tmpl/prog/js/members.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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 292ef4fae2..3fe01a4c01 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1929,6 +1929,8 @@ legend:hover { }); [% END %] $("#guarantor_template").hide(); + var guarantor_attributes; + var to_api_mapping; [% IF guarantor_attributes %] guarantor_attributes = [% To.json(guarantor_attributes) %]; [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index fdd9c728c2..29e8d6a02e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -122,7 +122,8 @@ function select_user(borrowernumber, borrower, relationship) { fieldset.find('.new_guarantor_relationship').val(relationship); } - if(typeof guarantor_attributes !== 'undefined' && to_api_mapping) { + if(guarantor_attributes && to_api_mapping) { + $('#saverecord').prop('disabled', true); $.ajax({ url: '/api/v1/patrons/'+borrowernumber, method: "GET", @@ -135,6 +136,10 @@ function select_user(borrowernumber, borrower, relationship) { document.forms.entryform[attribute].value = data[key_data]; } } + $('#saverecord').prop('disabled', false); + }, + error:function(){ + $('#saverecord').prop('disabled', false); } }); } -- 2.34.1