Bugzilla – Attachment 125337 Details for
Bug 29030
Problems introduced by bug 25728
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29030: Make authorized value and description fields required
Bug-29030-Make-authorized-value-and-description-fi.patch (text/plain), 9.06 KB, created by
Katrin Fischer
on 2021-09-26 14:17:33 UTC
(
hide
)
Description:
Bug 29030: Make authorized value and description fields required
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2021-09-26 14:17:33 UTC
Size:
9.06 KB
patch
obsolete
>From 966ba1268300e64f2a1644ae8c28f7e39e92997a Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 15 Sep 2021 17:40:19 +0000 >Subject: [PATCH] Bug 29030: Make authorized value and description fields > required > >This patch modifies the markup of the "Create a new authorized value" >modal so that a minimum set of fields is required: Authorized value and >description. > >The patch also modifies the JavaScript which handles the submission so >that the jQuery Validation plugin can handle the field checks. > >The spelling "authorised" is changed to "authorized" following coding >guidelines. > >To test, apply the patch and rebuild the staff interface CSS >(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client). > >- Locate a record in the catalog which has items and open an item for > editing. >- In the add item form, test the process of adding an authorized > value on the fly with the following fields: Withdrawn, Lost, > Damaged, Use restrictions, Not for loan, Collection code, Shelving > location, and Shelving control number. > - In each case you should be able to type a new value in the > dropdown's search box and be shown the option "Select to create." > - Selecting should trigger a modal window, "Create a new authorized > value." > - Test that both "Authorized value" and "Description" fields are > required, and the form can't be submitted without them. > - Test that an error message shows up when you submit an authorized > value which already exists, e.g. authval "1" for "DAMAGED." > - After triggering this error, click the "Cancel" button and try > creating another new authorized value. When the modal reopens the > form should be reset: No previously-entered data, no error messages. > - Submitting a valid form with a new authorized value should work > correctly. The modal window should close automatically. > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../intranet-tmpl/prog/css/src/staff-global.scss | 1 + > .../en/includes/modals/cataloguing_create_av.inc | 20 ++++---- > koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 60 +++++++++++++--------- > 3 files changed, 47 insertions(+), 34 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 9d8f5e8069..809e0a506b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -2371,6 +2371,7 @@ td { > .dialog { > border-radius: 0; > border-width: 1px 0 0 0; >+ clear: both; > margin: 15px -15px -15px -15px; > padding: 15px; > text-align: left; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cataloguing_create_av.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cataloguing_create_av.inc >index 995a5ae337..0618474740 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cataloguing_create_av.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cataloguing_create_av.inc >@@ -3,11 +3,10 @@ > <div class="modal-content"> > <div class="modal-header"> > <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >- <h3 id="avCreateLabel">Create a new authorised value</h3> >+ <h3 id="avCreateLabel">Create a new authorized value</h3> > </div> > <form id="add_new_av" method="post"> > <div class="modal-body"> >- <div class="error"></div> > <fieldset class="rows"> > <ol> > <li> >@@ -16,24 +15,27 @@ > <span id="new_av_category"></span> > </li> > <li> >- <span class="label" for="value">Authorised value:</span> >- <input type="text" id="value" name="value" /> >+ <label for="value" class="required">Authorized value:</label> >+ <input class="required" required="required" type="text" id="value" name="value" /> >+ <span class="required">Required</span> > </li> > <li> >- <span class="label" for="description">Description:</span> >- <input type="text" id="description" name="description" /> >+ <label for="description" class="required">Description:</label> >+ <input class="required" required="required" type="text" id="description" name="description" /> >+ <span class="required">Required</span> > </li> > <li> >- <span class="label" for="opac_description">Description (OPAC):</span> >+ <label for="opac_description">Description (OPAC):</label> > <input type="text" id="opac_description" name="opac_description" /> > </li> > </ol> > </fieldset> >+ <div class="avCreate_error dialog alert" style="display:none;"></div> > </div> > <div class="modal-footer"> >- <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> > <input type="hidden" name="select2" value="" /> >- <input type="submit" class="btn btn-primary" value="Save"> >+ <button type="submit" class="btn btn-default">Save</button> >+ <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button> > </div> > </form> > </div> <!-- /.modal-content --> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >index a2d7b4a2aa..e037f6ff82 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >@@ -1,3 +1,4 @@ >+/* global __ */ > /* exported openAuth ExpandField CloneField CloneSubfield UnCloneField CloneItemSubfield CheckMandatorySubfields */ > > /* >@@ -588,30 +589,39 @@ $(document).ready(function() { > Select2Utils.initSelect2($('.subfield_line select[data-category!=""]')); > } > >- $("#add_new_av").on("submit", function(){ >- var category = $(this).find('input[name="category"]').val(); >- var value = $(this).find('input[name="value"]').val(); >- var description = $(this).find('input[name="description"]').val(); >- var opac_description = $(this).find('input[name="opac_description"]').val(); >- >- var data = "category="+encodeURIComponent(category) >- +"&value="+encodeURIComponent(value) >- +"&description="+encodeURIComponent(description) >- +"&opac_description="+encodeURIComponent(opac_description); >- >- $.ajax({ >- type: "POST", >- url: "/cgi-bin/koha/svc/authorised_values", >- data: data, >- success: function(response) { >- $('#avCreate').modal('hide'); >- >- $(current_select2).append('<option selected value="'+response.value+'">'+response.description+'</option>'); >- }, >- error: function(err) { >- $("#avCreate .error").html(_("Something went wrong, maybe the value already exists?")) >- } >- }); >- return false; >+ $("#avCreate").on("hidden.bs.modal", function(){ >+ add_new_av.resetForm(); /* resets form state for jQuery Validate plugin */ >+ $("#add_new_av")[0].reset(); >+ $(".avCreate_error").hide(); >+ }); >+ >+ var add_new_av = $("#add_new_av").validate({ >+ submitHandler: function(form) { >+ var category = form.category.value; >+ var value = form.value.value; >+ var description = form.description.value; >+ var opac_description = form.opac_description.value; >+ >+ var data = "category="+encodeURIComponent(category) >+ +"&value="+encodeURIComponent(value) >+ +"&description="+encodeURIComponent(description) >+ +"&opac_description="+encodeURIComponent(opac_description); >+ $.ajax({ >+ type: "POST", >+ url: "/cgi-bin/koha/svc/authorised_values", >+ data: data, >+ success: function(response) { >+ $('#avCreate').modal('hide'); >+ >+ $(current_select2).append('<option selected value="'+response.value+'">'+response.description+'</option>'); >+ $("#avCreate").modal("hide"); >+ }, >+ error: function() { >+ $(".avCreate_error").html(__("Something went wrong. Maybe the value already exists?")).show(); >+ } >+ }); >+ return false; >+ } > }); >+ > }); >-- >2.11.0
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 29030
:
124905
|
124920
| 125337