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