From f87435c933616c648c50ab609d1fea2ac51785a7 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Sat, 29 Apr 2017 19:36:18 +0000 Subject: [PATCH] Bug 18542 - Move and style "new field" link in item search form MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch modifies the item search page JavaScript so that the "New field" link has a "+" icon and is always placed at the end of the last row in that section of the form. To test, apply the patch and open the item search form in the staff client. In the third section there should be a "+ New field" link at the end of the first row of fields. Clicking the "New field" link should clone that row and move the link to the end of the cloned row. Behaves as expected. Signed-off-by: Marc Véron Signed-off-by: Jonathan Druart Amended patch: Fix indentation --- .../prog/en/modules/catalogue/itemsearch.tt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt index f7d5a3c029..f4b2e2397d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt @@ -134,7 +134,7 @@ } } - function addNewField() { + function addNewField( link ) { var form_field = $('div.form-field-select-text').last(); var copy = form_field.clone(true); copy.find('input,select').not('[type="hidden"]').each(function() { @@ -142,6 +142,7 @@ }); copy.find('.form-field-conjunction').prop('disabled', false); form_field.after(copy); + link.remove(); copy.find('select.form-field-column').change(); } @@ -299,12 +300,12 @@ // Add the "New field" link. var form_field = $('div.form-field-select-text').last() var NEW_FIELD = _("New field"); - var button_field_new = $('' + NEW_FIELD + ''); - button_field_new.click(function() { - addNewField(); - return false; + var button_field_new = $(' ' + NEW_FIELD + ''); + button_field_new.click(function(e) { + e.preventDefault(); + addNewField( $(this) ); }); - form_field.after(button_field_new); + form_field.append(button_field_new); // If a field is linked to an authorised values list, display the list. $('div.form-field-select-text select').change(function() { -- 2.39.5