From f5dda21c2c5642d8f7c7280950a73d3788189f11 Mon Sep 17 00:00:00 2001 From: Axel Amghar Date: Fri, 17 May 2019 14:24:52 +0200 Subject: [PATCH] Bug 20388: QA fixe : add searchfield only if it doesn't exist To test: Without the fix: - in search field configuration -> search field - add the search field "uri" at the bottom of the tab - you should have two fields "uri" like that : https://snag.gy/BpxcIq.jpg Then apply the fix - try to add the search field uri - this time an alert should appear with the message : " SearchField uri already exist " Signed-off-by: Michal Denar --- .../admin/searchengine/elasticsearch/mappings.tt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt index f1eff65951..0198b9afb8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt @@ -76,11 +76,19 @@ var table = $(this).closest('table'); var line = $(this).closest("tr"); var name = $(line).find('input[data-id="search_field_name"]').val(); - var label = $(line).find('input[data-id="search_field_name"]').val(); - if ( name.length > 0 && label.length > 0 ) { - var new_line = clone_line( line ); - new_line.appendTo(table.find('tbody')); - clean_line(line); + let already_exist = 0; + [% FOREACH search_field IN all_search_fields %] + if ("[% search_field.name | html %]" == name){ already_exist = 1; } + [% END %] + if (already_exist) { + alert("SearchField "+ name + " already exist"); + } else { + var label = $(line).find('input[data-id="search_field_name"]').val(); + if ( name.length > 0 && label.length > 0 ) { + var new_line = clone_line( line ); + new_line.appendTo(table.find('tbody')); + clean_line(line); + } } }); }); -- 2.11.0