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