Bug 20589: Add field boosting and use query_string fields parameter
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / didyoumean.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% BLOCK pluginlist %]
5 <div class="pluginlist">
6 [% FOREACH plugin IN plugins %]
7     <div class="plugin">
8         <div class="pluginname">
9             [% IF plugin.enabled %]<input type="checkbox" checked="checked" id="checkbox_[% type | html %][% plugin.name | html %]">[% ELSE %]<input type="checkbox" id="checkbox_[% type | html %][% plugin.name | html %]">[% END %]
10             <label class='pluginlabel' for="checkbox_[% type | html %][% plugin.name | html %]">[% plugin.name | html %]</label></div>
11         <div class="plugindesc">
12         [% SWITCH plugin.name %]
13         [% CASE 'AuthorityFile' %]
14             Suggest authorities which are relevant to the term the user searched for.
15         [% CASE 'ExplodedTerms' %]
16             Suggest that patrons expand their searches to include
17             broader/narrower/related terms.
18         [% CASE 'LibrisSpellcheck' %]
19             Use the LIBRIS spellcheck API.
20         [% END %]
21         </div>
22     </div>
23 [% END %]
24 </div>
25 [% END %]
26 [% INCLUDE 'doc-head-open.inc' %]
27 <title>Koha &rsaquo; Administration &rsaquo; Did you mean?</title>
28 [% INCLUDE 'doc-head-close.inc' %]
29 </head>
30
31 <body id="admin_didyoumean" class="admin">
32 [% INCLUDE 'header.inc' %]
33 [% INCLUDE 'prefs-admin-search.inc' %]
34 <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; Did you mean?</div>
35
36 <div class="main container-fluid">
37     <div class="row">
38         <div class="col-sm-10 col-sm-push-2">
39             <main>
40
41         <h3>Did you mean?</h3>
42         <noscript><div class="dialog alert"><strong>Please enable Javascript:</strong>
43             Configuring 'Did you mean?' plugins requires Javascript. If
44             you are unable to use Javascript, you may be able to enter the
45             configuration (which is stored in JSON in the OPACdidyoumean and
46             INTRAdidyoumean system preferences) in the Local Preferences tab in
47             the system preference editor, but this is unsupported, not
48             recommended, and likely will not work.</div></noscript>
49         <div id="didyoumeanlegend">
50             Please put the 'Did you mean?' plugins in order by significance, from
51             most significant to least significant, and check the box to enable those
52             plugins that you want to use. (NOTE: 'Did you mean?' functionality
53             is not yet enabled on the staff client)
54         </div>
55         <form action="/cgi-bin/koha/admin/didyoumean.pl" method="post">
56             <fieldset id="didyoumeanopac">
57                 <legend>OPAC</legend>
58                 [% PROCESS pluginlist plugins=OPACpluginlist type='opac' %]
59             </fieldset>
60             <fieldset id="didyoumeanintranet">
61                 <legend>Intranet</legend>
62                 [% PROCESS pluginlist plugins=INTRApluginlist type='intranet' %]
63             </fieldset>
64             <fieldset class="action"><button class="save-all submit" type="submit">Save configuration</button> <a href="/cgi-bin/koha/admin/didyoumean.pl" class="force_reload cancel">Cancel</a></fieldset>
65         </form>
66
67             </main>
68         </div> <!-- /.col-sm-10.col-sm-push-2 -->
69
70         <div class="col-sm-2 col-sm-pull-10">
71             <aside>
72                 [% INCLUDE 'admin-menu.inc' %]
73             </aside>
74         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
75      </div> <!-- /.row -->
76
77 [% MACRO jsinclude BLOCK %]
78     [% Asset.js("js/admin-menu.js") | $raw %]
79     <script>
80         $(document).ready(function() {
81             $( ".pluginlist" ).sortable();
82             $( ".plugin" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
83                 .find( ".pluginname" )
84                         .addClass( "ui-widget-header ui-corner-all" )
85                         .end()
86                 .find( ".plugindesc" );
87             $(".save-all").on("click",function(e){
88                 e.preventDefault();
89                 yesimeant();
90             });
91             $(".force_reload").on("click",function(e){
92                 e.preventDefault();
93                 window.location.reload(true);
94             });
95         });
96
97         function yesimeant() {
98             var OPACdidyoumean = serialize_plugins('opac');
99             var INTRAdidyoumean = serialize_plugins('intranet');
100
101             var data = "pref_OPACdidyoumean=" + encodeURIComponent(OPACdidyoumean) + "&pref_INTRAdidyoumean=" + encodeURIComponent(INTRAdidyoumean);
102
103             $.ajax({
104                 data: data,
105                 type: 'POST',
106                 url: '/cgi-bin/koha/svc/config/systempreferences/',
107                 success: function () { alert(_("Successfully saved configuration")); },
108             });
109             return false;
110         }
111
112         function serialize_plugins(interface) {
113             var serializedconfig = '[';
114             $('#didyoumean' + interface + ' .pluginlist .plugin').each(function(index) {
115                 var name = $(this).find('.pluginlabel').text();
116                 var enabled = $(this).find('input:checkbox:checked').length ?
117                               ', "enabled": 1' : '';
118                 serializedconfig += '{ "name": "' + name + '"' + enabled + '}, ';
119                 });
120                 serializedconfig = serializedconfig.substring(0, serializedconfig.length - 2);
121                 serializedconfig += ']';
122                 return serializedconfig;
123         }
124     </script>
125 [% END %]
126 [% INCLUDE 'intranet-bottom.inc' %]