Bugzilla – Attachment 90534 Details for
Bug 19598
ES configuration - Make the columns sortable/searchable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19598: ES configuration - Make the columns searchable
Bug-19598-ES-configuration---Make-the-columns-sear.patch (text/plain), 22.67 KB, created by
axel Amghar
on 2019-06-12 14:56:26 UTC
(
hide
)
Description:
Bug 19598: ES configuration - Make the columns searchable
Filename:
MIME Type:
Creator:
axel Amghar
Created:
2019-06-12 14:56:26 UTC
Size:
22.67 KB
patch
obsolete
>From 08ace3203b2aae3d87e478525ddb7350fde6fb0c Mon Sep 17 00:00:00 2001 >From: Axel Amghar <axel.amghar@biblibre.com> >Date: Wed, 29 May 2019 09:20:44 +0200 >Subject: [PATCH] Bug 19598: ES configuration - Make the columns searchable > >Test plan: >- apply the patch >- at the top of each table you have a search line >- In search fields: verify that the search is correct with all the fields(name, label, type and weight) >- Go to bilios table: verify that the search is correct with all the new fields >- make a search and verify that the button reset search is valid >- add some mappings (without save) and test the search again >- save and test the search once again >- then, make the same with authorities table >--- > .../admin/searchengine/elasticsearch/mappings.tt | 282 +++++++++++++++++++-- > 1 file changed, 264 insertions(+), 18 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 33df1fb..c2debb5 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 >@@ -13,8 +13,17 @@ > > function clone_line( line ) { > var new_line = $(line).clone(); >+ let my_index_name = $(new_line).find('td:first-child > input:first-child').val(); > $(new_line).removeClass("nodrag nodrop"); >- $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html(_("Delete")); >+ >+ //add class for the research >+ $(new_line).find('td:first-child > select').addClass("field_name_research_" + my_index_name); >+ $(new_line).find('td:nth-child(2)> select').addClass("sort_research_" + my_index_name); >+ $(new_line).find('td:nth-child(3)> select').addClass("facet_research_select_" + my_index_name); >+ $(new_line).find('td:nth-child(4)> select').addClass("suggestible_research_" + my_index_name); >+ $(new_line).find('td:nth-child(5)> input').addClass("mapping_research_" + my_index_name); >+ >+ $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html('<i class="fa fa-trash"></i> Delete'); > $(new_line).find('[data-id]').each( function() { > $(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id'); > } ); >@@ -26,6 +35,28 @@ > return new_line; > } > >+ function search_input(imput_search_val, input_class) { >+ if (imput_search_val != ""){ >+ $('input.' + input_class ).each ( function () { >+ //if the search correspond with the begining of a input value >+ if (($(this).val().toLowerCase().indexOf(imput_search_val.toLowerCase()) == -1) >+ && ($(this).val().toLowerCase().indexOf(imput_search_val.replace(',','.').toLowerCase()) == -1)){ >+ $(this).parents('tr').hide(); >+ } >+ }); >+ } >+ } >+ >+ function search_select(select_search_val, select_class){ >+ if (select_search_val != "All"){ >+ $('select.' + select_class +' option:selected').each( function () { >+ if ($(this).val() != select_search_val){ >+ $(this).parents('tr').hide(); >+ } >+ }); >+ } >+ } >+ > $(document).ready(function() { > $("#tabs").tabs(); > $('.delete').click(function() { >@@ -38,11 +69,14 @@ > $('.add').click(function() { > var table = $(this).closest('table'); > var index_name = $(table).attr('data-index_name'); >+ >+ //remove the no matches tr from if the search give no results search >+ $(".delete_tr_" + index_name).remove(); > 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')); >+ new_line.appendTo($('table[data-index_name="'+ index_name+ '"]>.' + index_name + '_table')); > $('.delete').click(function() { > $(this).parents('tr').remove(); > }); >@@ -56,9 +90,156 @@ > $("#facet_biblios > table").tableDnD( { > onDragClass: "dragClass", > } ); >+ >+ >+ //SEARCH FOR SEARCH FIELDS TABLE >+ >+ let search_field_table = $(".search_field_table"); >+ search_field_table.each( function () { >+ $(this).children().attr("style","display: table-row"); >+ }); >+ >+ let searching_fields_name = $("#searching_fields_name"); >+ let searching_fields_label = $("#searching_fields_label"); >+ let searching_fields_type = $("#searching_fields_type"); >+ let searching_fields_weight = $("#searching_fields_weight"); >+ >+ function search_fields (){ >+ >+ $(".delete_tr").remove(); >+ search_field_table.each( function () { >+ $(this).children().show(); >+ }); >+ >+ search_input(searching_fields_name.val(),"field_name_research"); >+ search_input(searching_fields_label.val(),"field_label_research"); >+ search_select(searching_fields_type.val(),"field_type_research"); >+ search_input(searching_fields_weight.val(),"field_weight_research"); >+ >+ let find = false; >+ let tr_search_field_table = $(".search_field_table > tr"); >+ tr_search_field_table.each(function(){ >+ if ($(this).css("display") == "table-row"){ >+ find = true; >+ } >+ }); >+ if (find == false){ >+ search_field_table.append('<tr class="delete_tr"><td colspan="4" id="no_matches" ><h3><b>no matches</b></h3></td></tr>'); >+ } >+ } >+ >+ searching_fields_name.on("click paste keyup", search_fields); >+ searching_fields_label.on("click paste keyup", search_fields); >+ searching_fields_type.change(search_fields); >+ searching_fields_weight.on("click paste keyup", search_fields); >+ >+ //SEARCH FOR BIBLIOS AND AUTHORITIES TABLE >+ >+ [% FOREACH index IN indexes %] >+ >+ let [% index.index_name | html %]_table = $(".[% index.index_name | html %]_table"); >+ [% index.index_name | html %]_table.each( function () { >+ $(this).children().attr("style","display: table-row"); >+ }); >+ >+ let searching_fields_[% index.index_name | html %] = $("#searching_fields_[% index.index_name | html %]"); >+ let searching_sortable_[% index.index_name | html %] = $("#searching_sortable_[% index.index_name | html %]"); >+ let searching_facetable_[% index.index_name | html %] = $("#searching_facetable_[% index.index_name | html %]"); >+ let searching_suggestible_[% index.index_name | html %] = $("#searching_suggestible_[% index.index_name | html %]"); >+ let searching_mappings_[% index.index_name | html %] = $("#searching_mappings_[% index.index_name | html %]"); >+ >+ function search_[% index.index_name | html %] (){ >+ >+ //remove the no matches tr from the previous search >+ $(".delete_tr_[% index.index_name | html %]").remove(); >+ >+ [% index.index_name | html %]_table.each( function () { >+ $(this).children().show(); >+ }); >+ >+ search_input(searching_fields_[% index.index_name | html %].val(),"field_name_research_[% index.index_name | html %]"); >+ search_select(searching_sortable_[% index.index_name | html %].val(),"sort_research_[% index.index_name | html %]"); >+ search_select(searching_suggestible_[% index.index_name | html %].val(),"suggestible_research_[% index.index_name | html %]"); >+ search_input(searching_mappings_[% index.index_name | html %].val(),"mapping_research_[% index.index_name | html %]"); >+ >+ if (searching_fields_[% index.index_name | html %].val() != ""){ >+ $('select.field_name_research_[% index.index_name | html %] option:selected').each( function () { >+ if ($(this).val().toLowerCase().indexOf(searching_fields_[% index.index_name | html %].val().toLowerCase()) == -1 ){ >+ $(this).parents('tr').hide(); >+ } >+ }); >+ } >+ >+ if (searching_facetable_[% index.index_name | html %].val() != "All"){ >+ $('select.facet_research_select_[% index.index_name | html %] option:selected').each( function () { >+ if ($(this).val() != searching_facetable_[% index.index_name | html %].val()){ >+ $(this).parents('tr').hide(); >+ } >+ }); >+ $('input.facet_research_input_[% index.index_name | html %]').each( function () { >+ if ($(this).val() != searching_facetable_[% index.index_name | html %].val()){ >+ $(this).parents('tr').hide(); >+ } >+ }); >+ } >+ >+ let find = false; >+ let tr_[% index.index_name | html %]_table = $(".[% index.index_name | html %]_table > tr"); >+ tr_[% index.index_name | html %]_table.each(function(){ >+ if ($(this).css("display") == "table-row"){ >+ find = true; >+ } >+ }); >+ if (find == false){ >+ [% index.index_name | html %]_table.append('<tr class="delete_tr_[% index.index_name | html %]"><td colspan="6" id="no_matches" ><h3><b>no matches</b></h3></td></tr>'); >+ } >+ } >+ >+ searching_fields_[% index.index_name | html %].on("paste keyup", search_[% index.index_name | html %]); >+ searching_sortable_[% index.index_name | html %].change(search_[% index.index_name | html %]); >+ searching_facetable_[% index.index_name | html %].change(search_[% index.index_name | html %]); >+ searching_suggestible_[% index.index_name | html %].change(search_[% index.index_name | html %]); >+ searching_mappings_[% index.index_name | html %].on("click paste keyup", search_[% index.index_name | html %]); >+ >+ $('.reset_search_[% index.index_name | html %]').click(function() { >+ searching_fields_[% index.index_name | html %].val(""); >+ searching_sortable_[% index.index_name | html %].val("All"); >+ searching_facetable_[% index.index_name | html %].val("All"); >+ searching_suggestible_[% index.index_name | html %].val("All"); >+ searching_mappings_[% index.index_name | html %].val(""); >+ search_[% index.index_name | html %](); >+ }); >+ [% END %] > }); > </script> > <style> >+ >+#no_matches { >+ color : red; >+ text-align : center; >+} >+ >+.btn-search >+{ >+ width : 100%; >+ margin-right:-20px; >+} >+ >+.delete, .add, .width_full, .input_search >+{ >+ width : 100%; >+} >+ >+.input_search >+{ >+ padding-bottom: 10px; >+} >+ >+#searching_fields_weight >+{ >+ margin-right:-100px; >+ width : 100%; >+} > a.add, a.delete { > cursor: pointer; > } >@@ -163,15 +344,43 @@ a.add, a.delete { > <th>Weight</th> > </tr> > </thead> >+ > <tbody> >+ <tr> >+ <td> >+ <input placeholder="Search names" type="text" id="searching_fields_name" class="input_search" /> >+ </td> >+ <td> >+ <input placeholder="Search labels" type="text" id="searching_fields_label" class="input_search" /> >+ </td> >+ <td> >+ <select class="btn btn-s btn-search" id="searching_fields_type"> >+ <option value="All" >All</option> >+ <option value="" ></option> >+ <option value="string" >String</option> >+ <option value="date" >Date</option> >+ <option value="number" >Number</option> >+ <option value="boolean" >Boolean</option> >+ <option value="sum" >Sum</option> >+ </select> >+ </td> >+ <td> >+ <input placeholder="Search weights" type="text" id="searching_fields_weight" class="input_search" /> >+ </td> >+ </tr> >+ </tbody> >+ >+ <tbody class="search_field_table"> >+ > [% FOREACH search_field IN all_search_fields %] >+ > <tr> > <td> >- <input type="text" name="search_field_name" value="[% search_field.name | html %]" /> >+ <input type="text" name="search_field_name" value="[% search_field.name | html %]" class="field_name_research" /> > </td> >- <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" /> >+ <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" class="field_label_research" /></td> > <td> >- <select name="search_field_type"> >+ <select name="search_field_type" class="btn btn-default btn-xs width_full field_type_research" > > <option value=""></option> > [% IF search_field.type == "string" %] > <option value="string" selected="selected">String</option> >@@ -199,7 +408,7 @@ a.add, a.delete { > <option value="sum">Sum</option> > [% END %] > [% IF search_field.type == "isbn" %] >- <option value="isbn" selected="selected">ISBN</option> >+ <option value="isbn" selected="selected">ISBN</option> > [% ELSE %] > <option value="isbn">ISBN</option> > [% END %] >@@ -212,9 +421,9 @@ a.add, a.delete { > </td> > <td> > [% IF search_field.mapped_biblios %] >- <input type="number" step="0.01" min="0.01" max="999.99" name="search_field_weight" value="[% search_field.weight | html %]" /> >+ <input class="field_weight_research" type="number" step="0.01" min="0.01" max="999.99" name="search_field_weight" value="[% search_field.weight | html %]" /> > [% ELSE %] >- <input type="hidden" name="search_field_weight" value=""> >+ <input class="field_weight_research" type="hidden" name="search_field_weight" value=""> > [% END %] > </td> > </tr> >@@ -235,16 +444,53 @@ a.add, a.delete { > <th></th> > </tr> > </thead> >+ > <tbody> >+ <tr> >+ <td> >+ <input placeholder="Search fields" type="text" id="searching_fields_[% index.index_name | html %]" class="input_search" /> >+ </td> >+ <td> >+ <select class="btn btn-s btn-search" id="searching_sortable_[% index.index_name | html %]"> >+ <option value="All" >All</option> >+ <option value="undef" >Undef</option> >+ <option value="0" >0</option> >+ <option value="1" >1</option> >+ </select> >+ </td> >+ <td> >+ <select class="btn btn-s btn-search" id="searching_facetable_[% index.index_name | html %]"> >+ <option value="All" >All</option> >+ <option value="1" >Yes</option> >+ <option value="0" >No</option> >+ </select> >+ </td> >+ <td> >+ <select class="btn btn-s btn-search" id="searching_suggestible_[% index.index_name | html %]"> >+ <option value="All" >All</option> >+ <option value="1" >Yes</option> >+ <option value="0" >No</option> >+ </select> >+ </td> >+ <td> >+ <input placeholder="Search mappings" type="text" id="searching_mappings_[% index.index_name | html %]" class="input_search" /> >+ </td> >+ <td> >+ <a class="btn btn-default btn-s reset_search_[% index.index_name | html %]"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Search</a></td> >+ </td> >+ </tr> >+ </tbody> >+ >+ <tbody class="[% index.index_name | html %]_table"> > [% FOREACH mapping IN index.mappings %] > <tr> > <td> > <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" /> >- <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]"> >+ <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]" class="field_name_research_[% index.index_name | html %]"> > [% mapping.search_field_label | html %] > </td> > <td> >- <select name="mapping_sort"> >+ <select name="mapping_sort" class="btn btn-default btn-xs width_full sort_research_[% index.index_name | html %]"> > [% IF mapping.sort == 'undef' %] > <option value="undef" selected="selected">Undef</option> > [% ELSE %] >@@ -264,7 +510,7 @@ a.add, a.delete { > </td> > <td> > [% IF mapping.is_facetable %] >- <select name="mapping_facet"> >+ <select name="mapping_facet" class="btn btn-default btn-xs width_full facet_research_select_[% index.index_name | html %]"> > [% IF mapping.facet %] > <option value="0">No</option> > <option value="1" selected="selected">Yes</option> >@@ -274,12 +520,12 @@ a.add, a.delete { > [% END %] > </select> > [% ELSE %] >- <input type="hidden" name="mapping_facet" value="0" /> >+ <input type="hidden" name="mapping_facet" value="0" class="facet_research_input_[% index.index_name | html %]"/> > No > [% END %] > </td> > <td> >- <select name="mapping_suggestible"> >+ <select name="mapping_suggestible" class="btn btn-default btn-xs width_full suggestible_research_[% index.index_name | html %]"> > [% IF mapping.suggestible %] > <option value="0">No</option> > <option value="1" selected="selected">Yes</option> >@@ -290,7 +536,7 @@ a.add, a.delete { > </select> > </td> > <td> >- <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" /> >+ <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" class="mapping_research_[% index.index_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> >@@ -300,21 +546,21 @@ a.add, a.delete { > <tr class="nodrag nodrop"> > <td> > <input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" /> >- <select data-id="mapping_search_field_name"> >+ <select data-id="mapping_search_field_name" class="btn btn-default btn-xs width_full" > > [% FOREACH f IN all_search_fields %] > <option value="[% f.name | html %]">[% f.name | html %]</option> > [% END %] > </select> > </td> > <td> >- <select data-id="mapping_sort"> >+ <select data-id="mapping_sort" class="btn btn-default btn-xs width_full"> > <option value="undef">Undef</option> > <option value="0">0</option> > <option value="1">1</option> > </select> > </td> > <td> >- <select data-id="mapping_facet"> >+ <select data-id="mapping_facet" class="btn btn-default btn-xs width_full"> > [% IF mapping.facet %] > <option value="0">No</option> > <option value="1" selected="selected">Yes</option> >@@ -325,7 +571,7 @@ a.add, a.delete { > </select> > </td> > <td> >- <select data-id="mapping_suggestible"> >+ <select data-id="mapping_suggestible" class="btn btn-default btn-xs width_full"> > [% IF mapping.suggestible %] > <option value="0">No</option> > <option value="1" selected="selected">Yes</option> >-- >2.7.4
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 19598
:
90534