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