From c9b4abac0fef33e94469d47915a30db86d482b6a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 12 Feb 2021 12:57:56 +0000 Subject: [PATCH] Bug 27682: Add a floating table header for Search engine configuration This patch adds DataTables options to the tables on the search engine configuration pages. The table on the "Search fields" tab will be sortable, all tables will be searchable, and all tables will have floating headers. To test you should have the SearchEngine preference set to "Elasticsearch." - Apply the patch and go to Administration -> Search engine configuration (Elasticsearch) - Test the tables under each tab, "Search fields," "Bibliographic records," and "Authorities," the table has a search filter and the header row "sticks" to the top of the browser window as you scroll down. - The "Search fields" table should be sortable, but the other two should not--they have drag-and-drop row reordering. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../searchengine/elasticsearch/mappings.tt | 41 ++++++++++--------- .../prog/js/elasticsearch-mappings.js | 27 +++++++++++- 2 files changed, 47 insertions(+), 21 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 202bb0bc11..7d9d9c8b08 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 @@ -108,27 +108,26 @@ a.add, a.delete { [% END %]
- +
- + - - - - + + + [% FOREACH search_field IN all_search_fields %] - - - + - [% END %] @@ -231,7 +230,7 @@ a.add, a.delete { [% FOREACH index IN indexes %]
-
Name Aliases Label TypeSearchable WeightSearchable
 Staff interfaceOPAC  Staff interfaceOPAC
+ [% IF search_field.mandatory %] [% ELSE %] @@ -138,14 +137,14 @@ a.add, a.delete { [% search_field.aliases.join(', ') | html %] + [% IF search_field.mandatory %] [% ELSE %] [% END %] + [% IF search_field.mandatory %] + [% IF search_field.mapped_biblios %] + + [% ELSE %] + + [% END %] + - [% IF search_field.mapped_biblios %] - - [% ELSE %] - - [% END %] -
+
@@ -240,7 +239,7 @@ a.add, a.delete { - + @@ -271,6 +270,7 @@ a.add, a.delete { + [% ELSE %] @@ -444,10 +444,10 @@ a.add, a.delete { [% END %] -

+

-

+
@@ -461,6 +461,7 @@ a.add, a.delete { [% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] [% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %] [% Asset.js("js/elasticsearch-mappings.js") | $raw %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js index 3ebd600d7c..99d9185a4b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js +++ b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js @@ -20,8 +20,32 @@ function clone_line(line) { return new_line; } +function tableInit( oldtabid, newtabid ) { + + var oldTableId = $("#" + oldtabid + "_table"); + var newTableId = $("#" + newtabid + "_table"); + + oldTableId.DataTable().destroy(); + newTableId.DataTable( + $.extend(true, {}, dataTablesDefaults, { + "columnDefs": [ + { "orderable": false, "searchable": false, 'targets': ['NoSort'] }, + ], + "paging": false, + "autoWidth": false + })); +} + $(document).ready(function () { - $("#tabs").tabs(); + + tableInit( "", "search_fields"); + + $("#tabs").tabs({ + activate: function( event, ui ){ + tableInit( ui.oldPanel.attr('id'), ui.newPanel.attr('id') ); + }, + }); + $('.delete').click(function () { if ($(this).hasClass('mandatory') && $(".mandatory[data-field_name=" + $(this).attr('data-field_name') + "]").length < 2) { alert( __("This field is mandatory and must have at least one mapping") ); @@ -34,6 +58,7 @@ $(document).ready(function () { $("table.mappings").tableDnD({ onDragClass: "dragClass", }); + $('.add').click(function () { var table = $(this).closest('table'); var index_name = $(table).attr('data-index_name'); -- 2.39.5
Search fieldSuggestible Searchable Mapping