Bugzilla – Attachment 73681 Details for
Bug 20388
Ability to add search fields from UI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20388 - Add/delete search fields from search engine configuration page
Bug-20388---Adddelete-search-fields-from-search-en.patch (text/plain), 6.42 KB, created by
Nicolas Legrand
on 2018-04-05 12:54:17 UTC
(
hide
)
Description:
Bug 20388 - Add/delete search fields from search engine configuration page
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2018-04-05 12:54:17 UTC
Size:
6.42 KB
patch
obsolete
>From 11fccd2dd84f3c17a09f3704b50de2b3ff393d52 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Thu, 22 Mar 2018 15:36:03 +0000 >Subject: [PATCH] Bug 20388 - Add/delete search fields from search engine > configuration page >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Test plan: > > - apply this patch, > - check that SearchEngine system preference is set to Elasticsearch, > - go to Admin > Search engine configuration, > - on the search fields tab, fill a new line at the bottom of the table > (name, label, type) > - click on the "Add" button and save, > - check that the new search field has been saved, > - also test field deletions, > - check that you can't delete already mapped fields. > >Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr> >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > admin/searchengine/elasticsearch/mappings.pl | 22 ++++++---- > .../admin/searchengine/elasticsearch/mappings.tt | 49 +++++++++++++++++++++- > 2 files changed, 63 insertions(+), 8 deletions(-) > >diff --git a/admin/searchengine/elasticsearch/mappings.pl b/admin/searchengine/elasticsearch/mappings.pl >index 7d63002..27579d4 100755 >--- a/admin/searchengine/elasticsearch/mappings.pl >+++ b/admin/searchengine/elasticsearch/mappings.pl >@@ -61,14 +61,17 @@ if ( $op eq 'edit' ) { > > eval { > >+ Koha::SearchFields->search()->delete; >+ > for my $i ( 0 .. scalar(@field_name) - 1 ) { > my $field_name = $field_name[$i]; > my $field_label = $field_label[$i]; > my $field_type = $field_type[$i]; >- my $search_field = Koha::SearchFields->find( { name => $field_name }, { key => 'name' } ); >- $search_field->label($field_label); >- $search_field->type($field_type); >- $search_field->store; >+ my $search_field = Koha::SearchFields->find_or_create({ >+ name => $field_name, >+ label => $field_label, >+ type => $field_type >+ }); > } > > Koha::SearchMarcMaps->search( { marc_type => $marc_type, } )->delete; >@@ -133,11 +136,16 @@ for my $index_name (qw| biblios authorities |) { > push @indexes, { index_name => $index_name, mappings => \@mappings }; > } > >-my $search_fields = $schema->resultset('SearchField')->search; >-my @all_search_fields = $search_fields->search( {}, { order_by => ['name'] } ); >+my $all_search_fields = Koha::SearchFields->search( {}, { order_by => ['name'] } )->unblessed; >+foreach my $search_field ( @$all_search_fields ) { >+ $search_field->{is_mapped} = $schema->resultset('SearchMarcToField')->search( >+ { search_field_id => $search_field->{id} })->count; >+} >+ >+ > $template->param( > indexes => \@indexes, >- all_search_fields => \@all_search_fields, >+ all_search_fields => $all_search_fields, > messages => \@messages, > ); > >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 cc6f94c..74da23b 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 >@@ -50,6 +50,24 @@ > } ); > } > }); >+ $('.add-search-field').click(function() { >+ var table = $(this).closest('table'); >+ var line = $(this).closest("tr"); >+ 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); >+ >+ $(table).tableDnD( { >+ onDragClass: "dragClass", >+ } ); >+ } >+ }); > }); > </script> > <style type="text/css"> >@@ -120,12 +138,13 @@ a.add, a.delete { > [% END %] > </ul> > <div id="search_fields"> >- <table class="search_fields"> >+ <table class="search_fields" data-index_name="search_fields"> > <thead> > <tr> > <th>Name</th> > <th>Label</th> > <th>Type</th> >+ <th></th> > </tr> > </thead> > <tbody> >@@ -165,9 +184,37 @@ a.add, a.delete { > [% END %] > </select> > </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> >+ [% ELSE %] >+ <a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a> >+ [% END %] >+ </td> > </tr> > [% END %] > </tbody> >+ <tfoot> >+ <tr> >+ <td> >+ <input type="text" data-id="search_field_name"/> >+ </td> >+ <td> >+ <input type="text" data-id="search_field_label"/> >+ </td> >+ <td> >+ <select data-id="search_field_type"> >+ <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><a class="btn btn-default btn-xs add-search-field"><i class="fa fa-plus"></i> Add</a></td> >+ </tr> >+ </tfoot> > </table> > </div> > [% FOREACH index IN indexes %] >-- >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 20388
:
73158
|
73165
|
73167
|
73476
|
73626
|
73627
|
73629
|
73681
|
73682
|
73918
|
73919
|
73940
|
73943
|
73944
|
73945
|
73946
|
74261
|
74718
|
74719
|
78658
|
78659
|
80709
|
86912
|
87196
|
87197
|
87198
|
87199
|
87201
|
87202
|
87203
|
87204
|
88075
|
88079
|
88080
|
88081
|
88082
|
88083
|
89117
|
89118
|
89121
|
89733
|
89894
|
90517
|
90518
|
90519
|
90520
|
90521
|
90522
|
90523
|
90524
|
98011
|
98012
|
98013
|
98014
|
98015
|
98016
|
98017
|
98018
|
99960
|
99961
|
99962
|
99963
|
99964
|
99965
|
99966
|
99967
|
119296
|
119317
|
119318
|
120104
|
163449
|
163450
|
163451
|
163452
|
163460
|
163461
|
163462
|
163463
|
164529
|
164530
|
164531
|
164532
|
164533
|
164534
|
164535
|
164789
|
164790
|
164791
|
164792
|
164793