From 0b789bbc9638c34d0b01480b756eb65478a90617 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 Signed-off-by: Sally Signed-off-by: Emmi Takkinen Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer --- .../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 feecd017e1..ae000d9912 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1968,6 +1968,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 131c1b514d..db6a082253 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.39.5