Bug 20248: (QA follow-up) Remove unnecessary stuff
[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 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 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         <div id="tabs" class="toptabs" style="clear:both">
129             <ul>
130                 <li><a href="#search_fields">Search fields</a></li>
131                 [% FOREACH index IN indexes %]
132                     [% SWITCH index.index_name %]
133                         [% CASE 'biblios' %]<li><a href="#mapping_biblios">Biblios</a></li>
134                         [% CASE 'authorities' %]<li><a href="#mapping_authorities">Authorities</a></li>
135                     [% END %]
136                 [% END %]
137             </ul>
138             <div id="search_fields">
139               <table class="search_fields">
140                 <thead>
141                   <tr>
142                     <th>Name</th>
143                     <th>Label</th>
144                     <th>Type</th>
145                   </tr>
146                 </thead>
147                 <tbody>
148                   [% FOREACH search_field IN all_search_fields %]
149                     <tr>
150                       <td>
151                         <input type="text" name="search_field_name" value="[% search_field.name | html %]" />
152                       </td>
153                       <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" />
154                       <td>
155                         <select name="search_field_type">
156                           <option value=""></option>
157                           [% IF search_field.type == "string" %]
158                             <option value="string" selected="selected">String</option>
159                           [% ELSE %]
160                             <option value="string">String</option>
161                           [% END %]
162                           [% IF search_field.type == "date" %]
163                             <option value="date" selected="selected">Date</option>
164                           [% ELSE %]
165                             <option value="date">Date</option>
166                           [% END %]
167                           [% IF search_field.type == "number" %]
168                             <option value="number" selected="selected">Number</option>
169                           [% ELSE %]
170                             <option value="number">Number</option>
171                           [% END %]
172                           [% IF search_field.type == "boolean" %]
173                             <option value="boolean" selected="selected">Boolean</option>
174                           [% ELSE %]
175                             <option value="boolean">Boolean</option>
176                           [% END %]
177                           [% IF search_field.type == "sum" %]
178                             <option value="sum" selected="selected">Sum</option>
179                           [% ELSE %]
180                             <option value="sum">Sum</option>
181                           [% END %]
182                           [% IF search_field.type == "isbn" %]
183                             <option value="isbn" selected="selected">ISBN</option>
184                           [% ELSE %]
185                             <option value="isbn">ISBN</option>
186                           [% END %]
187                           [% IF search_field.type == "stdno" %]
188                             <option value="stdno" selected="selected">Std. Number</option>
189                           [% ELSE %]
190                             <option value="stdno">Std. Number</option>
191                           [% END %]
192                         </select>
193                       </td>
194                     </tr>
195                   [% END %]
196                 </tbody>
197               </table>
198             </div>
199             [% FOREACH index IN indexes %]
200                 <div id="mapping_[% index.index_name | html %]">
201                     <table class="mappings" data-index_name="[% index.index_name | html %]">
202                       <thead>
203                         <tr class="nodrag nodrop">
204                           <th>Search field</th>
205                           <th>Sortable</th>
206                           <th>Facetable</th>
207                           <th>Suggestible</th>
208                           <th>Mapping</th>
209                           <th></th>
210                         </tr>
211                       </thead>
212                       <tbody>
213                         [% FOREACH mapping IN index.mappings %]
214                           <tr>
215                             <td>
216                               <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
217                               <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
218                               [% mapping.search_field_label | html %]
219                             </td>
220                             <td>
221                               <select name="mapping_sort">
222                                 [% IF mapping.sort == 'undef' %]
223                                   <option value="undef" selected="selected">Undef</option>
224                                 [% ELSE %]
225                                   <option value="undef">Undef</option>
226                                 [% END %]
227                                 [% IF mapping.sort == 0 %]
228                                   <option value="0" selected="selected">0</option>
229                                 [% ELSE %]
230                                   <option value="0">0</option>
231                                 [% END %]
232                                 [% IF  mapping.sort == 1 %]
233                                   <option value="1" selected="selected">1</option>
234                                 [% ELSE %]
235                                   <option value="1">1</option>
236                                 [% END %]
237                               </select>
238                             </td>
239                             <td>
240                               <select name="mapping_facet">
241                                 [% IF mapping.facet %]
242                                   <option value="0">No</option>
243                                   <option value="1" selected="selected">Yes</option>
244                                 [% ELSE %]
245                                   <option value="0" selected="selected">No</option>
246                                   <option value="1">Yes</option>
247                                 [% END %]
248                               </select>
249                             </td>
250                             <td>
251                               <select name="mapping_suggestible">
252                                 [% IF mapping.suggestible %]
253                                   <option value="0">No</option>
254                                   <option value="1" selected="selected">Yes</option>
255                                 [% ELSE %]
256                                   <option value="0" selected="selected">No</option>
257                                   <option value="1">Yes</option>
258                                 [% END %]
259                               </select>
260                             </td>
261                             <td>
262                                 <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
263                             </td>
264                             <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
265                           </tr>
266                         [% END %]
267                       </tbody>
268                       <tfoot>
269                         <tr class="nodrag nodrop">
270                           <td>
271                             <input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" />
272                             <select data-id="mapping_search_field_name">
273                              [% FOREACH f IN all_search_fields %]
274                                <option value="[% f.name | html %]">[% f.name | html %]</option>
275                              [% END %]
276                             </select>
277                           </td>
278                           <td>
279                             <select data-id="mapping_sort">
280                               <option value="undef">Undef</option>
281                               <option value="0">0</option>
282                               <option value="1">1</option>
283                             </select>
284                           </td>
285                           <td>
286                             <select data-id="mapping_facet">
287                               [% IF mapping.facet %]
288                                 <option value="0">No</option>
289                                 <option value="1" selected="selected">Yes</option>
290                               [% ELSE %]
291                                 <option value="0" selected="selected">No</option>
292                                 <option value="1">Yes</option>
293                               [% END %]
294                             </select>
295                           </td>
296                           <td>
297                             <select data-id="mapping_suggestible">
298                               [% IF mapping.suggestible %]
299                                 <option value="0">No</option>
300                                 <option value="1" selected="selected">Yes</option>
301                               [% ELSE %]
302                                 <option value="0" selected="selected">No</option>
303                                 <option value="1">Yes</option>
304                               [% END %]
305                             </select>
306                           </td>
307                           <td><input data-id="mapping_marc_field" type="text" /></td>
308                           <td><a class="btn btn-default btn-xs add"><i class="fa fa-plus"></i> Add</a></td>
309                         </tr>
310                       </tfoot>
311                     </table>
312                 </div>
313             [% END %]
314         </div>
315         <p>
316             <button class="btn btn-default" type="submit" name="op" value="edit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button>
317             <button class="btn btn-default" type="submit" name="op" value="reset_confirm"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Mappings</button>
318         </p>
319     </form>
320 </div>
321
322 </div>
323 <div class="yui-b">
324 [% INCLUDE 'admin-menu.inc' %]
325 </div>
326 </div>
327 [% INCLUDE 'intranet-bottom.inc' %]