Bug 18316: Change search field weight field to decimal
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / searchengine / elasticsearch / mappings.tt
index 90d5b35..bb758bd 100644 (file)
@@ -1,8 +1,10 @@
+[% USE raw %]
+[% USE Asset %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Administration &rsaquo; Elastic Search mappings</title>
+<title>Koha &rsaquo; Administration &rsaquo; Search engine configuration</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.tablednd.js"></script>
-<script type="text/javascript">
+[% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %]
+<script>
     function clean_line( line ) {
         $(line).find('input[type="text"]').val("");
         $(line).find('select').find('option:first').attr("selected", "selected");
@@ -52,7 +54,7 @@
         });
     });
 </script>
-<style type="text/css">
+<style>
 a.add, a.delete {
     cursor: pointer;
 }
@@ -60,46 +62,54 @@ a.add, a.delete {
 </head>
 <body id="admin_searchengine_mappings" class="admin">
 [% INCLUDE 'header.inc' %]
-[% INCLUDE 'cat-search.inc' %]
+[% INCLUDE 'prefs-admin-search.inc' %]
 
 <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>
 
-<div id="doc3" class="yui-t1">
-
-  <div id="bd">
-    <div id="yui-main">
-    <div class="yui-b">
+<div class="main container-fluid">
+    <div class="row">
+        <div class="col-sm-10 col-sm-push-2">
+            <main>
 
     [% FOR m IN messages %]
-      <div class="dialog [% m.type %]">
+      <div class="dialog [% m.type | html %]">
         [% SWITCH m.code %]
         [% CASE 'error_on_update' %]
-          An error occurred when updateing mappings ([% m.message %]).
+          An error occurred when updating mappings ([% m.message | html %]).
         [% CASE 'error_on_delete' %]
           An error occurred when deleting the existing mappings. Nothing has been changed!
-          (search field [% m.values.field_name %] with mapping [% m.values.marc_field %].)
+          (search field [% m.values.field_name | html %] with mapping [% m.values.marc_field | html %].)
         [% CASE 'success_on_update' %]
-          Mapping updated successfully.
+          Mappings updated successfully.
+        [% CASE 'success_on_reset' %]
+          Mappings have been reset successfully.
         [% CASE %]
-          [% m.code %]
+          [% m.code | html %]
         [% END %]
       </div>
     [% END %]
 
     <h1>Search engine configuration</h1>
-    <div class="warning">
-        Warning: Any modification in these configurations will need a total reindexation to be fully taken into account !
+    <div class="dialog message">
+        Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
+
+        <p>Weight: define weight as a positive number. Higher numbers indicate increased relevancy.
+        <strong>Note that fields weighting works only for simple search.</strong></p>
+        <ol>
+          <li>only search fields mapped with biblios can be weighted</li>
+          <li>search will boost/increase weighted field(s) relevancy</li>
+        </ol>
     </div>
     [% IF errors %]
-        <div class="error">
-        Errors occurred, Modifications does not apply. Please check following values:
+        <div class="dialog alert">
+        Changes have not been applied. Please check the following values:
           <ul>
             [% FOREACH e IN errors %]
                 <li>
                     [% IF ( e.type == "malformed_mapping" ) %]
-                        The value "[% e.value %]" is not supported for mappings
+                        The value "[% e.value | html %]" is not supported for mappings
                     [% ELSIF ( e.type == "no_mapping" ) %]
-                        There is no mapping for the index [% e.value %]
+                        There is no mapping for the index [% e.value | html %]
                     [% END %]
                 </li>
             [% END %]
@@ -107,14 +117,26 @@ a.add, a.delete {
         </div>
     [% END %]
 
+    [% IF reset_confirm %]
+        <div class="dialog alert">
+            <h3>The current mappings you see on the screen will be erased and replaced by the mappings in the mappings.yaml file.</h3>
+            <form method="post">
+                <input type="hidden" name="op" value="reset_confirmed" />
+                <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, reset mappings</button>
+            </form>
+            <br>
+            <form method="post">
+                <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not reset mappings</button>
+            </form>
+        </div>
+    [% END %]
     <form method="post">
-        <input type="hidden" name="op" value="edit" />
         <div id="tabs" class="toptabs" style="clear:both">
             <ul>
                 <li><a href="#search_fields">Search fields</a></li>
                 [% FOREACH index IN indexes %]
                     [% SWITCH index.index_name %]
-                        [% CASE 'biblios' %]<li><a href="#mapping_biblios">Biblios</a></li>
+                        [% CASE 'biblios' %]<li><a href="#mapping_biblios">Bibliographic records</a></li>
                         [% CASE 'authorities' %]<li><a href="#mapping_authorities">Authorities</a></li>
                     [% END %]
                 [% END %]
@@ -126,15 +148,16 @@ a.add, a.delete {
                     <th>Name</th>
                     <th>Label</th>
                     <th>Type</th>
+                    <th>Weight</th>
                   </tr>
                 </thead>
                 <tbody>
                   [% FOREACH search_field IN all_search_fields %]
                     <tr>
                       <td>
-                        <input type="text" name="search_field_name" value="[% search_field.name %]" />
+                        <input type="text" name="search_field_name" value="[% search_field.name | html %]" />
                       </td>
-                      <td><input type="text" name="search_field_label" value="[% search_field.label %]" />
+                      <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" />
                       <td>
                         <select name="search_field_type">
                           <option value=""></option>
@@ -163,16 +186,33 @@ a.add, a.delete {
                           [% ELSE %]
                             <option value="sum">Sum</option>
                           [% END %]
+                          [% IF search_field.type == "isbn" %]
+                            <option value="isbn" selected="selected">ISBN</option>
+                          [% ELSE %]
+                            <option value="isbn">ISBN</option>
+                          [% END %]
+                          [% IF search_field.type == "stdno" %]
+                            <option value="stdno" selected="selected">Std. Number</option>
+                          [% ELSE %]
+                            <option value="stdno">Std. Number</option>
+                          [% END %]
                         </select>
                       </td>
+                      <td>
+                      [% IF search_field.mapped_biblios %]
+                        <input type="number" step="0.01" min="0" max="999" name="search_field_weight" value="[% search_field.weight %]" />
+                      [% ELSE %]
+                        <input type="hidden" name="search_field_weight" value="">
+                      [% END %]
+                      </td>
                     </tr>
                   [% END %]
                 </tbody>
               </table>
             </div>
             [% FOREACH index IN indexes %]
-                <div id="mapping_[% index.index_name %]">
-                    <table class="mappings" data-index_name="[% index.index_name%]">
+                <div id="mapping_[% index.index_name | html %]">
+                    <table class="mappings" data-index_name="[% index.index_name | html %]">
                       <thead>
                         <tr class="nodrag nodrop">
                           <th>Search field</th>
@@ -187,9 +227,9 @@ a.add, a.delete {
                         [% FOREACH mapping IN index.mappings %]
                           <tr>
                             <td>
-                              <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" />
-                              <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]">
-                              [% mapping.search_field_label %]
+                              <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
+                              <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
+                              [% mapping.search_field_label | html %]
                             </td>
                             <td>
                               <select name="mapping_sort">
@@ -219,7 +259,7 @@ a.add, a.delete {
                                   <option value="0" selected="selected">No</option>
                                   <option value="1">Yes</option>
                                 [% END %]
-                              </selected>
+                              </select>
                             </td>
                             <td>
                               <select name="mapping_suggestible">
@@ -230,22 +270,22 @@ a.add, a.delete {
                                   <option value="0" selected="selected">No</option>
                                   <option value="1">Yes</option>
                                 [% END %]
-                              </selected>
+                              </select>
                             </td>
                             <td>
-                                <input name="mapping_marc_field" type="text" value="[% mapping.marc_field %]" />
+                                <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
                             </td>
-                            <td><a class="btn btn-mini delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
+                            <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
                           </tr>
                         [% END %]
                       </tbody>
                       <tfoot>
                         <tr class="nodrag nodrop">
                           <td>
-                            <input data-id="mapping_index_name" type="hidden" value="[% index.index_name %]" />
+                            <input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" />
                             <select data-id="mapping_search_field_name">
                              [% FOREACH f IN all_search_fields %]
-                               <option value="[% f.name %]">[% f.name %]</option>
+                               <option value="[% f.name | html %]">[% f.name | html %]</option>
                              [% END %]
                             </select>
                           </td>
@@ -265,7 +305,7 @@ a.add, a.delete {
                                 <option value="0" selected="selected">No</option>
                                 <option value="1">Yes</option>
                               [% END %]
-                            </selected>
+                            </select>
                           </td>
                           <td>
                             <select data-id="mapping_suggestible">
@@ -276,23 +316,30 @@ a.add, a.delete {
                                 <option value="0" selected="selected">No</option>
                                 <option value="1">Yes</option>
                               [% END %]
-                            </selected>
+                            </select>
                           </td>
                           <td><input data-id="mapping_marc_field" type="text" /></td>
-                          <td><a class="btn btn-mini add"><i class="fa fa-plus"></i> Add</a></td>
+                          <td><a class="btn btn-default btn-xs add"><i class="fa fa-plus"></i> Add</a></td>
                         </tr>
                       </tfoot>
                     </table>
                 </div>
             [% END %]
         </div>
-        <p><button class="btn" type="submit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button></p>
+        <p>
+            <button class="btn btn-default" type="submit" name="op" value="edit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button>
+            <button class="btn btn-default" type="submit" name="op" value="reset_confirm"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Mappings</button>
+        </p>
     </form>
-</div>
 
-</div>
-<div class="yui-b">
-[% INCLUDE 'admin-menu.inc' %]
-</div>
-</div>
+            </main>
+        </div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+        <div class="col-sm-2 col-sm-pull-10">
+            <aside>
+                [% INCLUDE 'admin-menu.inc' %]
+            </aside>
+        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
+     </div> <!-- /.row -->
+
 [% INCLUDE 'intranet-bottom.inc' %]