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