Bug 13618: Add html filters to all the variables
[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           Mapping updated successfully.
85         [% CASE %]
86           [% m.code | html %]
87         [% END %]
88       </div>
89     [% END %]
90
91     <h1>Search engine configuration</h1>
92     <div class="warning">
93         Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
94     </div>
95     [% IF errors %]
96         <div class="error">
97         Changes have not been applied. Please check the following values:
98           <ul>
99             [% FOREACH e IN errors %]
100                 <li>
101                     [% IF ( e.type == "malformed_mapping" ) %]
102                         The value "[% e.value | html %]" is not supported for mappings
103                     [% ELSIF ( e.type == "no_mapping" ) %]
104                         There is no mapping for the index [% e.value | html %]
105                     [% END %]
106                 </li>
107             [% END %]
108           </ul>
109         </div>
110     [% END %]
111
112     <form method="post">
113         <input type="hidden" name="op" value="edit" />
114         <div id="tabs" class="toptabs" style="clear:both">
115             <ul>
116                 <li><a href="#search_fields">Search fields</a></li>
117                 [% FOREACH index IN indexes %]
118                     [% SWITCH index.index_name %]
119                         [% CASE 'biblios' %]<li><a href="#mapping_biblios">Biblios</a></li>
120                         [% CASE 'authorities' %]<li><a href="#mapping_authorities">Authorities</a></li>
121                     [% END %]
122                 [% END %]
123             </ul>
124             <div id="search_fields">
125               <table class="search_fields">
126                 <thead>
127                   <tr>
128                     <th>Name</th>
129                     <th>Label</th>
130                     <th>Type</th>
131                   </tr>
132                 </thead>
133                 <tbody>
134                   [% FOREACH search_field IN all_search_fields %]
135                     <tr>
136                       <td>
137                         <input type="text" name="search_field_name" value="[% search_field.name | html %]" />
138                       </td>
139                       <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" />
140                       <td>
141                         <select name="search_field_type">
142                           <option value=""></option>
143                           [% IF search_field.type == "string" %]
144                             <option value="string" selected="selected">String</option>
145                           [% ELSE %]
146                             <option value="string">String</option>
147                           [% END %]
148                           [% IF search_field.type == "date" %]
149                             <option value="date" selected="selected">Date</option>
150                           [% ELSE %]
151                             <option value="date">Date</option>
152                           [% END %]
153                           [% IF search_field.type == "number" %]
154                             <option value="number" selected="selected">Number</option>
155                           [% ELSE %]
156                             <option value="number">Number</option>
157                           [% END %]
158                           [% IF search_field.type == "boolean" %]
159                             <option value="boolean" selected="selected">Boolean</option>
160                           [% ELSE %]
161                             <option value="boolean">Boolean</option>
162                           [% END %]
163                           [% IF search_field.type == "sum" %]
164                             <option value="sum" selected="selected">Sum</option>
165                           [% ELSE %]
166                             <option value="sum">Sum</option>
167                           [% END %]
168                           [% IF search_field.type == "isbn" %]
169                             <option value="isbn" selected="selected">ISBN</option>
170                           [% ELSE %]
171                             <option value="isbn">ISBN</option>
172                           [% END %]
173                           [% IF search_field.type == "stdno" %]
174                             <option value="stdno" selected="selected">Std. Number</option>
175                           [% ELSE %]
176                             <option value="stdno">Std. Number</option>
177                           [% END %]
178                         </select>
179                       </td>
180                     </tr>
181                   [% END %]
182                 </tbody>
183               </table>
184             </div>
185             [% FOREACH index IN indexes %]
186                 <div id="mapping_[% index.index_name | html %]">
187                     <table class="mappings" data-index_name="[% index.index_name | html %]">
188                       <thead>
189                         <tr class="nodrag nodrop">
190                           <th>Search field</th>
191                           <th>Sortable</th>
192                           <th>Facetable</th>
193                           <th>Suggestible</th>
194                           <th>Mapping</th>
195                           <th></th>
196                         </tr>
197                       </thead>
198                       <tbody>
199                         [% FOREACH mapping IN index.mappings %]
200                           <tr>
201                             <td>
202                               <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
203                               <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
204                               [% mapping.search_field_label | html %]
205                             </td>
206                             <td>
207                               <select name="mapping_sort">
208                                 [% IF mapping.sort == 'undef' %]
209                                   <option value="undef" selected="selected">Undef</option>
210                                 [% ELSE %]
211                                   <option value="undef">Undef</option>
212                                 [% END %]
213                                 [% IF mapping.sort == 0 %]
214                                   <option value="0" selected="selected">0</option>
215                                 [% ELSE %]
216                                   <option value="0">0</option>
217                                 [% END %]
218                                 [% IF  mapping.sort == 1 %]
219                                   <option value="1" selected="selected">1</option>
220                                 [% ELSE %]
221                                   <option value="1">1</option>
222                                 [% END %]
223                               </select>
224                             </td>
225                             <td>
226                               <select name="mapping_facet">
227                                 [% IF mapping.facet %]
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                               <select name="mapping_suggestible">
238                                 [% IF mapping.suggestible %]
239                                   <option value="0">No</option>
240                                   <option value="1" selected="selected">Yes</option>
241                                 [% ELSE %]
242                                   <option value="0" selected="selected">No</option>
243                                   <option value="1">Yes</option>
244                                 [% END %]
245                               </select>
246                             </td>
247                             <td>
248                                 <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
249                             </td>
250                             <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
251                           </tr>
252                         [% END %]
253                       </tbody>
254                       <tfoot>
255                         <tr class="nodrag nodrop">
256                           <td>
257                             <input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" />
258                             <select data-id="mapping_search_field_name">
259                              [% FOREACH f IN all_search_fields %]
260                                <option value="[% f.name | html %]">[% f.name | html %]</option>
261                              [% END %]
262                             </select>
263                           </td>
264                           <td>
265                             <select data-id="mapping_sort">
266                               <option value="undef">Undef</option>
267                               <option value="0">0</option>
268                               <option value="1">1</option>
269                             </select>
270                           </td>
271                           <td>
272                             <select data-id="mapping_facet">
273                               [% IF mapping.facet %]
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>
283                             <select data-id="mapping_suggestible">
284                               [% IF mapping.suggestible %]
285                                 <option value="0">No</option>
286                                 <option value="1" selected="selected">Yes</option>
287                               [% ELSE %]
288                                 <option value="0" selected="selected">No</option>
289                                 <option value="1">Yes</option>
290                               [% END %]
291                             </select>
292                           </td>
293                           <td><input data-id="mapping_marc_field" type="text" /></td>
294                           <td><a class="btn btn-default btn-xs add"><i class="fa fa-plus"></i> Add</a></td>
295                         </tr>
296                       </tfoot>
297                     </table>
298                 </div>
299             [% END %]
300         </div>
301         <p><button class="btn btn-default" type="submit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button></p>
302     </form>
303 </div>
304
305 </div>
306 <div class="yui-b">
307 [% INCLUDE 'admin-menu.inc' %]
308 </div>
309 </div>
310 [% INCLUDE 'intranet-bottom.inc' %]