Revert "Bug 20073: Move Elasticsearch configs to yaml files and improve the default...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / searchengine / elasticsearch / mappings.tt
1 [% USE Asset %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Administration &rsaquo; Search engine configuration</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 [% Asset.js("lib/jquery/plugins/jquery.tablednd.js") %]
6 <script type="text/javascript">
7     function clean_line( line ) {
8         $(line).find('input[type="text"]').val("");
9         $(line).find('select').find('option:first').attr("selected", "selected");
10     }
11
12     function clone_line( line ) {
13         var new_line = $(line).clone();
14         $(new_line).removeClass("nodrag nodrop");
15         $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html(_("Delete"));
16         $(new_line).find('[data-id]').each( function() {
17             $(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id');
18         } );
19         $(new_line).find("select").each( function() {
20             var attr = $(this).attr('name');
21             var val = $(line).find('[data-id="' + attr + '"]').val();
22             $(this).find('option[value="' + val + '"]').attr("selected", "selected");
23         } );
24         return new_line;
25     }
26
27     $(document).ready(function() {
28         $("#tabs").tabs();
29         $('.delete').click(function() {
30             $(this).parents('tr').remove();
31         });
32
33         $("table.mappings").tableDnD( {
34             onDragClass: "dragClass",
35         } );
36         $('.add').click(function() {
37             var table = $(this).closest('table');
38             var index_name   = $(table).attr('data-index_name');
39             var line = $(this).closest("tr");
40             var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val();
41             if ( marc_field.length > 0 ) {
42                 var new_line = clone_line( line );
43                 new_line.appendTo($('table[data-index_name="'+index_name+'"]>tbody'));
44                 $('.delete').click(function() {
45                     $(this).parents('tr').remove();
46                 });
47                 clean_line(line);
48
49                 $(table).tableDnD( {
50                     onDragClass: "dragClass",
51                 } );
52             }
53         });
54     });
55 </script>
56 <style type="text/css">
57 a.add, a.delete {
58     cursor: pointer;
59 }
60 </style>
61 </head>
62 <body id="admin_searchengine_mappings" class="admin">
63 [% INCLUDE 'header.inc' %]
64 [% INCLUDE 'prefs-admin-search.inc' %]
65
66 <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>
67
68 <div id="doc3" class="yui-t1">
69
70   <div id="bd">
71     <div id="yui-main">
72     <div class="yui-b">
73
74     [% FOR m IN messages %]
75       <div class="dialog [% m.type %]">
76         [% SWITCH m.code %]
77         [% CASE 'error_on_update' %]
78           An error occurred when updating mappings ([% m.message %]).
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 %] with mapping [% m.values.marc_field %].)
82         [% CASE 'success_on_update' %]
83           Mapping updated successfully.
84         [% CASE %]
85           [% m.code %]
86         [% END %]
87       </div>
88     [% END %]
89
90     <h1>Search engine configuration</h1>
91     <div class="warning">
92         Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
93     </div>
94     [% IF errors %]
95         <div class="error">
96         Changes have not been applied. Please check the following values:
97           <ul>
98             [% FOREACH e IN errors %]
99                 <li>
100                     [% IF ( e.type == "malformed_mapping" ) %]
101                         The value "[% e.value %]" is not supported for mappings
102                     [% ELSIF ( e.type == "no_mapping" ) %]
103                         There is no mapping for the index [% e.value %]
104                     [% END %]
105                 </li>
106             [% END %]
107           </ul>
108         </div>
109     [% END %]
110
111     <form method="post">
112         <input type="hidden" name="op" value="edit" />
113         <div id="tabs" class="toptabs" style="clear:both">
114             <ul>
115                 <li><a href="#search_fields">Search fields</a></li>
116                 [% FOREACH index IN indexes %]
117                     [% SWITCH index.index_name %]
118                         [% CASE 'biblios' %]<li><a href="#mapping_biblios">Biblios</a></li>
119                         [% CASE 'authorities' %]<li><a href="#mapping_authorities">Authorities</a></li>
120                     [% END %]
121                 [% END %]
122             </ul>
123             <div id="search_fields">
124               <table class="search_fields">
125                 <thead>
126                   <tr>
127                     <th>Name</th>
128                     <th>Label</th>
129                     <th>Type</th>
130                   </tr>
131                 </thead>
132                 <tbody>
133                   [% FOREACH search_field IN all_search_fields %]
134                     <tr>
135                       <td>
136                         <input type="text" name="search_field_name" value="[% search_field.name %]" />
137                       </td>
138                       <td><input type="text" name="search_field_label" value="[% search_field.label %]" />
139                       <td>
140                         <select name="search_field_type">
141                           <option value=""></option>
142                           [% IF search_field.type == "string" %]
143                             <option value="string" selected="selected">String</option>
144                           [% ELSE %]
145                             <option value="string">String</option>
146                           [% END %]
147                           [% IF search_field.type == "date" %]
148                             <option value="date" selected="selected">Date</option>
149                           [% ELSE %]
150                             <option value="date">Date</option>
151                           [% END %]
152                           [% IF search_field.type == "number" %]
153                             <option value="number" selected="selected">Number</option>
154                           [% ELSE %]
155                             <option value="number">Number</option>
156                           [% END %]
157                           [% IF search_field.type == "boolean" %]
158                             <option value="boolean" selected="selected">Boolean</option>
159                           [% ELSE %]
160                             <option value="boolean">Boolean</option>
161                           [% END %]
162                           [% IF search_field.type == "sum" %]
163                             <option value="sum" selected="selected">Sum</option>
164                           [% ELSE %]
165                             <option value="sum">Sum</option>
166                           [% END %]
167                         </select>
168                       </td>
169                     </tr>
170                   [% END %]
171                 </tbody>
172               </table>
173             </div>
174             [% FOREACH index IN indexes %]
175                 <div id="mapping_[% index.index_name %]">
176                     <table class="mappings" data-index_name="[% index.index_name%]">
177                       <thead>
178                         <tr class="nodrag nodrop">
179                           <th>Search field</th>
180                           <th>Sortable</th>
181                           <th>Facetable</th>
182                           <th>Suggestible</th>
183                           <th>Mapping</th>
184                           <th></th>
185                         </tr>
186                       </thead>
187                       <tbody>
188                         [% FOREACH mapping IN index.mappings %]
189                           <tr>
190                             <td>
191                               <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" />
192                               <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]">
193                               [% mapping.search_field_label %]
194                             </td>
195                             <td>
196                               <select name="mapping_sort">
197                                 [% IF mapping.sort == 'undef' %]
198                                   <option value="undef" selected="selected">Undef</option>
199                                 [% ELSE %]
200                                   <option value="undef">Undef</option>
201                                 [% END %]
202                                 [% IF mapping.sort == 0 %]
203                                   <option value="0" selected="selected">0</option>
204                                 [% ELSE %]
205                                   <option value="0">0</option>
206                                 [% END %]
207                                 [% IF  mapping.sort == 1 %]
208                                   <option value="1" selected="selected">1</option>
209                                 [% ELSE %]
210                                   <option value="1">1</option>
211                                 [% END %]
212                               </select>
213                             </td>
214                             <td>
215                               <select name="mapping_facet">
216                                 [% IF mapping.facet %]
217                                   <option value="0">No</option>
218                                   <option value="1" selected="selected">Yes</option>
219                                 [% ELSE %]
220                                   <option value="0" selected="selected">No</option>
221                                   <option value="1">Yes</option>
222                                 [% END %]
223                               </select>
224                             </td>
225                             <td>
226                               <select name="mapping_suggestible">
227                                 [% IF mapping.suggestible %]
228                                   <option value="0">No</option>
229                                   <option value="1" selected="selected">Yes</option>
230                                 [% ELSE %]
231                                   <option value="0" selected="selected">No</option>
232                                   <option value="1">Yes</option>
233                                 [% END %]
234                               </select>
235                             </td>
236                             <td>
237                                 <input name="mapping_marc_field" type="text" value="[% mapping.marc_field %]" />
238                             </td>
239                             <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
240                           </tr>
241                         [% END %]
242                       </tbody>
243                       <tfoot>
244                         <tr class="nodrag nodrop">
245                           <td>
246                             <input data-id="mapping_index_name" type="hidden" value="[% index.index_name %]" />
247                             <select data-id="mapping_search_field_name">
248                              [% FOREACH f IN all_search_fields %]
249                                <option value="[% f.name %]">[% f.name %]</option>
250                              [% END %]
251                             </select>
252                           </td>
253                           <td>
254                             <select data-id="mapping_sort">
255                               <option value="undef">Undef</option>
256                               <option value="0">0</option>
257                               <option value="1">1</option>
258                             </select>
259                           </td>
260                           <td>
261                             <select data-id="mapping_facet">
262                               [% IF mapping.facet %]
263                                 <option value="0">No</option>
264                                 <option value="1" selected="selected">Yes</option>
265                               [% ELSE %]
266                                 <option value="0" selected="selected">No</option>
267                                 <option value="1">Yes</option>
268                               [% END %]
269                             </select>
270                           </td>
271                           <td>
272                             <select data-id="mapping_suggestible">
273                               [% IF mapping.suggestible %]
274                                 <option value="0">No</option>
275                                 <option value="1" selected="selected">Yes</option>
276                               [% ELSE %]
277                                 <option value="0" selected="selected">No</option>
278                                 <option value="1">Yes</option>
279                               [% END %]
280                             </select>
281                           </td>
282                           <td><input data-id="mapping_marc_field" type="text" /></td>
283                           <td><a class="btn btn-default btn-xs add"><i class="fa fa-plus"></i> Add</a></td>
284                         </tr>
285                       </tfoot>
286                     </table>
287                 </div>
288             [% END %]
289         </div>
290         <p><button class="btn btn-default" type="submit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button></p>
291     </form>
292 </div>
293
294 </div>
295 <div class="yui-b">
296 [% INCLUDE 'admin-menu.inc' %]
297 </div>
298 </div>
299 [% INCLUDE 'intranet-bottom.inc' %]