Bugzilla – Attachment 81035 Details for
Bug 15836
Labels: Offer configuration option for splitting call numbers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15836: UI changes
Bug-15836-UI-changes.patch (text/plain), 41.44 KB, created by
Chris Cormack
on 2018-10-23 20:16:01 UTC
(
hide
)
Description:
Bug 15836: UI changes
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2018-10-23 20:16:01 UTC
Size:
41.44 KB
patch
obsolete
>From 230e104f724f4c5004f530f2d568be8100d6a03e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 21 Jun 2018 13:43:55 -0300 >Subject: [PATCH] Bug 15836: UI changes >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >The script admin/classsources.pl has been adjusted to follow usual >patterns used in other Koha scripts. >$op can be add_source, add_source_validate, etc. >Deletion steps have been removed (there is a JS confirmation box) to >simplify both script and template. > >Signed-off-by: Christian Stelzenmüller <christian.stelzenmueller@bsz-bw.de> >Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> >--- > admin/classsources.pl | 444 +++++++++--------- > .../data/mysql/atomicupdate/bug_15836.perl | 2 +- > .../prog/en/modules/admin/classsources.tt | 357 ++++++++------ > 3 files changed, 440 insertions(+), 363 deletions(-) > >diff --git a/admin/classsources.pl b/admin/classsources.pl >index 1dd0710402..fa3b0506ad 100755 >--- a/admin/classsources.pl >+++ b/admin/classsources.pl >@@ -1,6 +1,7 @@ > #! /usr/bin/perl > # > # Copyright 2007 LibLime >+# Copyright 2018 Koha Development Team > # > # This file is part of Koha. > # >@@ -26,274 +27,257 @@ use C4::Output; > use C4::Koha; > use C4::ClassSource; > use C4::ClassSortRoutine; >+use Koha::ClassSources; >+use Koha::ClassSortRules; >+use Koha::ClassSplitRules; > > my $script_name = "/cgi-bin/koha/admin/classsources.pl"; > >-my $input = new CGI; >-my $op = $input->param('op') || ''; >-my $source_code = $input->param('class_source'); >-my $rule_code = $input->param('sort_rule'); >-my $sort_routine = $input->param('sort_routine'); >-my ($template, $loggedinuser, $cookie) >- = get_template_and_user({template_name => "admin/classsources.tt", >- query => $input, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => {parameters => 'manage_classifications'}, >- debug => 1, >- }); >- >-$template->param(script_name => $script_name); >-$template->param($op => 1) if $op; >-my $description = $input->param('description'); >-my $used = $input->param('used'); >-my $display_lists = 0; >-if ($op eq "add_source") { >- add_class_source_form($template); >-} elsif ($op eq "add_source_confirmed") { >- add_class_source($template, >- $source_code, >- $description, >- $used eq "used" ? 1 : 0, >- $rule_code); >- $display_lists = 1; >-} elsif ($op eq "delete_source") { >- delete_class_source_form($template, $source_code); >-} elsif ($op eq "delete_source_confirmed") { >- delete_class_source($template, $source_code); >- $display_lists = 1; >-} elsif ($op eq "edit_source") { >- edit_class_source_form($template, $source_code); >-} elsif ($op eq "edit_source_confirmed") { >- edit_class_source($template, >- $source_code, >- $description, >- $used eq "used" ? 1 : 0, >- $rule_code); >- $display_lists = 1; >-} elsif ($op eq "add_sort_rule") { >- add_class_sort_rule_form($template); >-} elsif ($op eq "add_sort_rule_confirmed") { >- add_class_sort_rule($template, >- $rule_code, >- $description, >- $sort_routine); >- $display_lists = 1; >-} elsif ($op eq "delete_sort_rule") { >- delete_sort_rule_form($template, $rule_code); >-} elsif ($op eq "delete_sort_rule_confirmed") { >- delete_sort_rule($template, $rule_code); >- $display_lists = 1; >-} elsif ($op eq "edit_sort_rule") { >- edit_class_sort_rule_form($template, $rule_code); >-} elsif ($op eq "edit_sort_rule_confirmed") { >- edit_class_sort_rule($template, >- $rule_code, >- $description, >- $sort_routine); >- $display_lists = 1; >-} else { >- $display_lists = 1; >-} >- >-if ($display_lists) { >- $template->param(display_lists => 1); >- class_source_list($template); >- class_sort_rule_list($template); >-} >- >-output_html_with_http_headers $input, $cookie, $template->output; >+my $input = new CGI; >+my $op = $input->param('op') || 'list'; >+my $cn_source = $input->param('cn_source'); >+my $class_sort_rule = $input->param('class_sort_rule'); >+my $class_split_rule = $input->param('class_split_rule'); >+my $sort_routine = $input->param('sort_routine'); >+my $split_routine = $input->param('split_routine'); >+my $split_regex = $input->param('split_regex'); >+my $description = $input->param('description'); >+my $used = $input->param('used'); >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "admin/classsources.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { parameters => 'manage_classifications' }, >+ debug => 1, >+ } >+); > >-exit 0; >+my @messages; >+$template->param( script_name => $script_name ); > >-sub add_class_source_form { >- my ($template) = @_; >+if ( $op eq "add_source" ) { >+ my $class_source = >+ $cn_source ? Koha::ClassSources->find($cn_source) : undef; > $template->param( >- class_source_form => 1, >- confirm_op => "add_source_confirmed", >- used => 0 >+ class_source => $class_source, >+ sort_rules => scalar Koha::ClassSortRules->search, >+ split_rules => scalar Koha::ClassSplitRules->search, > ); >- get_sort_rule_codes($template, ''); > } >+elsif ( $op eq "add_source_validate" ) { >+ my $class_source = Koha::ClassSources->find($cn_source); >+ if ($class_source) { >+ $class_source->set( >+ { >+ description => $description, >+ used => ( $used eq 'used' ? 1 : 0 ), >+ class_sort_rule => $class_sort_rule, >+ class_split_rule => $class_split_rule, >+ } >+ ); >+ eval { $class_source->store; }; >+ if ($@) { >+ push @messages, >+ { type => 'error', code => 'error_on_update_source' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_update_source' }; >+ } > >-sub add_class_source { >- my ($template, $source_code, $description, $used, $sort_rule) = @_; >- my $success = AddClassSource($source_code, $description, $used, $sort_rule); >- if ($success > 0) { >- $template->param(added_source => $source_code); >- } else { >- $template->param(failed_add_source => $source_code); > } >-} >- >-sub edit_class_source_form { >- my ($template, $source_code) = @_; >- >- my $source = GetClassSource($source_code); >- $template->param( >- class_source_form => 1, >- edit_class_source => 1, >- class_source => $source_code, >- confirm_op => "edit_source_confirmed", >- description => $source->{'description'}, >- used => $source->{'used'}, >- ); >+ else { >+ $class_source = Koha::ClassSource->new( >+ { >+ cn_source => $cn_source, >+ description => $description, >+ used => ( $used eq 'used' ? 1 : 0 ), >+ class_sort_rule => $class_sort_rule, >+ class_split_rule => $class_split_rule, >+ } >+ ); >+ eval { $class_source->store; }; >+ if ($@) { >+ push @messages, >+ { type => 'error', code => 'error_on_insert_source' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_insert_source' }; >+ } >+ } > >- get_sort_rule_codes($template, $source->{'class_sort_rule'}); >+ $op = 'list'; > } >+elsif ( $op eq "delete_source_confirmed" ) { >+ my $class_source = Koha::ClassSources->find($cn_source); >+ my $deleted = eval { $class_source->delete }; >+ if ( $@ or not $deleted ) { >+ push @messages, { type => 'error', code => 'error_on_delete_source' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_delete_source' }; >+ } > >-sub edit_class_source { >- my ($template, $source_code, $description, $used, $sort_rule) = @_; >- ModClassSource($source_code, $description, $used, $sort_rule); >- $template->param(edited_source => $source_code); >+ $op = 'list'; > } >- >- >-sub delete_class_source_form { >- my ($template, $source_code) = @_; >+elsif ( $op eq "add_sort_rule" ) { >+ my $sort_rule = >+ $class_sort_rule ? Koha::ClassSortRules->find($class_sort_rule) : undef; > $template->param( >- delete_class_source_form => 1, >- confirm_op => "delete_source_confirmed", >- class_source => $source_code, >+ sort_rule => $sort_rule, >+ sort_routines => get_class_sort_routines(), > ); > } >+elsif ( $op eq "add_sort_rule_validate" ) { >+ my $sort_rule = Koha::ClassSortRules->find($class_sort_rule); >+ if ($sort_rule) { >+ $sort_rule->set( >+ { description => $description, sort_routine => $sort_routine } ); >+ eval { $sort_rule->store; }; >+ if ($@) { >+ push @messages, >+ { type => 'error', code => 'error_on_update_sort_rule' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_update_sort_rule' }; >+ } > >-sub delete_class_source { >- my ($template, $source_code) = @_; >- DelClassSource($source_code); >- $template->param(deleted_source => $source_code); >+ } >+ else { >+ $sort_rule = Koha::ClassSortRule->new( >+ { >+ class_sort_rule => $class_sort_rule, >+ description => $description, >+ sort_routine => $sort_routine, >+ } >+ ); >+ eval { $sort_rule->store; }; >+ if ($@) { >+ push @messages, >+ { type => 'error', code => 'error_on_insert_sort_rule' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_insert_sort_rule' }; >+ } >+ } >+ $op = 'list'; > } >- >-sub get_sort_rule_codes { >- my ($template, $current_rule) = @_; >- >- my $sort_rules = GetClassSortRules(); >- >- my @sort_rules = (); >- foreach my $sort_rule (sort keys %$sort_rules) { >- my $sort_rule = $sort_rules->{$sort_rule}; >- push @sort_rules, { >- rule => $sort_rule->{'class_sort_rule'}, >- description => $sort_rule->{'description'}, >- selected => $sort_rule->{'class_sort_rule'} eq $current_rule ? 1 : 0 >- }; >+elsif ( $op eq "delete_sort_rule" ) { >+ my $sort_rule = Koha::ClassSortRules->find($class_sort_rule); >+ my $deleted = eval { $sort_rule->delete }; >+ if ( $@ or not $deleted ) { >+ push @messages, >+ { type => 'error', code => 'error_on_delete_sort_rule' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_delete_sort_rule' }; > } >- $template->param(rules_dropdown => \@sort_rules); >- >+ $op = 'list'; > } >- >-sub add_class_sort_rule_form { >- my ($template) = @_; >+elsif ( $op eq "add_split_rule" ) { >+ my $split_rule = >+ $class_split_rule >+ ? Koha::ClassSplitRules->find($class_split_rule) >+ : undef; > $template->param( >- sort_rule_form => 1, >- confirm_op => "add_sort_rule_confirmed" >+ split_rule => $split_rule, >+ split_routines => get_class_split_routines(), > ); >- get_class_sort_routines($template, ""); > } >+elsif ( $op eq "add_split_rule_validate" ) { >+ my $split_rule = Koha::ClassSplitRules->find($class_split_rule); >+ if ($split_rule) { >+ $split_rule->set( >+ { >+ description => $description, >+ split_routine => $split_routine, >+ split_regex => >+ ( $split_routine eq 'RegEx' ? $split_regex : '' ), >+ } >+ ); >+ eval { $split_rule->store; }; >+ if ($@) { >+ push @messages, >+ { type => 'error', code => 'error_on_update_split_rule' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_update_split_rule' }; >+ } > >-sub add_class_sort_rule { >- my ($template, $rule_code, $description, $sort_routine) = @_; >- my $success = AddClassSortRule($rule_code, $description, $sort_routine); >- if ($success > 0) { >- $template->param(added_rule => $rule_code); >- } else { >- $template->param(failed_add_rule => $rule_code); > } >-} >- >-sub delete_sort_rule_form { >- my ($template, $rule_code) = @_; >- >- my @sources = GetSourcesForSortRule($rule_code); >- if ($#sources == -1) { >- $template->param( >- delete_sort_rule_form => 1, >- confirm_op => "delete_sort_rule_confirmed", >- sort_rule => $rule_code, >- ); >- } else { >- $template->param( >- delete_sort_rule_impossible => 1, >- sort_rule => $rule_code >+ else { >+ $split_rule = Koha::ClassSplitRule->new( >+ { >+ class_split_rule => $class_split_rule, >+ description => $description, >+ split_routine => $split_routine, >+ split_regex => >+ ( $split_routine eq 'RegEx' ? $split_regex : '' ), >+ } > ); >+ eval { $split_rule->store; }; >+ if ($@) { >+ warn $@; >+ push @messages, >+ { type => 'error', code => 'error_on_insert_split_rule' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_insert_split_rule' }; >+ } > } >+ $op = 'list'; > } >- >-sub delete_sort_rule { >- my ($template, $rule_code) = @_; >- DelClassSortRule($rule_code); >- $template->param(deleted_rule => $rule_code); >+elsif ( $op eq "delete_split_rule" ) { >+ my $split_rule = Koha::ClassSplitRules->find($class_split_rule); >+ my $deleted = eval { $split_rule->delete }; >+ if ( $@ or not $deleted ) { >+ push @messages, >+ { type => 'error', code => 'error_on_delete_split_rule' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_delete_split_rule' }; >+ } >+ $op = 'list'; > } > >-sub edit_class_sort_rule_form { >- my ($template, $rule_code) = @_; >- >- my $rule = GetClassSortRule($rule_code); >+if ( $op eq 'list' ) { >+ my $class_sources = Koha::ClassSources->search; >+ my $sort_rules = Koha::ClassSortRules->search; >+ my $split_rules = Koha::ClassSplitRules->search; > $template->param( >- sort_rule_form => 1, >- edit_sort_rule => 1, >- confirm_op => "edit_sort_rule_confirmed", >- sort_rule => $rule_code, >- description => $rule->{'description'}, >- sort_routine => $rule->{'sort_routine'} >+ class_sources => $class_sources, >+ sort_rules => $sort_rules, >+ split_rules => $split_rules, > ); >+} > >- get_class_sort_routines($template, $rule->{'sort_routine'}); >+$template->param( op => $op, messages => \@messages, ); >+output_html_with_http_headers $input, $cookie, $template->output; > >-} >+exit 0; > > sub get_class_sort_routines { >- my ($template, $current_routine) = @_; >- > my @sort_routines = GetSortRoutineNames(); >- my @sort_form = (); >- >- foreach my $sort_routine (sort @sort_routines) { >- push @sort_form, { >- routine => $sort_routine, >- selected => $sort_routine eq $current_routine ? 1 : 0 >- }; >- } >- $template->param(routines_dropdown => \@sort_form); >- >+ return \@sort_routines; > } > >-sub edit_class_sort_rule { >- my ($template, $rule_code, $description, $sort_routine) = @_; >- ModClassSortRule($rule_code, $description, $sort_routine); >- $template->param(edited_rule => $rule_code); >-} >- >-sub class_source_list { >- my ($template) = @_; >- my $sources = GetClassSources(); >- >- my @sources = (); >- foreach my $cn_source (sort keys %$sources) { >- my $source = $sources->{$cn_source}; >- push @sources, { >- code => $source->{'cn_source'}, >- description => $source->{'description'}, >- used => $source->{'used'}, >- sortrule => $source->{'class_sort_rule'} >- }; >- } >- $template->param(class_sources => \@sources); >-} >- >-sub class_sort_rule_list { >- >- my ($template) = @_; >- my $sort_rules = GetClassSortRules(); >- >- my @sort_rules = (); >- foreach my $sort_rule (sort keys %$sort_rules) { >- my $sort_rule = $sort_rules->{$sort_rule}; >- push @sort_rules, { >- rule => $sort_rule->{'class_sort_rule'}, >- description => $sort_rule->{'description'}, >- sort_routine => $sort_rule->{'sort_routine'} >- }; >- } >- $template->param(class_sort_rules => \@sort_rules); >+sub get_class_split_routines { >+ my @split_routines = qw( >+ Dewey >+ Generic >+ LCC >+ RegEx >+ ); >+ return \@split_routines; > } >diff --git a/installer/data/mysql/atomicupdate/bug_15836.perl b/installer/data/mysql/atomicupdate/bug_15836.perl >index 069b7503f8..edfe012709 100644 >--- a/installer/data/mysql/atomicupdate/bug_15836.perl >+++ b/installer/data/mysql/atomicupdate/bug_15836.perl >@@ -25,7 +25,7 @@ if( CheckVersion( $DBversion ) ) { > $dbh->do(q| > INSERT INTO class_split_rules(class_split_rule, description, split_routine) > VALUES >- ('dewey', 'Default sorting rules for DDC', 'dewey'), >+ ('dewey', 'Default sorting rules for DDC', 'Dewey'), > ('lcc', 'Default sorting rules for LCC', 'LCC'), > ('generic', 'Generic call number sorting rules', 'Generic') > |); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt >index 5882915cde..7e27bc050d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt >@@ -3,21 +3,17 @@ > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Classification sources >-[% IF ( class_source_form ) %] >-› >- [% IF ( edit_class_source ) %]Modify classification source[% ELSE %]Add classification source[% END %] >-[% END %] >-[% IF ( sort_rule_form ) %] >+[% IF op == 'add_source' %] > › >- [% IF ( edit_sort_rule ) %]Modify filing rule[% ELSE %]Add filing rule[% END %] >-[% END %] >-[% IF ( delete_class_source_form ) %] >- › Confirm deletion of classification source [% class_source | html %] >-[% ELSIF ( delete_sort_rule_form ) %] >- › Confirm deletion of filing rule [% sort_rule | html %] >-[% ELSIF ( delete_sort_rule_impossible ) %] >- › Cannot delete filing rule [% sort_rule | html %] >+ [% IF class_source %]Modify classification source[% ELSE %]Add classification source[% END %] >+[% ELSIF op == 'add_sort_rule' %] >+› >+ [% IF sort_rule %]Modify filing rule[% ELSE %]Add filing rule[% END %] >+[% ELSIF op == 'add_split_rule' %] >+› >+ [% IF split_rule %]Modify splitting rule[% ELSE %]Add splitting rule[% END %] > [% END %] >+ > </title> > [% INCLUDE 'doc-head-close.inc' %] > </head> >@@ -30,18 +26,12 @@ > <a href="/cgi-bin/koha/mainpage.pl">Home</a> > › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> > › <a href="/cgi-bin/koha/admin/classsources.pl">Classification sources</a> >-[% IF ( class_source_form ) %] >-› [% IF ( edit_class_source ) %]Modify classification source[% ELSE %]Add classification source[% END %] >-[% END %] >-[% IF ( sort_rule_form ) %] >-› [% IF ( edit_sort_rule ) %]Modify filing rule[% ELSE %]Add filing rule[% END %] >-[% END %] >-[% IF ( delete_class_source_form ) %] >-› Confirm deletion of classification source <span class="ex">'[% class_source | html %]'</span> >-[% ELSIF ( delete_sort_rule_form ) %] >-› Confirm deletion of filing rule <span class="ex">'[% sort_rule | html %]'</span> >-[% ELSIF ( delete_sort_rule_impossible ) %] >-› Cannot delete filing rule <span class="ex">'[% sort_rule | html %]'</span> >+[% IF op == 'add_source' %] >+› [% IF class_source %]Modify classification source[% ELSE %]Add classification source[% END %] >+[% ELSIF op == 'add_sort_rule' %] >+› [% IF sort_rule %]Modify filing rule[% ELSE %]Add filing rule[% END %] >+[% ELSIF op == 'add_split_rule' %] >+› [% IF split_rule %]Modify splitting rule[% ELSE %]Add splitting rule[% END %] > [% END %] > </div> > >@@ -50,47 +40,107 @@ > <div class="col-sm-10 col-sm-push-2"> > <main> > >-[% IF ( class_source_form ) %] >- [% IF ( edit_class_source ) %] >+[% FOR m IN messages %] >+ <div class="dialog [% m.type %]"> >+ [% SWITCH m.code %] >+ [% CASE 'error_on_update_source' %] >+ An error occurred when updating this classification source. >+ [% CASE 'success_on_update_source' %] >+ Classification source updated successfully. >+ [% CASE 'error_on_insert_source' %] >+ An error occurred when adding this classification source. Perhaps the code already exists? >+ [% CASE 'success_on_insert_source' %] >+ Classification source added successfully. >+ [% CASE 'error_on_delete_source' %] >+ An error occurred when deleting this classification source. >+ [% CASE 'success_on_delete_source' %] >+ Classification source deleted successfully. >+ [% CASE 'error_on_update_sort_rule' %] >+ An error occurred when adding this filing rule. Perhaps the code already exists? >+ [% CASE 'success_on_update_sort_rule' %] >+ Filing rule updated successfully. >+ [% CASE 'error_on_insert_sort_rule' %] >+ An error occurred when adding this filing rule. Perhaps the code already exists? >+ [% CASE 'success_on_insert_sort_rule' %] >+ Filing rule added successfully. >+ [% CASE 'error_on_delete_sort_rule' %] >+ An error occurred when deleting this filing rule. Perhaps it is used by at least one classification source? >+ [% CASE 'success_on_delete_sort_rule' %] >+ Filing rule deleted successfully. >+ [% CASE 'error_on_update_split_rule' %] >+ An error occurred when adding this splitting rule. Perhaps the code already exists? >+ [% CASE 'success_on_update_split_rule' %] >+ Splitting rule updated successfully. >+ [% CASE 'error_on_insert_split_rule' %] >+ An error occurred when adding this splitting rule. Perhaps the code already exists? >+ [% CASE 'success_on_insert_split_rule' %] >+ Splitting rule added successfully. >+ [% CASE 'error_on_delete_split_rule' %] >+ An error occurred when deleting this splitting rule. Perhaps it is used by at least one classification source? >+ [% CASE 'success_on_delete_split_rule' %] >+ Splitting rule deleted successfully. >+ [% CASE %] >+ [% m.code %] >+ [% END %] >+ </div> >+[% END %] >+ >+ >+[% IF op == 'add_source' %] >+ [% IF class_source %] > <h2>Modify classification source</h2> > [% ELSE %] > <h2>Add classification source</h2> > [% END %] > <form action="[% script_name | html %]" name="Aform" class="validated" method="post"> >- <input type="hidden" name="op" value="[% confirm_op | html %]" /> >+ <input type="hidden" name="op" value="add_source_validate" /> > <fieldset class="rows"> > <ol> > <li> >- [% IF ( edit_class_source ) %] >+ [% IF class_source %] > <span class="label">Classification source code: </span> >- <input type="hidden" name="class_source" value="[% class_source | html %]" /> >- [% class_source | html %] >+ <input type="hidden" name="cn_source" value="[% class_source.cn_source | html %]" /> >+ [% class_source.cn_source | html %] > [% ELSE %] > <label class="required" for="class_source">Classification source code: </label> >- <input class="required" required="required" type="text" id="class_source" name="class_source" size="10" maxlength="10" /> >+ <input class="required" required="required" type="text" id="class_source" name="cn_source" size="10" maxlength="10" /> > <span class="required">Required</span> > [% END %] > </li> > <li><label class="required" for="description">Description: </label> >- <input class="required" required="required" type="text" id="description" name="description" size="50" maxlength="250" value="[% description | html %]" /> >+ <input class="required" required="required" type="text" id="description" name="description" size="50" maxlength="250" value="[% class_source.description | html %]" /> > <span class="required">Required</span> > </li> > <li><label for="used">Source in use?</label> >- [% IF ( used ) %]<input type="checkbox" id="used" name="used" value="used" checked="checked" />[% ELSE %] >+ [% IF ( class_source.used ) %]<input type="checkbox" id="used" name="used" value="used" checked="checked" />[% ELSE %] > <input type="checkbox" id="used" name="used" value="used" />[% END %] > </li> >- <li><label class="required" for="sort_rule">Filing rule: </label> >- <select class="required" required="required" id="sort_rule" name="sort_rule"> >- [% FOREACH rules_dropdow IN rules_dropdown %] >- [% IF ( rules_dropdow.selected ) %] >- <option value="[% rules_dropdow.rule | html %]" selected="selected">[% rules_dropdow.description | html %] ([% rules_dropdow.rule | html %])</option> >- [% ELSE %] >- <option value="[% rules_dropdow.rule | html %]">[% rules_dropdow.description | html %] ([% rules_dropdow.rule | html %])</option> >- [% END %] >- [% END %] >- </select> >- <span class="required">Required</span> >- </li> >+ <li> >+ <label class="required" for="class_sort_rule">Filing rule: </label> >+ <select class="required" required="required" id="class_sort_rule" name="class_sort_rule"> >+ [% FOREACH r IN sort_rules %] >+ [% IF class_source.class_sort_rule == r.class_sort_rule %] >+ <option value="[% r.class_sort_rule | html %]" selected="selected">[% r.description | html %] ([% r.class_sort_rule | html %])</option> >+ [% ELSE %] >+ <option value="[% r.class_sort_rule | html %]">[% r.description | html %] ([% r.class_sort_rule | html %])</option> >+ [% END %] >+ [% END %] >+ </select> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label class="required" for="class_split_rule">Splitting rule: </label> >+ <select class="required" required="required" id="split_rule" name="class_split_rule"> >+ [% FOREACH r IN split_rules %] >+ [% IF class_source.class_split_rule == r.class_split_rule %] >+ <option value="[% r.class_split_rule | html %]" selected="selected">[% r.description | html %] ([% r.class_split_rule | html %])</option> >+ [% ELSE %] >+ <option value="[% r.class_split_rule | html %]">[% r.description | html %] ([% r.class_split_rule | html %])</option> >+ [% END %] >+ [% END %] >+ </select> >+ <span class="required">Required</span> >+ </li> > </ol> > </fieldset> > <fieldset class="action"> >@@ -100,38 +150,38 @@ > </form> > [% END %] > >-[% IF ( sort_rule_form ) %] >- [% IF ( edit_sort_rule ) %] >+[% IF op == 'add_sort_rule' %] >+ [% IF sort_rule %] > <h2>Modify filing rule</h2> > [% ELSE %] > <h2>Add filing rule</h2> > [% END %] > <form action="[% script_name | html %]" name="Aform" class="validated" method="post"> >- <input type="hidden" name="op" value="[% confirm_op | html %]" /> >+ <input type="hidden" name="op" value="add_sort_rule_validate" /> > <fieldset class="rows"> > <ol> > <li> >- [% IF ( edit_sort_rule ) %] >+ [% IF sort_rule %] > <span class="label">Filing rule code: </span> >- <input type="hidden" name="sort_rule" value="[% sort_rule | html %]" /> >- [% sort_rule | html %] >+ <input type="hidden" name="class_sort_rule" value="[% sort_rule.class_sort_rule | html %]" /> >+ [% sort_rule.class_sort_rule | html %] > [% ELSE %] >- <label for="sort_rule" class="required">Filing rule code: </label> >- <input class="required" required="required" type="text" id="sort_rule" name="sort_rule" size="10" maxlength="10" /> >+ <label for="class_sort_rule" class="required">Filing rule code: </label> >+ <input class="required" required="required" type="text" id="class_sort_rule" name="class_sort_rule" size="10" maxlength="10" /> > <span class="required">Required</span> > [% END %] > </li> > <li><label for="description" class="required">Description: </label> >- <input class="required" required="required" type="text" id="description" name="description" size="50" maxlength="250" value="[% description | html %]" /> >+ <input class="required" required="required" type="text" id="description" name="description" size="50" maxlength="250" value="[% sort_rule.description | html %]" /> > <span class="required">Required</span> > </li> > <li><label for="sort_routine" class="required">Filing routine: </label> > <select class="required" required="required" id="sort_routine" name="sort_routine"> >- [% FOREACH routines_dropdow IN routines_dropdown %] >- [% IF ( routines_dropdow.selected ) %] >- <option value="[% routines_dropdow.routine | html %]" selected="selected">[% routines_dropdow.routine | html %]</option> >+ [% FOREACH routine_name IN sort_routines %] >+ [% IF routine_name == sort_rule.sort_routine %] >+ <option value="[% routine_name | html %]" selected="selected">[% routine_name | html %]</option> > [% ELSE %] >- <option value="[% routines_dropdow.routine | html %]">[% routines_dropdow.routine | html %]</option> >+ <option value="[% routine_name | html %]">[% routine_name %]</option> > [% END %] > [% END %] > </select> >@@ -146,100 +196,92 @@ > </form> > [% END %] > >-[% IF ( delete_class_source_form ) %] >- <div class="dialog alert"> >- <h3>Confirm deletion of classification source <span class="ex">'[% class_source | html %]'</span>?</h3> >- <form action="[% script_name | html %]" name="Aform" method="post"> >- <input type="hidden" name="op" value="[% confirm_op | html %]" /> >- <input type="hidden" name="class_source" value="[% class_source | html %]" /> >- <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete classification source</button> >- </form> >- <form action="[% script_name | html %]" method="get"> >- <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button> >- </form> >- </div> >-[% END %] >- >-[% IF ( delete_sort_rule_form ) %] >- <div class="dialog alert"> >- <h3>Confirm deletion of filing rule <span class="ex">'[% sort_rule | html %]'</span>?</h3> >- <form action="[% script_name | html %]" name="Aform" method="post"> >- <input type="hidden" name="op" value="[% confirm_op | html %]" /> >- <input type="hidden" name="sort_rule" value="[% sort_rule | html %]" /> >- <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete filing rule</button> >- </form> >- <form action="[% script_name | html %]" method="get"> >- <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button> >- </form> >- </div> >-[% END %] >+[% IF op == 'add_split_rule' %] >+ [% IF split_rule %] >+<h2>Modify splitting rule</h2> >+ [% ELSE %] >+<h2>Add splitting rule</h2> >+ [% END %] >+<form action="[% script_name | html %]" name="Aform" class="validated" method="post"> >+ <input type="hidden" name="op" value="add_split_rule_validate" /> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ [% IF split_rule %] >+ <span class="label">Splitting rule code: </span> >+ <input type="hidden" name="class_split_rule" value="[% split_rule.class_split_rule | html %]" /> >+ [% split_rule.class_split_rule | html %] >+ [% ELSE %] >+ <label for="class_split_rule" class="required">Splitting rule code: </label> >+ <input class="required" required="required" type="text" id="class_split_rule" name="class_split_rule" size="10" maxlength="10" /> >+ <span class="required">Required</span> >+ [% END %] >+ </li> >+ <li><label for="description" class="required">Description: </label> >+ <input class="required" required="required" type="text" id="description" name="description" size="50" maxlength="250" value="[% split_rule.description | html %]" /> >+ <span class="required">Required</span> >+ </li> >+ <li><label for="split_routine" class="required">Splitting routine: </label> >+ <select class="required" required="required" id="split_routine" name="split_routine"> >+ [% FOREACH routine_name IN split_routines %] >+ [% IF routine_name == split_rule.split_routine %] >+ <option value="[% routine_name | html %]" selected="selected">[% routine_name | html %]</option> >+ [% ELSE %] >+ <option value="[% routine_name | html %]">[% routine_name | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ <span class="required">Required</span> >+ </li> >+ <li id="regex_block"> >+ <label for="split_regex" class="required">Regular expression: </label> >+ <input type="text" name="split_regex" id="split_regex" value="[% split_rule.split_regex | html %]" /> >+ <span class="required">Required</span> >+ </li> > >-[% IF ( delete_sort_rule_impossible ) %] >-<div class="dialog alert"><h3>Cannot delete filing rule <span class="ex">'[% sort_rule | html %]'</span></h3> >- <p>The filing rule [% sort_rule | html %] is used by at least one classification source. Please >- remove it from all classification source definitions before trying again. >- </p> >- <form action="[% script_name | html %]" method="get"> >- <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button> >- </form> >-</div> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Save" /> >+ <a class="cancel" href="/cgi-bin/koha/admin/classsources.pl">Cancel</a> >+ </fieldset> >+</form> > [% END %] > >-[% IF ( display_lists ) %] >+[% IF op == 'list' %] > > <div id="toolbar" class="btn-toolbar"> >- <a class="btn btn-default btn-sm" id="newsource" href="[% script_name | html %]?op=add_source"><i class="fa fa-plus"></i> New classification source</a> >+ <a class="btn btn-default btn-sm" id="newsource" href="[% script_name| html %]?op=add_source"><i class="fa fa-plus"></i> New classification source</a> > <a class="btn btn-default btn-sm" id="newrule" href="[% script_name | html %]?op=add_sort_rule"><i class="fa fa-plus"></i> New filing rule</a> >+ <a class="btn btn-default btn-sm" id="newrule" href="[% script_name | html %]?op=add_split_rule"><i class="fa fa-plus"></i> New splitting rule</a> > </div> > > <h2>Classification sources</h2> >-[% IF ( added_source ) %] >-<div class="dialog message">Added classification source [% added_source | html %]</div> >-[% END %] >-[% IF ( edited_source ) %] >-<div class="dialog message">Modified classification source [% edited_source | html %]</div> >-[% END %] >-[% IF ( deleted_source ) %] >-<div class="dialog message">Deleted classification source [% deleted_source | html %]</div> >-[% END %] >-[% IF ( failed_add_source ) %] >-<div class="dialog message">Failed to add classification source [% failed_add_source | html %]. Perhaps the code already exists?</div> >-[% END %] > <table> > <tr> > <th>Code</th> > <th>Description</th> > <th>In use</th> > <th>Filing rule</th> >+ <th>Splitting rule</th> > <th>Actions</th> > </tr> > [% FOREACH class_source IN class_sources %] > <tr> >- <td>[% class_source.code | html %]</td> >- <td>[% class_source.description | html %]</td> >+ <td>[% class_source.cn_source | html %]</td> >+ <td>[% class_source.description |html | html %]</td> > <td>[% IF ( class_source.used ) %]Yes[% ELSE %]No[% END %]</td> >- <td>[% class_source.sortrule | html %]</td> >+ <td>[% class_source.class_sort_rule | html %]</td> >+ <td>[% class_source.class_split_rule | html %]</td> > <td class="actions"> >- <a class="btn btn-default btn-xs" href="[% class_source.script_name | html %]?op=edit_source&class_source=[% class_source.code | html %]"><i class="fa fa-pencil"></i> Edit</a> >- <a class="btn btn-default btn-xs" href="[% class_source.script_name | html %]?op=delete_source&class_source=[% class_source.code | html %]"><i class="fa fa-trash"></i> Delete</a> >+ <a class="btn btn-default btn-xs" href="[% script_name | html %]?op=add_source&cn_source=[% class_source.cn_source |html %]"><i class="fa fa-pencil"></i> Edit</a> >+ <a class="btn btn-default btn-xs delete_class_source" href="[% script_name | html %]?op=delete_source&cn_source=[% class_source.cn_source |html %]"><i class="fa fa-trash"></i> Delete</a> > </td> > </tr> > [% END %] > </table> > > <h2>Classification filing rules</h2> >-[% IF ( added_rule ) %] >-<div class="dialog message">Added filing rule [% added_rule | html %]</div> >-[% END %] >-[% IF ( edited_rule ) %] >-<div class="dialog message">Modified filing rule [% edited_rule | html %]</div> >-[% END %] >-[% IF ( deleted_rule ) %] >-<div class="dialog message">Deleted filing rule [% deleted_rule | html %]</div> >-[% END %] >-[% IF ( failed_add_rule ) %] >-<div class="dialog message">Failed to add filing rule [% failed_add_rule | html %]. Perhaps the code already exists?</div> >-[% END %] > <table> > <tr> > <th>Code</th> >@@ -247,19 +289,41 @@ > <th>Sorting routine</th> > <th>Actions</th> > </tr> >- [% FOREACH class_sort_rule IN class_sort_rules %] >+ [% FOREACH rule IN sort_rules %] >+ <tr> >+ <td>[% rule.class_sort_rule | html %]</td> >+ <td>[% rule.description |html | html %]</td> >+ <td>[% rule.sort_routine | html %]</td> >+ <td class="actions"> >+ <a class="btn btn-default btn-xs" href="[% script_name | html %]?op=add_sort_rule&class_sort_rule=[% rule.class_sort_rule |url %]"><i class="fa fa-pencil"></i> Edit</a> >+ <a class="btn btn-default btn-xs delete_sort_rule" href="[% script_name | html %]?op=delete_sort_rule&class_sort_rule=[% rule.class_sort_rule |url %]"><i class="fa fa-trash"></i> Delete</a> >+ </td> >+ </tr> >+ [% END %] >+</table> >+ >+<h2>Classification splitting rules</h2> >+<table> >+ <tr> >+ <th>Code</th> >+ <th>Description</th> >+ <th>Splitting routine</th> >+ <th>Actions</th> >+ </tr> >+ [% FOREACH rule IN split_rules %] > <tr> >- <td>[% class_sort_rule.rule | html %]</td> >- <td>[% class_sort_rule.description | html %]</td> >- <td>[% class_sort_rule.sort_routine | html %]</td> >+ <td>[% rule.class_split_rule | html %]</td> >+ <td>[% rule.description | html %]</td> >+ <td>[% rule.split_routine | html %]</td> > <td class="actions"> >- <a class="btn btn-default btn-xs" href="[% class_sort_rule.script_name | html %]?op=edit_sort_rule&sort_rule=[% class_sort_rule.rule | html %]"><i class="fa fa-pencil"></i> Edit</a> >- <a class="btn btn-default btn-xs" href="[% class_sort_rule.script_name | html %]?op=delete_sort_rule&sort_rule=[% class_sort_rule.rule | html %]"><i class="fa fa-trash"></i> Delete</a> >+ <a class="btn btn-default btn-xs" href="[% script_name | html %]?op=add_split_rule&class_split_rule=[% rule.class_split_rule | url %]"><i class="fa fa-pencil"></i> Edit</a> >+ <a class="btn btn-default btn-xs delete_split_rule" href="[% script_name | html %]?op=delete_split_rule&class_split_rule=[% rule.class_split_rule | url %]"><i class="fa fa-trash"></i> Delete</a> > </td> > </tr> > [% END %] > </table> > >+ > [% END %] > > </main> >@@ -274,5 +338,34 @@ > > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/admin-menu.js") | $raw %] >+ >+ <script> >+ function update_regex_block(){ >+ if ( $("#split_routine option:selected").val() == 'RegEx' ) { >+ $("#regex_block").show(); >+ $("#split_regex").attr('required', 'required'); >+ } else { >+ $("#regex_block").hide(); >+ $("#split_regex").removeAttr('required'); >+ } >+ }; >+ $(document).ready(function(){ >+ update_regex_block(); >+ $("#split_routine").on("change", function(){ >+ update_regex_block(); >+ }); >+ >+ $(".delete_class_source").on("click", function(e){ >+ return confirm(_("Are you sure you want to delete this class source?")); >+ }); >+ $(".delete_sort_rule").on("click", function(e){ >+ return confirm(_("Are you sure you want to delete this filing rule?")); >+ }); >+ $(".delete_split_rule").on("click", function(e){ >+ return confirm(_("Are you sure you want to delete this splitting rule?")); >+ }); >+ }); >+ >+ </script> > [% END %] > [% INCLUDE 'intranet-bottom.inc' %] >-- >2.19.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15836
:
76691
|
76692
|
76693
|
76694
|
76695
|
76696
|
77061
|
77079
|
77306
|
78791
|
78793
|
78795
|
78796
|
78798
|
78799
|
79029
|
80339
|
80340
|
80341
|
80342
|
80343
|
80344
|
80345
|
80346
|
80347
|
80548
|
80549
|
80550
|
80551
|
80552
|
80553
|
80554
|
80555
|
80556
|
81033
|
81034
|
81035
|
81036
|
81037
|
81038
|
81039
|
81040
|
81041
|
81627
|
81628
|
81629
|
81630
|
81631
|
81632
|
81633
|
81634
|
81635
|
82110
|
82112
|
82113
|
82118
|
82119
|
82120
|
82289
|
82290
|
82291
|
82292
|
82293
|
82294
|
82295
|
82296
|
82297
|
82298
|
82299
|
82300
|
82301
|
82302
|
82317
|
82318
|
82319
|
82321