Bug 22080: (QA follow-up) Add filters
[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     });
57 </script>
58 <style>
59 a.add, a.delete {
60     cursor: pointer;
61 }
62 </style>
63 </head>
64 <body id="admin_searchengine_mappings" class="admin">
65 [% INCLUDE 'header.inc' %]
66 [% INCLUDE 'prefs-admin-search.inc' %]
67
68 <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>
69
70 <div class="main container-fluid">
71     <div class="row">
72         <div class="col-sm-10 col-sm-push-2">
73             <main>
74
75     [% FOR m IN messages %]
76       <div class="dialog [% m.type | html %]">
77         [% SWITCH m.code %]
78         [% CASE 'error_on_update' %]
79           [% tx("An error occurred when updating mappings: {message}.", { message = m.message }) | html %]
80         [% CASE 'error_on_delete' %]
81           [% t("An error occurred when deleting the existing mappings. Nothing has been changed!") | $raw %]
82           [% tx("(search field {field_name} with mapping {marc_field}.)", { field_name = m.values.field_name, marc_field = m.values.marc_field }) | html %]
83         [% CASE 'invalid_field_weight' %]
84           [% tx("Invalid field weight '{weight}', must be a positive decimal number.", { weight = m.weight }) | html %]
85         [% CASE 'error_on_update_es_mappings' %]
86           [% tx("An error occurred when updating Elasticsearch index mappings: {message}.", { message = m.message }) | html %]
87         [% CASE 'reindex_required' %]
88           [% tx("Index '{index}' needs to be reindexed.", { index = m.index }) | html %]
89         [% CASE 'recreate_required' %]
90           [% tx("Index '{index}' needs to be recreated.", { index = m.index }) | html %]
91         [% CASE 'success_on_update' %]
92           [% t("Mappings updated successfully.") | $raw %]
93         [% CASE 'success_on_reset' %]
94           [% t("Mappings have been reset successfully.") | $raw %]
95         [% CASE %]
96           [% m.code | html %]
97         [% END %]
98       </div>
99     [% END %]
100
101     <h1>Search engine configuration</h1>
102     <div class="dialog message">
103         Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
104
105         <p>Weight: define weight as a positive number. Higher numbers indicate increased relevancy.
106         <strong>Note that fields weighting works only for simple search.</strong></p>
107         <ol>
108           <li>only search fields mapped with biblios can be weighted</li>
109           <li>search will boost/increase weighted field(s) relevancy</li>
110         </ol>
111     </div>
112     [% IF errors %]
113         <div class="dialog alert">
114         Changes have not been applied. Please check the following values:
115           <ul>
116             [% FOREACH e IN errors %]
117                 <li>
118                     [% IF ( e.type == "malformed_mapping" ) %]
119                         <span>The value "[% e.value | html %]" is not supported for mappings</span>
120                     [% ELSIF ( e.type == "no_mapping" ) %]
121                         <span>There is no mapping for the index [% e.value | html %]</span>
122                     [% END %]
123                 </li>
124             [% END %]
125           </ul>
126         </div>
127     [% END %]
128
129     [% IF reset_confirm %]
130         <div class="dialog alert">
131             <h3>The current mappings you see on the screen will be erased and replaced by the mappings in the mappings.yaml file.</h3>
132             <form method="post">
133                 <input type="hidden" name="op" value="reset_confirmed" />
134                 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, reset mappings</button>
135             </form>
136             <br>
137             <form method="post">
138                 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not reset mappings</button>
139             </form>
140         </div>
141     [% END %]
142     <form method="post">
143         <div id="tabs" class="toptabs" style="clear:both">
144             <ul>
145                 <li><a href="#search_fields">Search fields</a></li>
146                 [% FOREACH index IN indexes %]
147                     [% SWITCH index.index_name %]
148                         [% CASE 'biblios' %]<li><a href="#mapping_biblios">Bibliographic records</a></li>
149                         [% CASE 'authorities' %]<li><a href="#mapping_authorities">Authorities</a></li>
150                     [% END %]
151                 [% END %]
152             </ul>
153             <div id="search_fields">
154               <table class="search_fields">
155                 <thead>
156                   <tr>
157                     <th>Name</th>
158                     <th>Label</th>
159                     <th>Type</th>
160                     <th>Weight</th>
161                   </tr>
162                 </thead>
163                 <tbody>
164                   [% FOREACH search_field IN all_search_fields %]
165                     <tr>
166                       <td>
167                         <input type="text" name="search_field_name" value="[% search_field.name | html %]" />
168                       </td>
169                       <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" />
170                       <td>
171                         <select name="search_field_type">
172                           <option value=""></option>
173                           [% IF search_field.type == "string" %]
174                             <option value="string" selected="selected">String</option>
175                           [% ELSE %]
176                             <option value="string">String</option>
177                           [% END %]
178                           [% IF search_field.type == "date" %]
179                             <option value="date" selected="selected">Date</option>
180                           [% ELSE %]
181                             <option value="date">Date</option>
182                           [% END %]
183                           [% IF search_field.type == "number" %]
184                             <option value="number" selected="selected">Number</option>
185                           [% ELSE %]
186                             <option value="number">Number</option>
187                           [% END %]
188                           [% IF search_field.type == "boolean" %]
189                             <option value="boolean" selected="selected">Boolean</option>
190                           [% ELSE %]
191                             <option value="boolean">Boolean</option>
192                           [% END %]
193                           [% IF search_field.type == "sum" %]
194                             <option value="sum" selected="selected">Sum</option>
195                           [% ELSE %]
196                             <option value="sum">Sum</option>
197                           [% END %]
198                           [% IF search_field.type == "isbn" %]
199                             <option value="isbn" selected="selected">ISBN</option>
200                           [% ELSE %]
201                             <option value="isbn">ISBN</option>
202                           [% END %]
203                           [% IF search_field.type == "stdno" %]
204                             <option value="stdno" selected="selected">Std. Number</option>
205                           [% ELSE %]
206                             <option value="stdno">Std. Number</option>
207                           [% END %]
208                         </select>
209                       </td>
210                       <td>
211                       [% IF search_field.mapped_biblios %]
212                         <input type="number" step="0.01" min="0.01" max="999.99" name="search_field_weight" value="[% search_field.weight | html %]" />
213                       [% ELSE %]
214                         <input type="hidden" name="search_field_weight" value="">
215                       [% END %]
216                       </td>
217                     </tr>
218                   [% END %]
219                 </tbody>
220               </table>
221             </div>
222             [% FOREACH index IN indexes %]
223                 <div id="mapping_[% index.index_name | html %]">
224                     <table class="mappings" data-index_name="[% index.index_name | html %]">
225                       <thead>
226                         <tr class="nodrag nodrop">
227                           <th>Search field</th>
228                           <th>Sortable</th>
229                           <th>Facetable</th>
230                           <th>Suggestible</th>
231                           <th>Mapping</th>
232                           <th></th>
233                         </tr>
234                       </thead>
235                       <tbody>
236                         [% FOREACH mapping IN index.mappings %]
237                           <tr>
238                             <td>
239                               <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
240                               <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
241                               [% mapping.search_field_label | html %]
242                             </td>
243                             <td>
244                               <select name="mapping_sort">
245                                 [% IF mapping.sort == 'undef' %]
246                                   <option value="undef" selected="selected">Undef</option>
247                                 [% ELSE %]
248                                   <option value="undef">Undef</option>
249                                 [% END %]
250                                 [% IF mapping.sort == 0 %]
251                                   <option value="0" selected="selected">0</option>
252                                 [% ELSE %]
253                                   <option value="0">0</option>
254                                 [% END %]
255                                 [% IF  mapping.sort == 1 %]
256                                   <option value="1" selected="selected">1</option>
257                                 [% ELSE %]
258                                   <option value="1">1</option>
259                                 [% END %]
260                               </select>
261                             </td>
262                             <td>
263                               <select name="mapping_facet">
264                                 [% IF mapping.facet %]
265                                   <option value="0">No</option>
266                                   <option value="1" selected="selected">Yes</option>
267                                 [% ELSE %]
268                                   <option value="0" selected="selected">No</option>
269                                   <option value="1">Yes</option>
270                                 [% END %]
271                               </select>
272                             </td>
273                             <td>
274                               <select name="mapping_suggestible">
275                                 [% IF mapping.suggestible %]
276                                   <option value="0">No</option>
277                                   <option value="1" selected="selected">Yes</option>
278                                 [% ELSE %]
279                                   <option value="0" selected="selected">No</option>
280                                   <option value="1">Yes</option>
281                                 [% END %]
282                               </select>
283                             </td>
284                             <td>
285                                 <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
286                             </td>
287                             <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
288                           </tr>
289                         [% END %]
290                       </tbody>
291                       <tfoot>
292                         <tr class="nodrag nodrop">
293                           <td>
294                             <input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" />
295                             <select data-id="mapping_search_field_name">
296                              [% FOREACH f IN all_search_fields %]
297                                <option value="[% f.name | html %]">[% f.name | html %]</option>
298                              [% END %]
299                             </select>
300                           </td>
301                           <td>
302                             <select data-id="mapping_sort">
303                               <option value="undef">Undef</option>
304                               <option value="0">0</option>
305                               <option value="1">1</option>
306                             </select>
307                           </td>
308                           <td>
309                             <select data-id="mapping_facet">
310                               [% IF mapping.facet %]
311                                 <option value="0">No</option>
312                                 <option value="1" selected="selected">Yes</option>
313                               [% ELSE %]
314                                 <option value="0" selected="selected">No</option>
315                                 <option value="1">Yes</option>
316                               [% END %]
317                             </select>
318                           </td>
319                           <td>
320                             <select data-id="mapping_suggestible">
321                               [% IF mapping.suggestible %]
322                                 <option value="0">No</option>
323                                 <option value="1" selected="selected">Yes</option>
324                               [% ELSE %]
325                                 <option value="0" selected="selected">No</option>
326                                 <option value="1">Yes</option>
327                               [% END %]
328                             </select>
329                           </td>
330                           <td><input data-id="mapping_marc_field" type="text" /></td>
331                           <td><a class="btn btn-default btn-xs add"><i class="fa fa-plus"></i> Add</a></td>
332                         </tr>
333                       </tfoot>
334                     </table>
335                 </div>
336             [% END %]
337         </div>
338         <p>
339             <button class="btn btn-default" type="submit" name="op" value="edit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button>
340             <button class="btn btn-default" type="submit" name="op" value="reset_confirm"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Mappings</button>
341         </p>
342     </form>
343
344             </main>
345         </div> <!-- /.col-sm-10.col-sm-push-2 -->
346
347         <div class="col-sm-2 col-sm-pull-10">
348             <aside>
349                 [% INCLUDE 'admin-menu.inc' %]
350             </aside>
351         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
352      </div> <!-- /.row -->
353
354 [% INCLUDE 'intranet-bottom.inc' %]