Bug 32002: Make submit button yellow on administration > Did you mean?
[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">Home</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">
77                 <button class="save-all btn btn-primary" type="submit">Save configuration</button>
78                 <a href="/cgi-bin/koha/admin/didyoumean.pl" class="force_reload cancel">Cancel</a>
79             </fieldset>
80         </form>
81
82             </main>
83         </div> <!-- /.col-sm-10.col-sm-push-2 -->
84
85         <div class="col-sm-2 col-sm-pull-10">
86             <aside>
87                 [% INCLUDE 'admin-menu.inc' %]
88             </aside>
89         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
90      </div> <!-- /.row -->
91
92 [% MACRO jsinclude BLOCK %]
93     [% Asset.js("js/admin-menu.js") | $raw %]
94     <script>
95         $(document).ready(function() {
96             $( ".pluginlist" ).sortable();
97             $( ".plugin" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
98                 .find( ".pluginname" )
99                         .addClass( "ui-widget-header ui-corner-all" )
100                         .end()
101                 .find( ".plugindesc" );
102             $(".save-all").on("click",function(e){
103                 e.preventDefault();
104                 yesimeant();
105             });
106             $(".force_reload").on("click",function(e){
107                 e.preventDefault();
108                 window.location.reload(true);
109             });
110         });
111
112         function yesimeant() {
113             var OPACdidyoumean = serialize_plugins('opac');
114
115             var data = "pref_OPACdidyoumean=" + encodeURIComponent(OPACdidyoumean);
116
117             $.ajax({
118                 data: data,
119                 type: 'POST',
120                 url: '/cgi-bin/koha/svc/config/systempreferences/',
121                 success: function () { alert(_("Successfully saved configuration")); },
122             });
123             return false;
124         }
125
126         function serialize_plugins(interface) {
127             var serializedconfig = '[';
128             $('#didyoumean' + interface + ' .pluginlist .plugin').each(function(index) {
129                 var name = $(this).find('.pluginlabel').text();
130                 var enabled = $(this).find('input:checkbox:checked').length ?
131                               ', "enabled": 1' : '';
132                 serializedconfig += '{ "name": "' + name + '"' + enabled + '}, ';
133                 });
134                 serializedconfig = serializedconfig.substring(0, serializedconfig.length - 2);
135                 serializedconfig += ']';
136                 return serializedconfig;
137         }
138     </script>
139 [% END %]
140 [% INCLUDE 'intranet-bottom.inc' %]