Bug 23777: Use To.json in preferences.tt
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / preferences.tt
blobae22e006ce15a1e5fd1c40771a2b20656b7450aa
1 [% USE raw %]
2 [% USE To %]
3 [% USE Asset %]
4 [% USE Koha %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Administration &rsaquo; System preferences</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% Asset.css("css/preferences.css") | $raw %]
10 [% Asset.css("lib/jquery/plugins/multiple-select/multiple-select.css") | $raw %]
11 [% Asset.css("css/humanmsg.css") | $raw %]
12 [% Asset.css("lib/codemirror/codemirror.css") | $raw %]
13 </head>
14 <body id="admin_preferences" class="admin">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'prefs-admin-search.inc' %]
18 <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; System preferences</div>
20 <div class="main container-fluid">
21     <div class="row">
22         <div class="col-sm-10 col-sm-push-2">
23             <main>
25     [% IF ( jump_not_found ) %]
26     <h2>System preferences</h2>
27     <div class="dialog alert">
28         Could not find a system preference named <code>[% jumpfield | html %]</code>.
29     </div>
30     [% END %]
31     [% IF ( search_not_found ) %]
32     <div class="dialog alert">
33         No system preferences matched your search for: <strong>[% searchfield | html %]</strong>
34     </div>
35     [% ELSIF searchfield %]
36         <h1>You searched for: [% searchfield | html %]</h1>
37     [% END %]
38     [% FOREACH TAB IN TABS %]
39     <div class="prefs-tab">
40     <h2>[% TAB.tab_title | html %] preferences</h2>
41     <form action="/cgi-bin/koha/admin/preferences.pl" method="post">
42         [% UNLESS ( searchfield ) %]<div id="toolbar"><button class="save-all submit" type="submit">Save all [% TAB.tab_title | html %] preferences</button></div>[% END %]
43         <input type="hidden" name="op" value="save" />
44         <input type="hidden" name="tab" value="[% TAB.tab_id | html %]" />
46             [% FOREACH LINE IN TAB.LINES %]
47             [% IF ( LINE.is_group_title ) %]
48             [% UNLESS ( loop.first ) %]</tbody></table>[% END %]
49             <h3>[% LINE.title | html %]</h3>
50             <table class="preferences">
51             <thead><tr><th>Preference</th><th>Value</th></tr></thead>
52             [% UNLESS ( loop.last ) %]<tbody>[% END %]
53             [% ELSE %]
54             [% IF ( loop.first ) %]<table class="preferences"><thead><tr><th>Preference</th><th>Value</th></tr></thead><tbody>[% END %]
55             <tr class="name-row">
56                 <td class="name-cell">
57                     <code>
58                         [% FOREACH NAME IN LINE.NAMES %]
59                                                 <label for="pref_[% NAME.name | html %]">
60                                                         [% IF ( NAME.jumped ) %]
61                                                         <span class="term" id="jumped">[% NAME.name | html %]</span>
62                             [% ELSIF ( NAME.highlighted ) %]
63                                                         <span class="term">[% NAME.name | html %]</span>
64                                                         [% ELSE %]
65                                                         [% NAME.name | html %]
66                                                         [% END %]
68                             [% IF NAME.overridden %]
69                                 <span class="overridden" title="The system preference [% NAME.name | html %] may have been overridden from this value by one or more virtual hosts.">
70                                     [Overridden]
71                                 </span>
72                             [% END %]
73                                                 </label>
74                         [% UNLESS ( loop.last ) %]<br />[% END %]
75                         [% END %]
76                     </code>
77                 </td>
78                 <td><div>
79                     [% FOREACH CHUNK IN LINE.CHUNKS %]
80                     [% IF ( CHUNK.type_text ) %]
81                     [% CHUNK.contents | $raw %]
82                     [% ELSIF ( CHUNK.type_input ) %]
83                     <input type="[%IF CHUNK.input_type %][% CHUNK.input_type | html %][% ELSE %]text[% END %]" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "short" | html %]" value="[% CHUNK.value | html %]" autocomplete="off" /> [% IF ( CHUNK.dateinput ) %]<span class="hint">[% INCLUDE 'date-format.inc' %]</span>[% END %]
84                     [% ELSIF ( CHUNK.type_select ) %]
85                     <select name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "choice" | html %]">
86                         [% FOREACH CHOICE IN CHUNK.CHOICES.sort('value') %]
87                         [% IF ( CHOICE.selected ) %]
88                         <option value="[% CHOICE.value | html %]" selected="selected">
89                         [% ELSE %]
90                         <option value="[% CHOICE.value | html %]">
91                         [% END %]
92                             [% CHOICE.text | html %]
93                         </option>
94                         [% END %]
95                     </select>
96                     [% ELSIF ( CHUNK.type_multiple ) %]
97                     <select name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "choice" | html %]" multiple="multiple">
98                         [% FOREACH CHOICE IN CHUNK.CHOICES %][% IF ( CHOICE.selected ) %]<option value="[% CHOICE.value | html %]" selected="selected">[% ELSE %]<option value="[% CHOICE.value | html %]">[% END %][% CHOICE.text | html %]</option>[% END %]
99                     </select>
100                     [% ELSIF ( CHUNK.type_textarea )%]
101                         [% IF ( CHUNK.syntax == "text/html" && Koha.Preference('UseWYSIWYGinSystemPreferences') ) %]
102                             <textarea name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "short" | html %] mce" rows="20" cols="60">[% CHUNK.value | html %]</textarea>
103                         [% ELSE %]
104                             <a class="expand-textarea" id="expand_[% CHUNK.name | html %]" data-target="[% CHUNK.name | html %]" data-syntax="[% CHUNK.syntax | html %]" href="#">Click to edit</a>
105                             <textarea style="display:none" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "short" | html %] codemirror" rows="10" cols="40">[% CHUNK.value | html %]</textarea>
106                             <a class="collapse-textarea" id="collapse_[% CHUNK.name | html %]" data-target="[% CHUNK.name | html %]" data-syntax="[% CHUNK.syntax | html %]" style="display:none" href="#">Click to collapse</br></a>
107                         [% END %]
108                     [% ELSIF ( CHUNK.type_languages ) %]
109                         <ul class="sortable">
110                             [% FOREACH language IN CHUNK.languages %]
111                                 [% IF ( language.plural ) %]
112                                     <li>
113                                         [% IF ( language.native_description ) %]
114                                             [% language.native_description | html %]
115                                         [% ELSE %]
116                                             [% language.rfc4646_subtag | html %]
117                                         [% END %]
118                                         [% IF language.sublanguages_loop.size > 0 %]
119                                             <ul>
120                                                 [% FOREACH sublanguages_loo IN language.sublanguages_loop %]
121                                                     <li>
122                                                         <label for="pref_[% CHUNK.name | html %]_[% sublanguages_loo.rfc4646_subtag | html %]">[% sublanguages_loo.native_description | html %] [% sublanguages_loo.script_description | html %] [% sublanguages_loo.region_description | html %] [% sublanguages_loo.variant_description | html %]([% sublanguages_loo.rfc4646_subtag | html %])</label>
123                                                         [% IF ( sublanguages_loo.enabled ) %]
124                                                             <input value="[% sublanguages_loo.rfc4646_subtag | html %]" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]_[% sublanguages_loo.rfc4646_subtag | html %]" type="checkbox" checked="checked" class="preference preference-checkbox"/>
125                                                         [% ELSE %]
126                                                             <input value="[% sublanguages_loo.rfc4646_subtag | html %]" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]_[% sublanguages_loo.rfc4646_subtag | html %]" type="checkbox" class="preference preference-checkbox"/>
127                                                         [% END %]
128                                                     </li>
129                                                 [% END # FOREACH sublanguages %]
130                                             </ul>
131                                         [% END %]
132                                     </li>
133                                 [% ELSE %]
134                                     <li>
135                                         <label for="pref_[% CHUNK.name | html %]_[% language.rfc4646_subtag | html %]">[% language.native_description | html %] ([% language.rfc4646_subtag | html %])</label>
136                                         [% IF ( language.group_enabled ) %]
137                                             <input value="[% language.rfc4646_subtag | html %]" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]_[% language.rfc4646_subtag | html %]" type="checkbox" checked="checked" class="preference preference-checkbox"/>
138                                         [% ELSE %]
139                                             <input value="[% language.rfc4646_subtag | html %]" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]_[% language.rfc4646_subtag | html %]" type="checkbox" class="preference preference-checkbox"/>
140                                         [% END %]
141                                     </li>
142                                 [% END # IF language.plural %]
143                             [% END # FOREACH language %]
144                         </ul> <!-- / ul.sortable -->
145                     [% END %]
146                     [% END %]
147                 </div></td>
148             </tr>
149             [% IF ( loop.last ) %]</tbody></table>[% END %]
150             [% END %]
151         [% END %]
152         <fieldset class="action"><button class="save-all submit" type="submit">Save all [% TAB.tab_title | html %] preferences</button> <a href="/cgi-bin/koha/admin/preferences.pl" class="force_reload cancel">Cancel</a></fieldset>
153     </form>
154     </div>
155     [% END %]
157             </main>
158         </div> <!-- /.col-sm-10.col-sm-push-2 -->
160         <div class="col-sm-2 col-sm-pull-10">
161             <aside>
162                 [% INCLUDE 'prefs-menu.inc' %]
163             </aside>
164         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
165      </div> <!-- /.row -->
167 [% MACRO jsinclude BLOCK %]
168     [% INCLUDE 'datatables.inc' %]
169     [% Asset.js("lib/hc-sticky.js") | $raw %]
170     [% Asset.js("lib/jquery/plugins/multiple-select/jquery.multiple.select.js") | $raw %]
171     [% Asset.js( "lib/codemirror/codemirror-compressed.js" ) | $raw %]
172     [% Asset.js( "lib/codemirror/css.min.js" ) | $raw %]
173     [% Asset.js( "lib/codemirror/javascript.min.js" ) | $raw %]
174     [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
175     [% Asset.js( "lib/codemirror/yaml.min.js" ) | $raw %]
176     <script>
177         var Sticky;
178         $(document).ready(function(){
179             [% UNLESS ( searchfield ) %]
180                 Sticky = $("#toolbar");
181                 Sticky.hcSticky({
182                     stickTo: "main",
183                     stickyClass: "floating"
184                 });
185             [% END %]
186             $("select[multiple='multiple']").multipleSelect( {
187                 placeholder: _("Please select ..."),
188                 selectAllText: _("Select all"),
189                 allSelected: _("All selected"),
190                 countSelected: _("# of % selected"),
191                 noMatchesFound: _("No matches found")
192             } );
193             $(".force_reload").on("click",function(e){
194                 e.preventDefault();
195                 window.location.reload(true);
196             });
198         });
199         // This is here because of its dependence on template variables, everything else should go in js/pages/preferences.js - jpw
200         var to_highlight = "[% To.json( searchfield ) | $raw %]";
201         var search_jumped = [% IF ( search_jumped ) %]true[% ELSE %]false[% END %];
202         var MSG_NOTHING_TO_SAVE = _("Nothing to save");
203         var MSG_SAVING = _("Saving...");
204         var MSG_SAVED_PREFERENCE = _("Saved preference %s");
205         var MSG_MODIFIED = _("modified");
206         var MSG_MADE_CHANGES = _("You have made changes to system preferences.");
207         var MSG_CLICK_TO_EXPAND = _("Click to expand this section");
208         var MSG_CLICK_TO_COLLAPSE = _("Click to collapse this section");
209         var MSG_INTERNAL_SERVER_ERROR = _( "Internal Server Error, please reload the page" );
210         var MSG_SESSION_TIMED_OUT = _( "You need to log in again, your session has timed out" );
211         var MSG_DATA_NOT_SAVED = _( "Error; your data might not have been saved" );
212         var MSG_LOADING = _( "Loading..." );
213         var MSG_ALL_VALUE_WARN = _("Note: _ALL_ value will override all other values");
214         var MSG_UPD_LOC_FORMAT_WARN = _("The following values are not formatted correctly:");
215         var MSG_INVALID = _( "Error: presence of invalid data prevent saving. Please make the corrections and try again." );
216     </script>
217     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
218     [% Asset.js("js/ajax.js") | $raw %]
219     [% Asset.js("js/pages/preferences.js") | $raw %]
220     [%# Add WYSIWYG editor for htmlarea system preferences %]
221     [% INCLUDE 'wysiwyg-systempreferences.inc' %]
222 [% END %]
224 [% INCLUDE 'intranet-bottom.inc' %]