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