From 0733ba2075badfca90477d0dbfa490f81e68f066 Mon Sep 17 00:00:00 2001 From: Adam Styles Date: Tue, 22 Feb 2022 11:32:52 +1100 Subject: [PATCH] Bug 30159: Fix Check() to validate both mandatory and important fields This patch adds a check for both mandatory and important fields when validating bibliographic records during cataloguing. To test: 1. Go to Admin -> Biblio frameworks. View the MARC structure of your default framework. 2. Search for tag 082. Edit the subfields for this tag. 3. Check the 'important' checkbox for subfield a and Save. 4. Go to add or edit a new biblio record under Cataloguing. 5. Ensure the 082$a field is empty and hit Save. 6. Notice the confirmation pop-up is an unreadable display of HTML. 7. Click Cancel on the pop-up box. 8. Apply the patch and refresh the editor page. 9. Ensure the 082$a field is empty and hit Save. 10. Notice the confirmation pop-up is more helpful this time. Click Cancel on the pop-up box. 11. Notice the 082$a field is displayed at the top of the page as an important field that is missing information. Use the 'go to field' link and confirm this works as expected. 12. Leave 082$a empty and hit Save. 13. This time click OK on the confirmation pop-up. Confirm you are able to save your record as normal. Sponsored-by: Education Services Australia SCIS Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Signed-off-by: Fridolin Somers --- .../prog/en/modules/cataloguing/addbiblio.tt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 5325d6e91f..b81b909eef 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -711,8 +711,12 @@ function PopupMARCFieldDoc(field) { if( ! StrAlert ){ var StrWarning = AreFieldsNotOk(false); if (StrWarning){ - StrWarning += "\n" + _("Are you sure you want to save?"); - var r=confirm(StrWarning); + + // Check important fields + $("#check_errors").html( AreFieldsNotOk(false) ); + $('html, body').animate({ scrollTop: 0 }, 'fast'); + + var r=confirm("Important fields(s) are not filled. Are you sure you want to save?"); if (! r){ return false; } @@ -720,7 +724,9 @@ function PopupMARCFieldDoc(field) { document.f.submit(); return true; } else { - $("#check_errors").html( StrAlert ); + + // Call AreFieldsNotOk() twice to check both mandatory and important fields + $("#check_errors").html( AreFieldsNotOk() + AreFieldsNotOk(false) ); $('html, body').animate({ scrollTop: 0 }, 'fast'); Sticky.hcSticky('refresh'); return false; -- 2.39.5