Bugzilla – Attachment 74315 Details for
Bug 20588
Elasticsearch - Apply dataTable on search fields and mapping tables
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20588 - Apply dataTable on search fields and mapping tables
Bug-20588---Apply-dataTable-on-search-fields-and-m.patch (text/plain), 10.23 KB, created by
Séverine Queune
on 2018-04-17 11:51:04 UTC
(
hide
)
Description:
Bug 20588 - Apply dataTable on search fields and mapping tables
Filename:
MIME Type:
Creator:
Séverine Queune
Created:
2018-04-17 11:51:04 UTC
Size:
10.23 KB
patch
obsolete
>From d852d1afcb96521644f0044b8444fa5649177e25 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@gmail.com> >Date: Thu, 12 Apr 2018 09:36:59 +0000 >Subject: [PATCH] Bug 20588 - Apply dataTable on search fields and mapping > tables >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This add the following capabilities: > - Pagination, > - columns sorting, > - data filtering > >Test plan: > - apply this patch, > - update DB and schema files, > - add/remove search fields and mappings > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > .../admin/searchengine/elasticsearch/mappings.tt | 154 ++++++++++++++++----- > 1 file changed, 118 insertions(+), 36 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 0da3b7d..5822101 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 >@@ -2,13 +2,51 @@ > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Elastic Search mappings</title> > [% INCLUDE 'doc-head-close.inc' %] >+[% INCLUDE 'datatables.inc' %] > [% Asset.js("lib/jquery/plugins/jquery.tablednd.js") %] >+[% Asset.css("css/datatables.css") %] > <script type="text/javascript"> >+ var searchfieldst; >+ var bibliost; >+ var authoritiest; >+ > function clean_line( line ) { > $(line).find('input[type="text"]').val(""); > $(line).find('select').find('option:first').attr("selected", "selected"); > } > >+ function reset_datatables() { >+ var searchfieldSettings = searchfieldst.fnSettings(); >+ var biblioSettings = bibliost.fnSettings(); >+ var authoritySettings = authoritiest.fnSettings(); >+ >+ searchfieldSettings._iDisplayLength = 20; >+ biblioSettings._iDisplayLength = 20; >+ authoritySettings._iDisplayLength = 20; >+ >+ searchfieldst.fnDraw(); >+ bibliost.fnDraw(); >+ authoritiest.fnDraw(); >+ } >+ >+ function show_all_rows() { >+ var searchfieldSettings = searchfieldst.fnSettings(); >+ var biblioSettings = bibliost.fnSettings(); >+ var authoritySettings = authoritiest.fnSettings(); >+ >+ searchfieldSettings._iDisplayLength = -1; >+ biblioSettings._iDisplayLength = -1; >+ authoritySettings._iDisplayLength = -1; >+ >+ searchfieldSettings.oPreviousSearch.sSearch = ""; >+ biblioSettings.oPreviousSearch.sSearch = ""; >+ authoritySettings.oPreviousSearch.sSearch = ""; >+ >+ searchfieldst.fnDraw(); >+ bibliost.fnDraw(); >+ authoritiest.fnDraw(); >+ } >+ > function clone_line( line ) { > var new_line = $(line).clone(); > $(new_line).removeClass("nodrag nodrop"); >@@ -26,60 +64,104 @@ > > $(document).ready(function() { > $("#tabs").tabs(); >- $('.delete').click(function() { >- $(this).parents('tr').remove(); > >- var line = $(this).closest("tr"); >+ //searchfieldst = KohaTable("search-fieldst", { >+ searchfieldst = $('#search-fieldst').dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "sType": "string", "aTargets": [ "string-sort" ] } >+ ], >+ "sPaginationType": "full_numbers", >+ })); >+ >+ bibliost = $('#bibliost').dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "sType": "string", "aTargets": [ "string-sort" ] } >+ ], >+ "sPaginationType": "full_numbers", >+ })); >+ >+ authoritiest = $('#authoritiest').dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "sType": "string", "aTargets": [ "string-sort" ] } >+ ], >+ "sPaginationType": "full_numbers", >+ })); >+ >+ $('#save').click(function() { >+ show_all_rows(); >+ }); >+ >+ $('table.dataTable').on('click', '.delete', function() { >+ var tableid = $(this).closest('table').attr('id'); >+ var t = $('#' + tableid).DataTable(); >+ var line = $(this).closest('tr'); >+ t.row( $(this).parents('tr') ).remove().draw( false ); >+ >+ // Show all rows on biblios and authorities table >+ // to find some mapping. >+ show_all_rows(); >+ > var search_field_name = $(line).find('input[name="mapping_search_field_name"]').val(); > var mappings = $('input[name="mapping_search_field_name"][type="hidden"][value="' + search_field_name + '"]'); >+ > if (mappings.length == 0) { > var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); > $(search_field_line).find('a.btn-default').removeClass('disabled'); > } >+ >+ //Set display length back to 20. >+ reset_datatables(); > }); > > $("table.mappings").tableDnD( { > onDragClass: "dragClass", > } ); >+ > $('.add').click(function() { >- var table = $(this).closest('table'); >- var index_name = $(table).attr('data-index_name'); >+ var tableid = $(this).closest('table').attr('id'); >+ var t = $('#' + tableid).DataTable(); > var line = $(this).closest("tr"); >+ var new_line = clone_line( line ); >+ > 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(); >- }); >+ t.row.add($(new_line)).draw( false ); >+ t.order([1, 'asc']).draw(); >+ t.page('last').draw(false); >+ >+ // Show all rows on search-fields table >+ // to find the search field. >+ var mappingSettings = mappingst.fnSettings(); >+ mappingSettings._iDisplayLength = -1; >+ mappingst.fnDraw(); > > var search_field_name = $(line).find('select[data-id="mapping_search_field_name"] option:selected').text(); > var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); > $(search_field_line).find('a.btn-default').addClass('disabled'); > >- clean_line(line); >+ //Set display length back to 20. >+ mappingSettings._iDisplayLength = 20; >+ mappingst.fnDraw(); > >- $(table).tableDnD( { >- onDragClass: "dragClass", >- } ); >+ clean_line(line); > } > }); >+ > $('.add-search-field').click(function() { >- var table = $(this).closest('table'); >+ var t = $('#search-fieldst').DataTable(); > var line = $(this).closest("tr"); >+ var new_line = clone_line( line ); >+ > var name = $(line).find('input[data-id="search_field_name"]').val(); > var label = $(line).find('input[data-id="search_field_name"]').val(); >+ > if ( name.length > 0 && label.length > 0 ) { >- var new_line = clone_line( line ); >- new_line.appendTo($('table[data-index_name=search_fields]>tbody')); >- $('.delete').click(function() { >- $(this).parents('tr').remove(); >- }); >- clean_line(line); >+ t.row.add($(new_line)).draw( false ); >+ t.order([1, 'asc']).draw(); >+ t.page('last').draw(false); > >- $(table).tableDnD( { >- onDragClass: "dragClass", >- } ); >+ clean_line(line); > } > }); > }); >@@ -159,14 +241,14 @@ a.add, a.delete { > [% END %] > </ul> > <div id="search_fields"> >- <table class="search_fields" data-index_name="search_fields"> >+ <table id="search-fieldst" class="search_fields" data-index_name="search_fields"> > <thead> > <tr> >- <th>Name</th> >- <th>Label</th> >- <th>Type</th> >- <th>Weight</th> >- <th></th> >+ <th class="string-sort">Name</th> >+ <th class="string-sort">Label</th> >+ <th class="string-sort">Type</th> >+ <th class="string-sort">Weight</th> >+ <th class="string-sort"></th> > </tr> > </thead> > <tbody> >@@ -253,14 +335,14 @@ a.add, a.delete { > </div> > [% FOREACH index IN indexes %] > <div id="mapping_[% index.index_name %]"> >- <table class="mappings" data-index_name="[% index.index_name%]"> >+ <table id="[% index.index_name%]t" class="mappings" data-index_name="[% index.index_name%]"> > <thead> > <tr class="nodrag nodrop"> > <th>Search field</th> >- <th>Sortable</th> >- <th>Facetable</th> >- <th>Suggestible</th> >- <th>Mapping</th> >+ <th class="string-sort">Sortable</th> >+ <th class="string-sort">Facetable</th> >+ <th class="string-sort">Suggestible</th> >+ <th class="string-sort">Mapping</th> > <th></th> > </tr> > </thead> >@@ -367,7 +449,7 @@ a.add, a.delete { > </div> > [% END %] > </div> >- <p><button class="btn btn-default" type="submit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button></p> >+ <p><button id="save" class="btn btn-default" type="submit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button></p> > </form> > </div> > >-- >2.1.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 20588
:
74241
|
74312
|
74315
|
78660
|
90576
|
90585