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