Bugzilla – Attachment 116759 Details for
Bug 26958
Move Elasticsearch mapping template JS to the footer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26958: Move Elasticsearch mapping template JS to the footer
Bug-26958-Move-Elasticsearch-mapping-template-JS-t.patch (text/plain), 7.13 KB, created by
Nick Clemens (kidclamp)
on 2021-02-11 15:09:34 UTC
(
hide
)
Description:
Bug 26958: Move Elasticsearch mapping template JS to the footer
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-02-11 15:09:34 UTC
Size:
7.13 KB
patch
obsolete
>From 989b0d47cb3218d53f177a920cf9c74e1636e606 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Fri, 6 Nov 2020 16:18:07 +0000 >Subject: [PATCH] Bug 26958: Move Elasticsearch mapping template JS to the > footer > >This patch moves inclusion of JavaScript to the footer of the >Elasticsearch mapping template. It also moves the JS into a separate >file. > >To test you should have SearchEngine system preference set to >"Elasticsearch." > > - Apply the patch and go to Administration -> Search engine > configuration (Elasticsearch). > - Confirm that JavaScript dependent interactions work correctly: > - Tabs > - Under the bibliographic records and authorities tabs, table row > drag-and-drop > - Under the bibliographic records and authorities tabs, test the > "Add" line at the bottom of the table. > - Under the bibliographic records and authorities tabs, test the > "Delete" button. > >Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > .../admin/searchengine/elasticsearch/mappings.tt | 66 +++------------------- > .../prog/js/elasticsearch-mappings.js | 58 +++++++++++++++++++ > 2 files changed, 65 insertions(+), 59 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js > >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 9adcfe0eaa..81beb1d311 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 >@@ -1,74 +1,17 @@ > [% USE raw %] > [% USE Asset %] >+[% SET footerjs = 1 %] > [% PROCESS 'i18n.inc' %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Search engine configuration (Elasticsearch)</title> > [% INCLUDE 'doc-head-close.inc' %] >-[% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %] >-<script> >- function clean_line( line ) { >- $(line).find('input[type="text"]').val(""); >- $(line).find('select').find('option:first').attr("selected", "selected"); >- } >- >- function clone_line( line ) { >- var new_line = $(line).clone(); >- $(new_line).removeClass("nodrag nodrop"); >- $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html(_("Delete")); >- $(new_line).find('[data-id]').each( function() { >- $(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id'); >- } ); >- $(new_line).find("select").each( function() { >- var attr = $(this).attr('name'); >- var val = $(line).find('[data-id="' + attr + '"]').val(); >- $(this).find('option[value="' + val + '"]').attr("selected", "selected"); >- } ); >- return new_line; >- } >- >- $(document).ready(function() { >- $("#tabs").tabs(); >- $('.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"); >- return; >- } else { >- $(this).parents('tr').remove(); >- } >- }); >- >- $("table.mappings").tableDnD( { >- onDragClass: "dragClass", >- } ); >- $('.add').click(function() { >- var table = $(this).closest('table'); >- var index_name = $(table).attr('data-index_name'); >- var line = $(this).closest("tr"); >- var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val(); >- if ( marc_field.length > 0 ) { >- var new_line = clone_line( line ); >- new_line.appendTo($('table[data-index_name="'+index_name+'"]>tbody')); >- $('.delete').click(function() { >- $(this).parents('tr').remove(); >- }); >- clean_line(line); >- >- $(table).tableDnD( { >- onDragClass: "dragClass", >- } ); >- } >- }); >- $("#facet_biblios > table").tableDnD( { >- onDragClass: "dragClass", >- } ); >- }); >-</script> > <style> > a.add, a.delete { > cursor: pointer; > } > </style> > </head> >+ > <body id="admin_searchengine_mappings" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'prefs-admin-search.inc' %] >@@ -521,4 +464,9 @@ a.add, a.delete { > </div> <!-- /.col-sm-2.col-sm-pull-10 --> > </div> <!-- /.row --> > >+[% MACRO jsinclude BLOCK %] >+ [% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %] >+ [% Asset.js("js/elasticsearch-mappings.js") | $raw %] >+[% END %] >+ > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >new file mode 100644 >index 0000000000..3ebd600d7c >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >@@ -0,0 +1,58 @@ >+/* global __ */ >+ >+function clean_line(line) { >+ $(line).find('input[type="text"]').val(""); >+ $(line).find('select').find('option:first').attr("selected", "selected"); >+} >+ >+function clone_line(line) { >+ var new_line = $(line).clone(); >+ $(new_line).removeClass("nodrag nodrop"); >+ $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html( __("Delete") ); >+ $(new_line).find('[data-id]').each(function () { >+ $(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id'); >+ }); >+ $(new_line).find("select").each(function () { >+ var attr = $(this).attr('name'); >+ var val = $(line).find('[data-id="' + attr + '"]').val(); >+ $(this).find('option[value="' + val + '"]').attr("selected", "selected"); >+ }); >+ return new_line; >+} >+ >+$(document).ready(function () { >+ $("#tabs").tabs(); >+ $('.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") ); >+ return; >+ } else { >+ $(this).parents('tr').remove(); >+ } >+ }); >+ >+ $("table.mappings").tableDnD({ >+ onDragClass: "dragClass", >+ }); >+ $('.add').click(function () { >+ var table = $(this).closest('table'); >+ var index_name = $(table).attr('data-index_name'); >+ var line = $(this).closest("tr"); >+ var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val(); >+ if (marc_field.length > 0) { >+ var new_line = clone_line(line); >+ new_line.appendTo($('table[data-index_name="' + index_name + '"]>tbody')); >+ $('.delete').click(function () { >+ $(this).parents('tr').remove(); >+ }); >+ clean_line(line); >+ >+ $(table).tableDnD({ >+ onDragClass: "dragClass", >+ }); >+ } >+ }); >+ $("#facet_biblios > table").tableDnD({ >+ onDragClass: "dragClass", >+ }); >+}); >-- >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 26958
:
113262
|
113299
|
113301
| 116759