Bugzilla – Attachment 163900 Details for
Bug 35138
Enable configuration of facets with Elasticsearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35138: A bit of cleaning - UI
Bug-35138-A-bit-of-cleaning---UI.patch (text/plain), 10.70 KB, created by
Clemens Tubach
on 2024-03-26 10:51:13 UTC
(
hide
)
Description:
Bug 35138: A bit of cleaning - UI
Filename:
MIME Type:
Creator:
Clemens Tubach
Created:
2024-03-26 10:51:13 UTC
Size:
10.70 KB
patch
obsolete
>From 50a4a0ce67475486331fc3abbe2035b76fdef397 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 21 Mar 2024 14:47:27 +0100 >Subject: [PATCH] Bug 35138: A bit of cleaning - UI > >This can be moved to its own bug report, it's only a bit of cleaning >trying to keep the code cleaner after than before. >No behaviour changes expected. > >Sponsored-by: The Research University in the Helmholtz Association (KIT) >Signed-off-by: Clemens Tubach <clemens.tubach@kit.edu> >--- > .../searchengine/elasticsearch/mappings.tt | 16 ++--- > .../prog/js/elasticsearch-mappings.js | 58 +++++++++---------- > 2 files changed, 36 insertions(+), 38 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 00bc1ae4f4..ce884f8915 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 >@@ -258,16 +258,16 @@ a.add, a.delete { > </td> > <td> > [% IF search_field.is_mapped %] >- <a class="btn btn-default btn-xs disabled delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a> >+ <a class="btn btn-default btn-xs disabled delete-search-field" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a> > [% ELSE %] >- <a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a> >+ <a class="btn btn-default btn-xs delete-search-field" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a> > [% END %] > </td> > </tr> > [% END %] > </tbody> > <tfoot> >- <tr> >+ <tr data-type="search-field"> > <td> > <input type="text" data-id="search_field_name"/> > </td> >@@ -429,16 +429,16 @@ a.add, a.delete { > <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" /> > </td> > [% IF mapping.search_field_mandatory %] >- <td><a class="btn btn-default btn-xs delete mandatory" data-field_name="[% mapping.search_field_name | html %]" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td> >+ <td><a class="btn btn-default btn-xs delete-mapping mandatory" data-field_name="[% mapping.search_field_name | html %]" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td> > [% ELSE %] >- <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td> >+ <td><a class="btn btn-default btn-xs delete-mapping" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td> > [% END %] > </tr> > [% END %] > [% END %] > </tbody> > <tfoot> >- <tr> >+ <tr data-type="mapping"> > <td> > <input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" /> > <select data-id="mapping_search_field_name"> >@@ -520,13 +520,13 @@ a.add, a.delete { > <input type="hidden" name="facet_name" value="[% f.name | html %]" /> > </td> > <td> >- <a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a> >+ <a class="btn btn-default btn-xs delete-facet" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a> > </td> > </tr> > [% END %] > </tbody> > <tfoot> >- <tr> >+ <tr data-type="facet"> > <td></td> > <td> > <select data-id="facet-search-field"> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >index d4806d16e0..23cabf0bb6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >@@ -5,9 +5,20 @@ function clean_line(line) { > $(line).find('select').find('option:first').prop("selected", true); > } > >+function build_delete_link(del_class){ >+ return '<a class="btn btn-default btn-xs %s" style="cursor: pointer;"><i class="fa fa-trash"></i> %s</a>'.format(del_class, __("Delete")); >+} >+ >+function remove_line(line){ >+ var table = $(line).closest('table'); >+ let dt = $(table).DataTable(); >+ dt.row(line).remove().draw(); >+} >+ > function clone_line(line) { > var new_line = $(line).clone(); >- $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html('<i class="fa fa-trash"></i> %s'.format(__("Delete") )); >+ let type = $(line).data('type'); >+ $(new_line).find('td:last-child').html(build_delete_link('delete-%s'.format(type))); > $(new_line).find('[data-id]').each(function () { > $(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id'); > }); >@@ -47,15 +58,19 @@ $(document).ready(function () { > tableInit( oldtabid, newtabid ); > }); > >- $(document).on('click', '.delete', function() { >+ $(document).on('click', '.delete-facet', function() { >+ var line = $(this).closest("tr"); >+ remove_line(line); >+ }); >+ $(document).on('click', '.delete-mapping', function() { >+ var line = $(this).closest("tr"); >+ remove_line(line); >+ }); >+ $(document).on('click', '.delete-search-field', 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 { >- var table = $(this).closest('table'); >- let dt = $(table).DataTable(); >- dt.row( $(this).closest('tr') ).remove().draw(); >- $(this).parents('tr').remove(); > var line = $(this).closest("tr"); > > var name; >@@ -74,28 +89,24 @@ $(document).ready(function () { > var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); > $(search_field_line).find('a.btn-default').removeClass('disabled'); > } >+ >+ remove_line(line); > } > }); > > $('.add').click(function () { > var table = $(this).closest('table'); > let table_id = table.attr('id'); >- var index_name = $(table).attr('data-index_name'); >+ let dt = $('#' + table_id).DataTable(); > var line = $(this).closest("tr"); > var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val(); >- if (marc_field.length > 0) { >+ let dt_data = dt.data(); >+ if ( marc_field.length ) { > var new_line = clone_line(line); >- var search_field_name = $(line).find('select[data-id="mapping_search_field_name"] option:selected').text(); >- new_line.appendTo($('table[data-index_name="' + index_name + '"]>tbody')); >+ var index_name = $(table).attr('data-index_name'); > 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); > } > }); >@@ -144,15 +155,8 @@ $(document).ready(function () { > if (search_field_name.length > 0) { > var new_line = clone_line(line); > new_line.find('td:first').attr({'data-order': search_field_name}); >- new_line.appendTo($('table#' + table_id + '>tbody')); > 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); > } > }); >@@ -173,15 +177,9 @@ $(document).ready(function () { > if (search_field_name.length > 0) { > const next_id = Math.max.apply(null, dt_data.map(row => row[0])) + 1; > const label = selected_option.data('label'); >- new_line = [next_id, search_field_name, '<span>%s</span><input type="hidden" name="facet_name" value="%s" />'.format(label.escapeHtml(), search_field_name.escapeHtml()), '<a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> %s</a>'.format(__("Delete"))]; >+ new_line = [next_id, search_field_name, '<span>%s</span><input type="hidden" name="facet_name" value="%s" />'.format(label.escapeHtml(), search_field_name.escapeHtml()), build_delete_link()] > 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); > } > }); >-- >2.30.2
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 35138
:
163133
|
163680
|
163681
|
163682
|
163683
|
163684
|
163896
|
163897
|
163898
|
163899
|
163900
|
164811
|
164812
|
164813
|
164814
|
164815
|
164816
|
165811
|
165812
|
165813
|
165814
|
165815
|
165816
|
165817
|
165818
|
166402