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