From 7748facfa5e2e9f149ba85af8d988a113ced6177 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 16 Jul 2014 16:38:57 +0200 Subject: [PATCH] Bug 6536: SRU servers administration This patch makes adjustments in admin/z3950servers in order to insert, edit and delete SRU server records. Test plan: Add, edit, copy and delete SRU server. Check if adding, editing, copying and deleting Z3950 servers still works. Signed-off-by: Giuseppe Angilella Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- admin/z3950servers.pl | 16 ++--- .../prog/en/modules/admin/z3950servers.tt | 65 +++++++++++++++---- 2 files changed, 62 insertions(+), 19 deletions(-) diff --git a/admin/z3950servers.pl b/admin/z3950servers.pl index c13c95f5eb..b7a80c24d9 100755 --- a/admin/z3950servers.pl +++ b/admin/z3950servers.pl @@ -36,6 +36,7 @@ use Koha::Database; my $input = new CGI; my $op = $input->param('op') || 'list'; my $id = $input->param('id') || 0; +my $type = $input->param('type') || ''; my $searchfield = ''; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -58,29 +59,28 @@ if( $op eq 'delete_confirmed' && $id ) { my $server = $schema->resultset('Z3950server')->find($id); if ( $server ) { $server->delete; - $template->param( msg_deleted => 1, msg_add => $server->name ); + $template->param( msg_deleted => 1, msg_add => $server->servername ); } else { $template->param( msg_notfound => 1, msg_add => $id ); } $id = 0; } elsif ( $op eq 'add_validated' ) { my @fields=qw/host port db userid password rank syntax encoding timeout - recordtype checked/; + recordtype checked servername servertype sru_options sru_fields + add_xslt/; my $formdata = _form_data_hashref( $input, \@fields ); - #add name from servername (an input with name="name" gave problems) - $formdata->{name} = $input->param('servername'); if( $id ) { my $server = $schema->resultset('Z3950server')->find($id); if ( $server ) { $server->update( $formdata ); - $template->param( msg_updated => 1, msg_add => $formdata->{name} ); + $template->param( msg_updated => 1, msg_add => $formdata->{servername} ); } else { $template->param( msg_notfound => 1, msg_add => $id ); } $id = 0; } else { $schema->resultset('Z3950server')->create( $formdata ); - $template->param( msg_added => 1, msg_add => $formdata->{name} ); + $template->param( msg_added => 1, msg_add => $formdata->{servername} ); } } else { #use searchfield only in remaining operations @@ -94,7 +94,7 @@ if ( $op eq 'add' || $op eq 'edit' ) { $data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id; delete $data->[0]->{id} if @$data && $op eq 'add'; #cloning record $template->param( add_form => 1, server => @$data? $data->[0]: undef, - op => $op ); + op => $op, type => $op eq 'add'? lc $type: '' ); } else { $data = ServerSearch( $schema, $id, $searchfield ); $template->param( loop => \@$data, searchfield => $searchfield, id => $id, @@ -107,7 +107,7 @@ output_html_with_http_headers $input, $cookie, $template->output; sub ServerSearch { #find server(s) by id or name my ( $schema, $id, $searchstring )= @_; my $rs = $schema->resultset('Z3950server')->search( - $id ? { id => $id }: { name => { like => $searchstring.'%' } }, + $id ? { id => $id }: { servername => { like => $searchstring.'%' } }, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' } ); return [ $rs->all ]; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt index 9657a0edac..218d8da852 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt @@ -1,7 +1,16 @@ [% INCLUDE 'doc-head-open.inc' %] + +[% BLOCK ServerType %] + [% IF (server.servertype||type) == 'sru' %] + SRU + [% ELSIF (server.servertype||type) == 'zed' %] + Z39.50 + [% END %] +[% END %] + Koha › Administration › Z39.50 servers -[% IF op == 'edit' %] › Modify Z39.50 server [% server.name %][% END %] -[% IF op == 'add' %] › New Z39.50 server[% END %] +[% IF op == 'edit' %] › Modify [% PROCESS ServerType %] server [% server.servername %][% END %] +[% IF op == 'add' %] › New [% PROCESS ServerType %] server[% END %] [% INCLUDE 'doc-head-close.inc' %] @@ -20,6 +29,10 @@ $("#encoding").val('[% server.encoding %]'); $("#recordtype").val('[% server.recordtype %]'); [% END %] + // Disable recordtype (and default to bib) for non-Z3950 servers until auth is supported + [% UNLESS (server.servertype||type) == 'zed' %] + $("#recordtype").prop('disabled',true); + [% END %] $( "#serverentry" ).validate({ rules: { servername: { required: true }, @@ -33,7 +46,17 @@ timeout: { number: true } } }); + $("#serverentry").submit(function( event ) { + // copy show_sru_fields to hidden counterpart + $('#sru_fields').val( $('#show_sru_fields').val() ); + // enable recordtype to include field in post + $('#recordtype').prop('disabled',false); + }); }); + function ModMapping () { + var map= $('#show_sru_fields').val(); + window.open('/cgi-bin/koha/admin/sru_modmapping.pl?mapping='+map,'popup','width=800,height=400,resizable=no,toolbar=false,scrollbars=no,top'); + } [% ELSE %] $(document).ready(function() { $("#serverst").dataTable($.extend(true, {}, dataTablesDefaults, { @@ -61,8 +84,8 @@
@@ -83,15 +106,16 @@ [% IF ( add_form ) %]
+ [% IF op == 'edit' %] -

Modify Z39.50 server

+

Modify [% PROCESS ServerType %] server

[% ELSE %] -

New Z39.50 server

+

New [% PROCESS ServerType %] server

[% END %]
    -
  1. Required
  2. +
  3. Required
  4. @@ -151,6 +175,24 @@ + [% IF (server.servertype||type) == 'sru' %] +
  5. + + + ( Separate options by commas. Example: sru=get,sru_version=1.1. See also http://www.indexdata.com/yaz/doc/zoom.html.) +
  6. +
  7. + + + +
  8. + [% END %] +
  9. + + + ( Separate files by commas.) +
  10. +
@@ -160,7 +202,8 @@ [% IF op == 'list' %]

Z39.50 servers administration

[% IF id %] @@ -178,15 +221,15 @@ [% ELSE %] [% END %] - [% loo.name %][% loo.host %]:[% loo.port %][% loo.db %][% loo.userid %][% IF loo.password %]########[% END %][% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %][% loo.rank %] -[% loo.syntax %][% loo.encoding %][% loo.timeout %] + [% loo.servername %][% loo.host %]:[% loo.port %][% loo.db %][% loo.userid %][% IF loo.password %]########[% END %][% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %][% loo.rank %] + [% loo.syntax %][% loo.encoding %][% loo.timeout %] [% IF ( loo.recordtype == 'biblio' ) %] Bibliographic [% ELSIF ( loo.recordtype == 'authority' ) %] Authority [% END %] - Edit Copy Delete + Edit Copy Delete [% END %] -- 2.39.5