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