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