Bugzilla – Attachment 133595 Details for
Bug 30584
Cannot add field mappings to Elasticsearch configuration
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30584: Fix ES mapping creation
Bug-30584-Fix-ES-mapping-creation.patch (text/plain), 3.40 KB, created by
Jonathan Druart
on 2022-04-21 17:30:27 UTC
(
hide
)
Description:
Bug 30584: Fix ES mapping creation
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-04-21 17:30:27 UTC
Size:
3.40 KB
patch
obsolete
>From 50204b58e9c45d44edd5877e88cfd762a7fae936 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 21 Apr 2022 19:23:14 +0200 >Subject: [PATCH] Bug 30584: Fix ES mapping creation > >We need to tell DT that we are adding/removing row, not only deal >manually with the DOM. > >This patch also fixes the following bug: if you add or remove a row from >the "biblio" tab, then go to another tab and back to "biblio", all >changes were gone (bug existed prior to bug 29893). > >Test plan: >Add, edit and remove mappings, switch from tabs and save. >Use the filters, save (29893 regression test) >--- > .../prog/js/elasticsearch-mappings.js | 34 +++++++++++++++---- > 1 file changed, 27 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >index ec59e99e462..cf1faa9519a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >@@ -52,7 +52,9 @@ $(document).ready(function () { > alert( __("This field is mandatory and must have at least one mapping") ); > return; > } else { >- $(this).parents('tr').remove(); >+ var table = $(this).closest('table'); >+ let dt = $(table).DataTable(); >+ dt.row( $(this).closest('tr') ).remove().draw(); > } > }); > >@@ -62,15 +64,22 @@ $(document).ready(function () { > > $('.add').click(function () { > var table = $(this).closest('table'); >+ let table_id = table.attr('id'); > 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(); >- }); >+ let dt = $('#' + table_id).DataTable(); >+ dt.row.add(new_line).draw(); >+ >+ $(table).on( 'click', '.delete', function () { >+ var table = $(this).closest('table'); >+ let dt = $(table).DataTable(); >+ dt.row( $(this).closest('tr') ).remove().draw(); >+ } ); >+ > clean_line(line); > > $(table).tableDnD({ >@@ -83,9 +92,20 @@ $(document).ready(function () { > }); > > $("#es_mappings").on("submit", function(e){ >- $("#search_fields_table").DataTable({ paging: false }).search('').draw(); >- $("#mapping_biblios_table").DataTable({ paging: false }).search('').draw(); >- $("#mapping_authorities_table").DataTable({ paging: false }).search('').draw(); >+ let table_ids = ['search_fields_table', 'mapping_biblios_table', 'mapping_authorities_table']; >+ $(table_ids).each(function(){ >+ let table; >+ // Remove warning "Cannot reinitialise DataTable" >+ if ( $.fn.dataTable.isDataTable( '#' + this ) ) { >+ table = $('#' + this).DataTable(); >+ } >+ else { >+ table = $('#' + this).DataTable( { >+ paging: false >+ } ); >+ } >+ table.search('').draw(); >+ }); > return true; > }); > }); >-- >2.25.1
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 30584
:
133595
|
133657
|
133800