Bugzilla – Attachment 163899 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: UI changes to add/remove a facet
Bug-35138-UI-changes-to-addremove-a-facet.patch (text/plain), 5.03 KB, created by
Clemens Tubach
on 2024-03-26 10:51:10 UTC
(
hide
)
Description:
Bug 35138: UI changes to add/remove a facet
Filename:
MIME Type:
Creator:
Clemens Tubach
Created:
2024-03-26 10:51:10 UTC
Size:
5.03 KB
patch
obsolete
>From e96040e9109cf859618be5d196a14256d8a8c818 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 21 Mar 2024 12:42:24 +0100 >Subject: [PATCH] Bug 35138: UI changes to add/remove a facet > >Sponsored-by: The Research University in the Helmholtz Association (KIT) >Signed-off-by: Clemens Tubach <clemens.tubach@kit.edu> >--- > .../searchengine/elasticsearch/mappings.tt | 18 +++++++++++ > .../prog/js/elasticsearch-mappings.js | 30 +++++++++++++++++++ > 2 files changed, 48 insertions(+) > >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 a3513d0d2a..00bc1ae4f4 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 >@@ -493,6 +493,7 @@ a.add, a.delete { > <th>Order</th> > <th class="NoSort">Search field</th> > <th class="NoSort">Label</th> >+ <th class="NoSort"> </th> > </tr> > </thead> > <tbody> >@@ -518,9 +519,26 @@ a.add, a.delete { > [% END %] > <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> >+ </td> > </tr> > [% END %] > </tbody> >+ <tfoot> >+ <tr> >+ <td></td> >+ <td> >+ <select data-id="facet-search-field"> >+ [% FOREACH search_field IN all_search_fields %] >+ <option value="[% search_field.name | html %]" data-label="[% search_field.label | html %]">[% search_field.name | html %]</option> >+ [% END %] >+ </select> >+ </td> >+ <td></td> >+ <td><a class="btn btn-default btn-xs add-facet"><i class="fa fa-plus"></i> Add</a></td> >+ </tr> >+ </tfoot> > </table> > </div> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >index d0f27a46d2..d4806d16e0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js >@@ -156,4 +156,34 @@ $(document).ready(function () { > clean_line(line); > } > }); >+ >+ $('.add-facet').click(function() { >+ var table = $(this).closest('table'); >+ let table_id = table.attr('id'); >+ let dt = $('#' + table_id).DataTable(); >+ var line = $(this).closest('tr'); >+ let selected_option = $(line).find('select[data-id="facet-search-field"] option:selected'); >+ var search_field_name = selected_option.val(); >+ let dt_data = dt.data(); >+ let already_exists = dt_data.filter((row, idx) => row[1] === search_field_name); >+ if ( already_exists.length ) { >+ alert(__("Facet '%s' already exist".format(search_field_name))); >+ return; >+ } >+ 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"))]; >+ 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