Bug 25054: (QA follow-up) Add space after comma for multiple aliases
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / searchengine / elasticsearch / mappings.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% PROCESS 'i18n.inc' %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Administration &rsaquo; Search engine configuration (Elasticsearch)</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %]
8 <script>
9     function clean_line( line ) {
10         $(line).find('input[type="text"]').val("");
11         $(line).find('select').find('option:first').attr("selected", "selected");
12     }
13
14     function clone_line( line ) {
15         var new_line = $(line).clone();
16         $(new_line).removeClass("nodrag nodrop");
17         $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html(_("Delete"));
18         $(new_line).find('[data-id]').each( function() {
19             $(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id');
20         } );
21         $(new_line).find("select").each( function() {
22             var attr = $(this).attr('name');
23             var val = $(line).find('[data-id="' + attr + '"]').val();
24             $(this).find('option[value="' + val + '"]').attr("selected", "selected");
25         } );
26         return new_line;
27     }
28
29     $(document).ready(function() {
30         $("#tabs").tabs();
31         $('.delete').click(function() {
32             if( $(this).hasClass('mandatory') && $(".mandatory[data-field_name="+$(this).attr('data-field_name')+"]").length < 2 ){
33                 alert("This field is mandatory and must have at least one mapping");
34                 return;
35             } else {
36                 $(this).parents('tr').remove();
37             }
38         });
39
40         $("table.mappings").tableDnD( {
41             onDragClass: "dragClass",
42         } );
43         $('.add').click(function() {
44             var table = $(this).closest('table');
45             var index_name   = $(table).attr('data-index_name');
46             var line = $(this).closest("tr");
47             var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val();
48             if ( marc_field.length > 0 ) {
49                 var new_line = clone_line( line );
50                 new_line.appendTo($('table[data-index_name="'+index_name+'"]>tbody'));
51                 $('.delete').click(function() {
52                     $(this).parents('tr').remove();
53                 });
54                 clean_line(line);
55
56                 $(table).tableDnD( {
57                     onDragClass: "dragClass",
58                 } );
59             }
60         });
61         $("#facet_biblios > table").tableDnD( {
62             onDragClass: "dragClass",
63         } );
64     });
65 </script>
66 <style>
67 a.add, a.delete {
68     cursor: pointer;
69 }
70 </style>
71 </head>
72 <body id="admin_searchengine_mappings" class="admin">
73 [% INCLUDE 'header.inc' %]
74 [% INCLUDE 'prefs-admin-search.inc' %]
75
76 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Search engine configuration (Elasticsearch)</div>
77
78 [% INCLUDE 'blocking_errors.inc' %]
79
80 <div class="main container-fluid">
81     <div class="row">
82         <div class="col-sm-10 col-sm-push-2">
83             <main>
84
85     [% FOR m IN messages %]
86       <div class="dialog [% m.type | html %]">
87         [% SWITCH m.code %]
88         [% CASE 'error_on_update' %]
89           [% tx("An error occurred when updating mappings: {message}.", { message = m.message }) | html %]
90         [% CASE 'error_on_delete' %]
91           [% t("An error occurred when deleting the existing mappings. Nothing has been changed!") | $raw %]
92           [% tx("(search field {field_name} with mapping {marc_field}.)", { field_name = m.values.field_name, marc_field = m.values.marc_field }) | html %]
93         [% CASE 'invalid_field_weight' %]
94           [% tx("Invalid field weight '{weight}', must be a positive decimal number.", { weight = m.weight }) | html %]
95         [% CASE 'missing_mandatory_fields' %]
96           [% t("You attempted to delete all mappings for a required index, you must leave at least one mapping") | $raw %]
97         [% CASE 'error_on_update_es_mappings' %]
98           [% tx("An error occurred when updating Elasticsearch index mappings: {message}.", { message = m.message }) | html %]
99         [% CASE 'reindex_required' %]
100           [% tx("Index '{index}' needs to be reindexed.", { index = m.index }) | html %]
101         [% CASE 'recreate_required' %]
102           [% tx("Index '{index}' needs to be recreated.", { index = m.index }) | html %]
103         [% CASE 'success_on_update' %]
104           [% t("Mappings updated successfully.") | $raw %]
105         [% CASE 'success_on_reset' %]
106           [% t("Mappings have been reset successfully.") | $raw %]
107         [% CASE 'elasticsearch_disabled' %]
108           [% t("Elasticsearch is currently disabled.") | $raw %]
109         [% CASE %]
110           [% m.code | html %]
111         [% END %]
112       </div>
113     [% END %]
114
115     <h1>Search engine configuration (Elasticsearch)</h1>
116     <div class="dialog message">
117         Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
118
119         <p>Weight: define weight as a positive number. Higher numbers indicate increased relevancy.
120         <strong>Note that fields weighting works only for simple search.</strong></p>
121         <ol>
122           <li>only search fields mapped with biblios can be weighted</li>
123           <li>search will boost/increase weighted field(s) relevancy</li>
124         </ol>
125     </div>
126     [% IF errors %]
127         <div class="dialog alert">
128         Changes have not been applied. Please check the following values:
129           <ul>
130             [% FOREACH e IN errors %]
131                 <li>
132                     [% IF ( e.type == "malformed_mapping" ) %]
133                         <span>The value "[% e.value | html %]" is not supported for mappings</span>
134                     [% ELSIF ( e.type == "no_mapping" ) %]
135                         <span>There is no mapping for the index [% e.value | html %]</span>
136                     [% END %]
137                 </li>
138             [% END %]
139           </ul>
140         </div>
141     [% END %]
142
143     [% IF reset_confirm %]
144         <div class="dialog alert">
145             <h3>The current mappings you see on the screen will be erased and replaced by the mappings in the mappings.yaml file.</h3>
146             <form method="post">
147                 <input type="hidden" name="op" value="reset_confirmed" />
148                 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, reset mappings</button>
149             </form>
150             <br>
151             <form method="post">
152                 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not reset mappings</button>
153             </form>
154         </div>
155     [% END %]
156     <form method="post">
157         <div id="tabs" class="toptabs" style="clear:both">
158             <ul>
159                 <li><a href="#search_fields">Search fields</a></li>
160                 [% FOREACH index IN indexes %]
161                     [% SWITCH index.index_name %]
162                         [% CASE 'biblios' %]<li><a href="#mapping_biblios">Bibliographic records</a></li>
163                         [% CASE 'authorities' %]<li><a href="#mapping_authorities">Authorities</a></li>
164                     [% END %]
165                 [% END %]
166             </ul>
167             <div id="search_fields">
168               <table class="search_fields">
169                 <thead>
170                   <tr>
171                     <th>Name</th>
172                     <th>Aliases</th>
173                     <th>Label</th>
174                     <th>Type</th>
175                     <th colspan="2">Searchable</th>
176                     <th>Weight</th>
177                   </tr>
178                   <tr>
179                     <th colspan=4>&nbsp;</th>
180                     <th>Staff interface</th>
181                     <th>OPAC</th>
182                     <th>&nbsp;</th>
183                   </tr>
184                 </thead>
185                 <tbody>
186                   [% FOREACH search_field IN all_search_fields %]
187                     <tr>
188                       <td>
189                         [% IF search_field.mandatory %]
190                             <input type="text" name="search_field_name" value="[% search_field.name | html %]" readonly />
191                         [% ELSE %]
192                             <input type="text" name="search_field_name" value="[% search_field.name | html %]" />
193                         [% END %]
194                       </td>
195                       <td>
196                           [% search_field.aliases.join(', ') | html %]
197                       </td>
198                       <td>
199                         [% IF search_field.mandatory %]
200                             <input type="text" name="search_field_label" value="[% search_field.label | html %]" readonly />
201                         [% ELSE %]
202                             <input type="text" name="search_field_label" value="[% search_field.label | html %]" />
203                         [% END %]
204                       </td>
205                       <td>
206                         [% IF search_field.mandatory %]
207                             <input type="hidden" name="search_field_type" value="[% search_field.type | html %]" />
208                             <select name="search_field_type" disabled>
209                         [% ELSE %]
210                             <select name="search_field_type">
211                         [% END %]
212                               <option value=""></option>
213                               [% IF search_field.type == "string" %]
214                                 <option value="string" selected="selected">String</option>
215                               [% ELSE %]
216                                 <option value="string">String</option>
217                               [% END %]
218                               [% IF search_field.type == "date" %]
219                                 <option value="date" selected="selected">Date</option>
220                               [% ELSE %]
221                                 <option value="date">Date</option>
222                               [% END %]
223                               [% IF search_field.type == "year" %]
224                                 <option value="year" selected="selected">Year</option>
225                               [% ELSE %]
226                                 <option value="year">Year</option>
227                               [% END %]
228                               [% IF search_field.type == "number" %]
229                                 <option value="number" selected="selected">Number</option>
230                               [% ELSE %]
231                                 <option value="number">Number</option>
232                               [% END %]
233                               [% IF search_field.type == "boolean" %]
234                                 <option value="boolean" selected="selected">Boolean</option>
235                               [% ELSE %]
236                                 <option value="boolean">Boolean</option>
237                               [% END %]
238                               [% IF search_field.type == "sum" %]
239                                 <option value="sum" selected="selected">Sum</option>
240                               [% ELSE %]
241                                 <option value="sum">Sum</option>
242                               [% END %]
243                               [% IF search_field.type == "isbn" %]
244                                 <option value="isbn" selected="selected">ISBN</option>
245                               [% ELSE %]
246                                 <option value="isbn">ISBN</option>
247                               [% END %]
248                               [% IF search_field.type == "stdno" %]
249                                 <option value="stdno" selected="selected">Std. Number</option>
250                               [% ELSE %]
251                                 <option value="stdno">Std. Number</option>
252                               [% END %]
253                             </select>
254                       </td>
255                       <td>
256                         <select name="search_field_staff_client">
257                           [% IF search_field.staff_client %]
258                             <option value="1" selected="selected">Yes</option>
259                             <option value="0">No</option>
260                           [% ELSE %]
261                             <option value="1">Yes</option>
262                             <option value="0" selected="selected">No</option>
263                           [% END %]
264                         </select>
265                       </td>
266                       <td>
267                         <select name="search_field_opac">
268                           [% IF search_field.opac %]
269                             <option value="1" selected="selected">Yes</option>
270                             <option value="0">No</option>
271                           [% ELSE %]
272                             <option value="1">Yes</option>
273                             <option value="0" selected="selected">No</option>
274                           [% END %]
275                         </select>
276                       </td>
277                       <td>
278                         [% IF search_field.mapped_biblios %]
279                             <input type="number" step="0.01" min="0.01" max="999.99" name="search_field_weight" value="[% search_field.weight | html %]" />
280                         [% ELSE %]
281                             <input type="hidden" name="search_field_weight" value="">
282                         [% END %]
283                       </td>
284                     </tr>
285                   [% END %]
286                 </tbody>
287               </table>
288             </div>
289             [% FOREACH index IN indexes %]
290                 <div id="mapping_[% index.index_name | html %]">
291                     <table class="mappings" data-index_name="[% index.index_name | html %]">
292                       <thead>
293                         <tr class="nodrag nodrop">
294                           <th>Search field</th>
295                           <th>Sortable</th>
296                           <th>Facetable</th>
297                           <th>Suggestible</th>
298                           <th>Searchable</th>
299                           <th>Mapping</th>
300                           <th></th>
301                         </tr>
302                       </thead>
303                       <tbody>
304                         [% FOREACH mapping IN index.mappings %]
305                             [% IF mapping.search_field_mandatory && mapping.search_field_label != loop.next.search_field_label && mapping.search_field_label != loop.prev.search_field_label %]
306                               <tr>
307                                 <td>
308                                   <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
309                                   <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
310                                   [% mapping.search_field_label | html %]
311                                 </td>
312                                 <td>
313                                   <input type="hidden" name="mapping_sort" value="[% mapping.sort | html %]" readonly />[% IF mapping.sort == 'undef' %]Undef[% ELSE %][% mapping.sort | html %][% END %]
314                                 </td>
315                                 <td>
316                                   <input type="hidden" name="mapping_facet" value="[% mapping.facet | html %]" readonly />[% IF mapping.facet == 1 %]Yes[% ELSE %]No[% END %]
317                                 </td>
318                                 <td>
319                                   <input type="hidden" name="mapping_suggestible" value="[% mapping.suggestible | html %]" readonly />[% IF mapping.suggestible == 1 %]Yes[% ELSE %]No[% END %]
320                                 </td>
321                                 <td>
322                                   <input type="hidden" name="mapping_search" value="[% mapping.search | html %]" readonly />[% IF mapping.search == 1 %]Yes[% ELSE %]No[% END %]
323                                 </td>
324                                 <td>
325                                     <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
326                                 </td>
327                               </tr>
328                             [% ELSE %]
329                               <tr>
330                                 <td>
331                                   <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
332                                   <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
333                                   [% mapping.search_field_label | html %]
334                                 </td>
335                                 <td>
336                                   <select name="mapping_sort">
337                                     [% IF mapping.sort == 'undef' %]
338                                       <option value="undef" selected="selected">Undef</option>
339                                     [% ELSE %]
340                                       <option value="undef">Undef</option>
341                                     [% END %]
342                                     [% IF mapping.sort == 0 %]
343                                       <option value="0" selected="selected">0</option>
344                                     [% ELSE %]
345                                       <option value="0">0</option>
346                                     [% END %]
347                                     [% IF  mapping.sort == 1 %]
348                                       <option value="1" selected="selected">1</option>
349                                     [% ELSE %]
350                                       <option value="1">1</option>
351                                     [% END %]
352                                   </select>
353                                 </td>
354                                 <td>
355                                   [% IF mapping.is_facetable %]
356                                     <select name="mapping_facet">
357                                       [% IF mapping.facet %]
358                                         <option value="0">No</option>
359                                         <option value="1" selected="selected">Yes</option>
360                                       [% ELSE %]
361                                         <option value="0" selected="selected">No</option>
362                                         <option value="1">Yes</option>
363                                       [% END %]
364                                     </select>
365                                   [% ELSE %]
366                                     <input type="hidden" name="mapping_facet" value="0" />
367                                     No
368                                   [% END %]
369                                 </td>
370                                 <td>
371                                   <select name="mapping_suggestible">
372                                     [% IF mapping.suggestible %]
373                                       <option value="0">No</option>
374                                       <option value="1" selected="selected">Yes</option>
375                                     [% ELSE %]
376                                       <option value="0" selected="selected">No</option>
377                                       <option value="1">Yes</option>
378                                     [% END %]
379                                   </select>
380                                 </td>
381                                 <td>
382                                   <select name="mapping_search">
383                                     [% IF mapping.search %]
384                                       <option value="0">No</option>
385                                       <option value="1" selected="selected">Yes</option>
386                                     [% ELSE %]
387                                       <option value="0" selected="selected">No</option>
388                                       <option value="1">Yes</option>
389                                     [% END %]
390                                   </select>
391                                 </td>
392                                 <td>
393                                     <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
394                                 </td>
395                                 [% IF mapping.search_field_mandatory %]
396                                     <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>
397                                 [% ELSE %]
398                                     <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
399                                 [% END %]
400                               </tr>
401                             [% END %]
402                         [% END %]
403                       </tbody>
404                       <tfoot>
405                         <tr class="nodrag nodrop">
406                           <td>
407                             <input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" />
408                             <select data-id="mapping_search_field_name">
409                              [% FOREACH f IN all_search_fields %]
410                                <option value="[% f.name | html %]">[% f.name | html %]</option>
411                              [% END %]
412                             </select>
413                           </td>
414                           <td>
415                             <select data-id="mapping_sort">
416                               <option value="undef">Undef</option>
417                               <option value="0">0</option>
418                               <option value="1">1</option>
419                             </select>
420                           </td>
421                           <td>
422                             <select data-id="mapping_facet">
423                               [% IF mapping.facet %]
424                                 <option value="0">No</option>
425                                 <option value="1" selected="selected">Yes</option>
426                               [% ELSE %]
427                                 <option value="0" selected="selected">No</option>
428                                 <option value="1">Yes</option>
429                               [% END %]
430                             </select>
431                           </td>
432                           <td>
433                             <select data-id="mapping_suggestible">
434                               [% IF mapping.suggestible %]
435                                 <option value="0">No</option>
436                                 <option value="1" selected="selected">Yes</option>
437                               [% ELSE %]
438                                 <option value="0" selected="selected">No</option>
439                                 <option value="1">Yes</option>
440                               [% END %]
441                             </select>
442                           </td>
443                           <td>
444                             <select data-id="mapping_search">
445                               [% IF mapping.search %]
446                                 <option value="0">No</option>
447                                 <option value="1" selected="selected">Yes</option>
448                               [% ELSE %]
449                                 <option value="0" selected="selected">No</option>
450                                 <option value="1">Yes</option>
451                               [% END %]
452                             </select>
453                           </td>
454                           <td><input data-id="mapping_marc_field" type="text" /></td>
455                           <td><a class="btn btn-default btn-xs add"><i class="fa fa-plus"></i> Add</a></td>
456                         </tr>
457                       </tfoot>
458                     </table>
459
460                     [% IF index.index_name == 'biblios' %]
461                         <h3>Facet order</h3>
462                         <div id="facet_[% index.index_name | html %]">
463                             <table>
464                                 <thead>
465                                     <tr>
466                                         <th>Search field</th>
467                                         <th>Label</th>
468                                         <th>Display</th>
469                                     </tr>
470                                 </thead>
471                                 <tbody>
472                                     [% FOREACH f IN facetable_fields %]
473                                         <tr>
474                                             <td>
475                                                 [% f.name | html %]
476                                             </td>
477                                             <td>
478                                                 [% SWITCH f.name %]
479                                                 [% CASE 'author' %]Authors
480                                                 [% CASE 'itype' %]Item Types
481                                                 [% CASE 'location' %]Locations
482                                                 [% CASE 'su-geo' %]Places
483                                                 [% CASE 'title-series' %]Series
484                                                 [% CASE 'subject' %]Topics
485                                                 [% CASE 'ccode' %]Collections
486                                                 [% CASE 'holdingbranch' %]Holding libraries
487                                                 [% CASE 'homebranch' %]Home libraries
488                                                 [% CASE 'ln' %]Language
489                                                 [% CASE %][% f | html %]
490                                                 [% END %]
491                                             </td>
492                                             <td>
493                                                 [% IF f.facet_order %]
494                                                     <input type="checkbox" name="display_facet" value="[% f.name | html %]" checked="checked" />
495                                                 [% ELSE %]
496                                                     <input type="checkbox" name="display_facet" value="[% f.name | html %]" />
497                                                 [% END %]
498                                             </td>
499                                         </tr>
500                                     [% END %]
501                                 </tbody>
502                             </table>
503                         </div>
504                     [% END %]
505                 </div>
506             [% END %]
507         </div>
508         <p>
509             <button class="btn btn-default" type="submit" name="op" value="edit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button>
510             <button class="btn btn-default" type="submit" name="op" value="reset_confirm"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Mappings</button>
511         </p>
512     </form>
513
514             </main>
515         </div> <!-- /.col-sm-10.col-sm-push-2 -->
516
517         <div class="col-sm-2 col-sm-pull-10">
518             <aside>
519                 [% INCLUDE 'admin-menu.inc' %]
520             </aside>
521         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
522      </div> <!-- /.row -->
523
524 [% INCLUDE 'intranet-bottom.inc' %]