Bug 31410: Set focus for cursor to Server name when adding a new Z39.50/SRU server
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / z3950servers.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5
6 [% BLOCK ServerType %]
7     [% IF (server.servertype||type) == 'sru' %]
8         <span>SRU</span>
9     [% ELSIF (server.servertype||type) == 'zed' %]
10         <span>Z39.50</span>
11     [% END %]
12 [% END %]
13
14 <title>
15     [% IF op == 'edit' %]
16         Modify [% PROCESS ServerType | remove("</*span>") %] server [% server.servername | html %] &rsaquo; [% END %]
17
18     [% IF op ==  'add' %]
19         New [% PROCESS ServerType | remove("</*span>") %] server &rsaquo; [% END %]
20
21     Z39.50/SRU servers &rsaquo; Administration &rsaquo; Koha
22 </title>
23 [% INCLUDE 'doc-head-close.inc' %]
24 </head>
25
26 <body id="admin_z3950servers" class="admin">
27 [% WRAPPER 'header.inc' %]
28     [% INCLUDE 'z3950-admin-search.inc' %]
29 [% END %]
30
31 [% WRAPPER 'sub-header.inc' %]
32     [% WRAPPER breadcrumbs %]
33         [% WRAPPER breadcrumb_item %]
34             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
35         [% END %]
36
37         [% IF op == 'edit' || op == 'add' %]
38             [% WRAPPER breadcrumb_item %]
39                 <a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a>
40            [% END %]
41         [% END %]
42
43         [% IF op == 'edit' %]
44             [% WRAPPER breadcrumb_item bc_active= 1 %]
45                 <span>Modify [% PROCESS ServerType %] server [% server.servername | html %]</span>
46            [% END %]
47
48         [% ELSIF op == 'add' %]
49             [% WRAPPER breadcrumb_item bc_active= 1 %]
50                 <span>New [% PROCESS ServerType %] server</span>
51            [% END %]
52
53         [% ELSE %]
54             [% WRAPPER breadcrumb_item bc_active= 1 %]
55                 <span>Z39.50/SRU servers</span>
56            [% END %]
57         [% END %]
58     [% END #/ WRAPPER breadcrumbs %]
59 [% END #/ WRAPPER sub-header.inc %]
60
61 <div class="main container-fluid">
62     <div class="row">
63         <div class="col-sm-10 col-sm-push-2">
64             <main>
65
66 [% IF msg_deleted %]
67     <div class="dialog alert">Z39.50/SRU server deleted ([% msg_add | html %])</div>
68 [% ELSIF msg_updated %]
69     <div class="dialog message">Z39.50/SRU server updated ([% msg_add | html %])</div>
70 [% ELSIF msg_added %]
71     <div class="dialog message">Z39.50/SRU server added ([% msg_add | html %])</div>
72 [% ELSIF msg_notfound %]
73     <div class="dialog alert">Error: Server with ID [% msg_add | html %] not found</div>
74 [% END %]
75
76 [% IF ( add_form ) %]
77     <form action="[% script_name | html %]" name="Aform" method="post" id="serverentry">
78         <input type="hidden" name="op" value="add_validated" />
79         <input type="hidden" name="servertype" value="[% server.servertype||type||'zed' | html %]"/>
80         [% IF op == 'edit' %]
81             <h1>Modify [% PROCESS ServerType %] server</h1>
82             <input type="hidden" name="id" value="[% server.id | html %]" />
83         [% ELSE %]
84             <h1>New [% PROCESS ServerType %] server</h1>
85         [% END %]
86         <fieldset class="rows">
87         <ol>
88         <li><label for="name" class="required">Server name: </label>
89             [% IF server.servername %]
90                 <input type="text" name="servername" id="servername" size="65" maxlength="100" value="[% server.servername | html %]" required="required" />
91             [% ELSE %]
92                 <input type="text" name="servername" id="servername" class="focus" size="65" maxlength="100" value="[% server.servername | html %]" required="required" />
93             [% END %]
94              <span class="required">Required</span>
95         </li>
96
97         <li><label for="host" class="required">Hostname: </label> <input type="text" name="host" id="host" size="30" value="[% server.host | html %]" required="required" /> <span class="required">Required</span>
98             [% IF (server.servertype||type) == 'sru' %]
99                 <div class="hint">Includes the domain part, but the path part of the URL should go into Database.</div>
100             [% END %]
101         </li>
102         <li><label for="port" class="required">Port: </label> <input type="text" name="port" id="port" size="5" value="[% server.port | html %]" required="required" /> <span class="required">Required</span>
103         </li>
104         <li><label for="db" class="required">Database: </label> <input type="text" name="db" id="db" value="[% server.db | html %]" required="required" /> <span class="required">Required</span>
105         </li>
106         <li><label for="userid">Userid: </label> <input type="text" name="userid" id="userid" value="[% server.userid | html %]" />
107         </li>
108         <li><label for="password">Password: </label> <input type="text" name="password" id="password" value="[% server.password | html %]" />
109         </li>
110         <li>
111             <label for="checked">Preselected: </label>
112         [% IF ( server.checked ) %]
113             <input type="checkbox" name="checked" id="checked" value="1" checked="checked" />
114         [% ELSE %]
115             <input type="checkbox" name="checked" id="checked" value="1" />
116         [% END %]
117             <span class="hint">Searched by default.</span>
118         </li>
119         <li>
120             <label for="rank">Rank: </label>
121             <input type="text" name="rank" id="rank" size="4" value="[% server.rank | html %]" />
122             <div class="hint">Display order.</div>
123         </li>
124         [% IF (server.servertype||type) == 'zed' %]
125         <li>
126             <label for="attributes">Attributes: </label>
127             <input type="text" name="attributes" id="attributes" size="30" value="[% server.attributes | html %]" />
128             <div class="hint">Additional PQF attributes added to each query.</div>
129         </li>
130         [% END %]
131
132         <li>
133             <label for="syntax">Syntax: </label>
134         <select name="syntax" id="syntax">
135             <option value="UNIMARC">UNIMARC</option>
136             <option value="INTERMARC">INTERMARC</option>
137             <option value="CCF">CCF</option>
138             <option value="USMARC">MARC21/USMARC</option>
139             <option value="UKMARC">UKMARC</option>
140             <option value="NORMARC">NORMARC</option>
141             <option value="LIBRISMARC">LIBRISMARC</option>
142             <option value="DANMARC">DANMARC</option>
143             <option value="FINMARC">FINMARC</option>
144             <option value="CANMARC">CANMARC</option>
145             <option value="SBN">SBN</option>
146             <option value="PICAMARC">PICAMARC</option>
147             <option value="AUSMARC">AUSMARC</option>
148             <option value="IBERMARC">IBERMARC</option>
149             <option value="CATMARC">CATMARC</option>
150             <option value="MALMARC">MALMARC</option>
151         </select>
152             <div class="hint">Z39.50 can send records in various formats. Choose one.</div>
153         </li>
154
155         <li>
156             <label for="encoding">Encoding: </label>
157         <select name="encoding" id="encoding">
158             [% FOREACH enc IN [ 'utf8' 'EUC-KR' 'ISO_5426' 'ISO_6937' 'ISO_8859-1' 'MARC-8' ] %]
159                 <option value="[% enc | html %]">[% enc | html %]</option>
160             [% END %]
161         </select>
162             <div class="hint">Z39.50 can send records in various encodings. Choose one.</div>
163         </li>
164
165         <li>
166             <label for="timeout">Timeout: </label>
167         <input type="text" name="timeout" id="timeout" size="4" value="[% server.timeout | html %]" /> seconds
168             <div class="hint">Enter 0 to disable.</div>
169         </li>
170         <li><label for="recordtype">Record type: </label>
171         <select name="recordtype" id="recordtype">
172             <option value="biblio">Bibliographic</option>
173             <option value="authority">Authority</option>
174         </select>
175         </li>
176         [% IF (server.servertype||type) == 'sru' %]
177         <li>
178         <label for="sru_options">Additional SRU options: </label>
179         <input type="text" name="sru_options" id="sru_options" size="50" value="[% server.sru_options | html %]"/>
180         <div class="hint">Separate options by commas. Example: sru=get,sru_version=1.1. See also http://www.indexdata.com/yaz/doc/zoom.html.</div>
181         </li>
182         <li>
183         <label for="sru_fields">SRU Search fields mapping: </label>
184         <input type="hidden" name="sru_fields" id="sru_fields" value="[% server.sru_fields | html %]" />
185             <input type="text" name="show_sru_fields" id="show_sru_fields" size="100" value="[% server.sru_fields | html %]" disabled="disabled" /> <input type="button" id="modify_sru_fields" value="Modify" />
186         </li>
187         [% END %]
188         <li>
189         <label for="add_xslt">XSLT File(s) for transforming results: </label>
190         <input type="text" name="add_xslt" id="add_xslt" size="100" value="[% server.add_xslt | html %]"/>
191         <div class="hint">Separate multiple filenames by commas.</div>
192         </li>
193
194         </ol>
195         </fieldset>
196
197         <fieldset class="action"><input type="submit" class="btn btn-primary" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/z3950servers.pl">Cancel</a></fieldset>
198     </form>
199 [% END %]
200
201 [% IF op == 'list' %]
202     <div id="toolbar" class="btn-toolbar">
203         <a id="newserver" class="btn btn-default" href="/cgi-bin/koha/admin/z3950servers.pl?op=add&type=zed"><i class="fa fa-plus"></i> New Z39.50 server</a>
204         <a id="newserver" class="btn btn-default" href="/cgi-bin/koha/admin/z3950servers.pl?op=add&type=sru"><i class="fa fa-plus"></i> New SRU server</a>
205     </div>
206     <h1>Z39.50/SRU servers administration</h1>
207     [% IF id %]
208         You searched for record [% id | html %]
209     [% ELSIF searchfield %]
210         You searched for [% searchfield | html %]
211     [% END %]
212
213     <div class="page-section">
214     <table id="serverst">
215
216         <thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Preselected</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>Record type</th><th>Attributes</th><th class="noExport">Actions</th>
217         </tr></thead>
218         <tbody>
219         [% FOREACH loo IN loop %]
220             <tr>
221             <td><a href="/cgi-bin/koha/admin/z3950servers.pl?op=edit&amp;id=[% loo.id | uri %]">[% loo.servername | html %]</a></td><td>[% loo.host | html %]:[% loo.port | html %]</td><td>[% loo.db | html %]</td><td>[% loo.userid | html %]</td><td>[% IF loo.password %]########[% END %]</td><td>[% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %]</td><td>[% loo.rank | html %]</td>
222             <td>[% loo.syntax | html %]</td><td>[% loo.encoding | html %]</td><td>[% loo.timeout | html %]</td>
223             <td>[% IF ( loo.recordtype == 'biblio' )  %]
224                 <span>Bibliographic</span>
225                 [% ELSIF ( loo.recordtype == 'authority' ) %]
226                 <span>Authority</span>
227                 [% END %]
228             </td>
229             <td>[% loo.attributes | html %]</td>
230             <td>
231                 <div class="btn-group dropup">
232                     <a class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown" href="#">
233                         Actions <b class="caret"></b>
234                     </a>
235                     <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
236                         <li><a href="/cgi-bin/koha/admin/z3950servers.pl?op=edit&amp;id=[% loo.id | uri %]"><i class="fa fa-pencil"></i> Edit</a></li>
237                         <li><a href="/cgi-bin/koha/admin/z3950servers.pl?op=add&amp;id=[% loo.id | uri %]"><i class="fa fa-copy"></i> Copy</a></li>
238                         <li><a href="/cgi-bin/koha/admin/z3950servers.pl?op=delete_confirmed&amp;id=[% loo.id | uri %]" class="delete" data-servername="[% loo.servername | html %]"><i class="fa fa-trash"></i> Delete</a></li>
239                     </ul>
240                 </div>
241             </td>
242             </tr>
243         [% END %]
244         </tbody>
245     </table>
246     </div> <!-- /.page-section -->
247 [% END %]
248
249             </main>
250         </div> <!-- /.col-sm-10.col-sm-push-2 -->
251
252         <div class="col-sm-2 col-sm-pull-10">
253             <aside>
254                 [% INCLUDE 'admin-menu.inc' %]
255             </aside>
256         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
257      </div> <!-- /.row -->
258
259 [% MACRO jsinclude BLOCK %]
260     [% Asset.js("js/admin-menu.js") | $raw %]
261     [% IF op == 'list' %]
262         [% INCLUDE 'datatables.inc' %]
263     [% END %]
264
265     <script>
266         [% IF ( add_form ) %]
267             $(document).ready(function(){
268                 // Update selects for syntax, encoding and recordtype
269                 [% IF server %]
270                     $("#syntax").val('[% server.syntax | html %]');
271                     $("#encoding").val('[% server.encoding | html %]');
272                     $("#recordtype").val('[% server.recordtype | html %]');
273                 [% END %]
274                 $( "#serverentry" ).validate({
275                     rules: {
276                         servername: { required: true },
277                         host: { required: true },
278                         port: {
279                             required: true,
280                             number: true
281                         },
282                         db: { required: true },
283                         rank: { number: true },
284                         timeout: { number: true }
285                     }
286                 });
287                 $("#serverentry").submit(function( event ) {
288                     // first test if show_sru_fields exists
289                     if( $('#show_sru_fields').length && $('#show_sru_fields').val()=='' && !confirm( _("No SRU search field mappings have been defined. This means that all field searches will go through the whole record. Continue?"))) {
290                         return false;
291                     }
292                     // copy show_sru_fields to hidden counterpart
293                     $('#sru_fields').val( $('#show_sru_fields').val() );
294                     // enable recordtype to include field in post
295                     $('#recordtype').prop('disabled',false);
296                 });
297                 $("#servername").on("blur",function(){
298                     toUC(this);
299                 });
300                 $("#modify_sru_fields").on("click",function(){
301                     ModMapping();
302                 });
303             });
304             function ModMapping () {
305                 var map= $('#show_sru_fields').val();
306                 var type= $('#recordtype').val();
307                 window.open('/cgi-bin/koha/admin/sru_modmapping.pl?mapping='+map + '&type=' + type,'popup','width=800,height=400,resizable=yes,toolbar=false,scrollbars=yes,top');
308             }
309         [% ELSE %]
310             $(document).ready(function() {
311                 $("#serverst").dataTable($.extend(true, {}, dataTablesDefaults, {
312                     "aoColumnDefs": [
313                         { "aTargets": [-1], "bSortable": false, "bSearchable": false },
314                     ],
315                     "sPaginationType": "full"
316                 }));
317                 $(".delete").on("click",function(e){
318                     var servername = $(this).data("servername");
319                     if( confirm( _("Are you sure you want to delete server %s?").format(servername) ) ) {
320                         return true;
321                     } else {
322                         e.preventDefault();
323                     }
324                 });
325             });
326         [% END %]
327     </script>
328 [% END %]
329 [% INCLUDE 'intranet-bottom.inc' %]