Bug 27682: Add a floating table header for Search engine configuration
[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" id="search_fields_table">
112                 <thead>
113                   <tr>
114                     <th>Name</th>
115                     <th>Aliases</th>
116                     <th>Label</th>
117                     <th>Type</th>
118                     <th>Weight</th>
119                     <th colspan="2">Searchable</th>
120                   </tr>
121                   <tr>
122                     <th colspan="5" class="NoSort">&nbsp;</th>
123                     <th class="NoSort">Staff interface</th>
124                     <th class="NoSort">OPAC</th>
125                   </tr>
126                 </thead>
127                 <tbody>
128                   [% FOREACH search_field IN all_search_fields %]
129                     <tr>
130                       <td data-order="[% search_field.name | html %]">
131                         [% IF search_field.mandatory %]
132                             <input type="text" name="search_field_name" value="[% search_field.name | html %]" readonly />
133                         [% ELSE %]
134                             <input type="text" name="search_field_name" value="[% search_field.name | html %]" />
135                         [% END %]
136                       </td>
137                       <td>
138                           [% search_field.aliases.join(', ') | html %]
139                       </td>
140                       <td data-order="[% search_field.label | html %]">
141                         [% IF search_field.mandatory %]
142                             <input type="text" name="search_field_label" value="[% search_field.label | html %]" readonly />
143                         [% ELSE %]
144                             <input type="text" name="search_field_label" value="[% search_field.label | html %]" />
145                         [% END %]
146                       </td>
147                       <td data-order="[% search_field.type | html %]">
148                         [% IF search_field.mandatory %]
149                             <input type="hidden" name="search_field_type" value="[% search_field.type | html %]" />
150                             <select name="search_field_type" disabled>
151                         [% ELSE %]
152                             <select name="search_field_type">
153                         [% END %]
154                               <option value=""></option>
155                               [% IF search_field.type == "string" %]
156                                 <option value="string" selected="selected">String</option>
157                               [% ELSE %]
158                                 <option value="string">String</option>
159                               [% END %]
160                               [% IF search_field.type == "date" %]
161                                 <option value="date" selected="selected">Date</option>
162                               [% ELSE %]
163                                 <option value="date">Date</option>
164                               [% END %]
165                               [% IF search_field.type == "year" %]
166                                 <option value="year" selected="selected">Year</option>
167                               [% ELSE %]
168                                 <option value="year">Year</option>
169                               [% END %]
170                               [% IF search_field.type == "number" %]
171                                 <option value="number" selected="selected">Number</option>
172                               [% ELSE %]
173                                 <option value="number">Number</option>
174                               [% END %]
175                               [% IF search_field.type == "boolean" %]
176                                 <option value="boolean" selected="selected">Boolean</option>
177                               [% ELSE %]
178                                 <option value="boolean">Boolean</option>
179                               [% END %]
180                               [% IF search_field.type == "sum" %]
181                                 <option value="sum" selected="selected">Sum</option>
182                               [% ELSE %]
183                                 <option value="sum">Sum</option>
184                               [% END %]
185                               [% IF search_field.type == "isbn" %]
186                                 <option value="isbn" selected="selected">ISBN</option>
187                               [% ELSE %]
188                                 <option value="isbn">ISBN</option>
189                               [% END %]
190                               [% IF search_field.type == "stdno" %]
191                                 <option value="stdno" selected="selected">Std. Number</option>
192                               [% ELSE %]
193                                 <option value="stdno">Std. Number</option>
194                               [% END %]
195                             </select>
196                       </td>
197                         <td data-order="[% search_field.weight | html %]">
198                             [% IF search_field.mapped_biblios %]
199                                 <input type="text" inputmode="numeric" pattern="[0-9]*" name="search_field_weight" value="[% search_field.weight | html %]" />
200                             [% ELSE %]
201                                 <input type="text" name="search_field_weight" value="">
202                             [% END %]
203                         </td>
204                       <td>
205                         <select name="search_field_staff_client">
206                           [% IF search_field.staff_client %]
207                             <option value="1" selected="selected">Yes</option>
208                             <option value="0">No</option>
209                           [% ELSE %]
210                             <option value="1">Yes</option>
211                             <option value="0" selected="selected">No</option>
212                           [% END %]
213                         </select>
214                       </td>
215                       <td>
216                         <select name="search_field_opac">
217                           [% IF search_field.opac %]
218                             <option value="1" selected="selected">Yes</option>
219                             <option value="0">No</option>
220                           [% ELSE %]
221                             <option value="1">Yes</option>
222                             <option value="0" selected="selected">No</option>
223                           [% END %]
224                         </select>
225                       </td>
226                     </tr>
227                   [% END %]
228                 </tbody>
229               </table>
230             </div>
231             [% FOREACH index IN indexes %]
232                 <div id="mapping_[% index.index_name | html %]">
233                     <table class="mappings" data-index_name="[% index.index_name | html %]" data-ordering="false" id="mapping_[% index.index_name | html %]_table">
234                       <thead>
235                         <tr class="nodrag nodrop">
236                           <th>Search field</th>
237                           <th>Sortable</th>
238                           <th>Facetable</th>
239                           <th>Suggestible</th>
240                           <th>Searchable</th>
241                           <th>Mapping</th>
242                           <th>&nbsp;</th>
243                         </tr>
244                       </thead>
245                       <tbody>
246                         [% FOREACH mapping IN index.mappings %]
247                             [% IF mapping.search_field_mandatory && mapping.search_field_label != loop.next.search_field_label && mapping.search_field_label != loop.prev.search_field_label %]
248                               <tr>
249                                 <td>
250                                   <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
251                                   <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
252                                   [% mapping.search_field_label | html %]
253                                 </td>
254                                 <td>
255                                   [% IF mapping.sort == 0 %]
256                                       <input type="hidden" name="mapping_sort" value="0" readonly />No
257                                   [% ELSE %]
258                                       <input type="hidden" name="mapping_sort" value="1" readonly />Yes
259                                   [% END %]
260                                 </td>
261                                 <td>
262                                   <input type="hidden" name="mapping_facet" value="[% mapping.facet | html %]" readonly />[% IF mapping.facet == 1 %]Yes[% ELSE %]No[% END %]
263                                 </td>
264                                 <td>
265                                   <input type="hidden" name="mapping_suggestible" value="[% mapping.suggestible | html %]" readonly />[% IF mapping.suggestible == 1 %]Yes[% ELSE %]No[% END %]
266                                 </td>
267                                 <td>
268                                   <input type="hidden" name="mapping_search" value="[% mapping.search | html %]" readonly />[% IF mapping.search == 1 %]Yes[% ELSE %]No[% END %]
269                                 </td>
270                                 <td>
271                                     <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
272                                 </td>
273                                 <td>&nbsp;</td>
274                               </tr>
275                             [% ELSE %]
276                               <tr>
277                                 <td>
278                                   <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
279                                   <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
280                                   [% mapping.search_field_label | html %]
281                                 </td>
282                                 <td>
283                                   <select name="mapping_sort">
284                                     [% IF mapping.sort == 0 %]
285                                       <option value="0" selected="selected">No</option>
286                                       <option value="1">Yes</option>
287                                     [% ELSE %]
288                                       <option value="0">No</option>
289                                       <option value="1" selected="selected">Yes</option>
290                                     [% END %]
291                                   </select>
292                                 </td>
293                                 <td>
294                                   [% IF mapping.is_facetable %]
295                                     <select name="mapping_facet">
296                                       [% IF mapping.facet %]
297                                         <option value="0">No</option>
298                                         <option value="1" selected="selected">Yes</option>
299                                       [% ELSE %]
300                                         <option value="0" selected="selected">No</option>
301                                         <option value="1">Yes</option>
302                                       [% END %]
303                                     </select>
304                                   [% ELSE %]
305                                     <input type="hidden" name="mapping_facet" value="0" />
306                                     No
307                                   [% END %]
308                                 </td>
309                                 <td>
310                                   <select name="mapping_suggestible">
311                                     [% IF mapping.suggestible %]
312                                       <option value="0">No</option>
313                                       <option value="1" selected="selected">Yes</option>
314                                     [% ELSE %]
315                                       <option value="0" selected="selected">No</option>
316                                       <option value="1">Yes</option>
317                                     [% END %]
318                                   </select>
319                                 </td>
320                                 <td>
321                                   <select name="mapping_search">
322                                     [% IF mapping.search %]
323                                       <option value="0">No</option>
324                                       <option value="1" selected="selected">Yes</option>
325                                     [% ELSE %]
326                                       <option value="0" selected="selected">No</option>
327                                       <option value="1">Yes</option>
328                                     [% END %]
329                                   </select>
330                                 </td>
331                                 <td>
332                                     <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
333                                 </td>
334                                 [% IF mapping.search_field_mandatory %]
335                                     <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>
336                                 [% ELSE %]
337                                     <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
338                                 [% END %]
339                               </tr>
340                             [% END %]
341                         [% END %]
342                       </tbody>
343                       <tfoot>
344                         <tr class="nodrag nodrop">
345                           <td>
346                             <input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" />
347                             <select data-id="mapping_search_field_name">
348                              [% FOREACH f IN all_search_fields %]
349                                <option value="[% f.name | html %]">[% f.name | html %]</option>
350                              [% END %]
351                             </select>
352                           </td>
353                           <td>
354                             <select data-id="mapping_sort">
355                               <option value="undef">Undef</option>
356                               <option value="0">0</option>
357                               <option value="1">1</option>
358                             </select>
359                           </td>
360                           <td>
361                             <select data-id="mapping_facet">
362                               [% IF mapping.facet %]
363                                 <option value="0">No</option>
364                                 <option value="1" selected="selected">Yes</option>
365                               [% ELSE %]
366                                 <option value="0" selected="selected">No</option>
367                                 <option value="1">Yes</option>
368                               [% END %]
369                             </select>
370                           </td>
371                           <td>
372                             <select data-id="mapping_suggestible">
373                               [% IF mapping.suggestible %]
374                                 <option value="0">No</option>
375                                 <option value="1" selected="selected">Yes</option>
376                               [% ELSE %]
377                                 <option value="0" selected="selected">No</option>
378                                 <option value="1">Yes</option>
379                               [% END %]
380                             </select>
381                           </td>
382                           <td>
383                             <select data-id="mapping_search">
384                               [% IF mapping.search %]
385                                 <option value="0">No</option>
386                                 <option value="1" selected="selected">Yes</option>
387                               [% ELSE %]
388                                 <option value="0" selected="selected">No</option>
389                                 <option value="1">Yes</option>
390                               [% END %]
391                             </select>
392                           </td>
393                           <td><input data-id="mapping_marc_field" type="text" /></td>
394                           <td><a class="btn btn-default btn-xs add"><i class="fa fa-plus"></i> Add</a></td>
395                         </tr>
396                       </tfoot>
397                     </table>
398
399                     [% IF index.index_name == 'biblios' %]
400                         <h3>Facet order</h3>
401                         <div id="facet_[% index.index_name | html %]">
402                             <table>
403                                 <thead>
404                                     <tr>
405                                         <th>Search field</th>
406                                         <th>Label</th>
407                                         <th>Display</th>
408                                     </tr>
409                                 </thead>
410                                 <tbody>
411                                     [% FOREACH f IN facetable_fields %]
412                                         <tr>
413                                             <td>
414                                                 [% f.name | html %]
415                                             </td>
416                                             <td>
417                                                 [% SWITCH f.name %]
418                                                 [% CASE 'author' %]Authors
419                                                 [% CASE 'itype' %]Item Types
420                                                 [% CASE 'location' %]Locations
421                                                 [% CASE 'su-geo' %]Places
422                                                 [% CASE 'title-series' %]Series
423                                                 [% CASE 'subject' %]Topics
424                                                 [% CASE 'ccode' %]Collections
425                                                 [% CASE 'holdingbranch' %]Holding libraries
426                                                 [% CASE 'homebranch' %]Home libraries
427                                                 [% CASE 'ln' %]Language
428                                                 [% CASE %][% f | html %]
429                                                 [% END %]
430                                             </td>
431                                             <td>
432                                                 [% IF f.facet_order %]
433                                                     <input type="checkbox" name="display_facet" value="[% f.name | html %]" checked="checked" />
434                                                 [% ELSE %]
435                                                     <input type="checkbox" name="display_facet" value="[% f.name | html %]" />
436                                                 [% END %]
437                                             </td>
438                                         </tr>
439                                     [% END %]
440                                 </tbody>
441                             </table>
442                         </div>
443                     [% END %]
444                 </div>
445             [% END %]
446         </div>
447         <fieldset class="action">
448             <button class="btn btn-default" type="submit" name="op" value="edit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button>
449             <button class="btn btn-default" type="submit" name="op" value="reset_confirm"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Mappings</button>
450         </fieldset>
451     </form>
452
453             </main>
454         </div> <!-- /.col-sm-10.col-sm-push-2 -->
455
456         <div class="col-sm-2 col-sm-pull-10">
457             <aside>
458                 [% INCLUDE 'admin-menu.inc' %]
459             </aside>
460         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
461      </div> <!-- /.row -->
462
463 [% MACRO jsinclude BLOCK %]
464     [% INCLUDE 'datatables.inc' %]
465     [% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %]
466     [% Asset.js("js/elasticsearch-mappings.js") | $raw %]
467 [% END %]
468
469 [% INCLUDE 'intranet-bottom.inc' %]