Bugzilla – Attachment 54983 Details for
Bug 17216
Add a new table to store authorized value categories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17216: Update the admin interface
Bug-17216-Update-the-admin-interface.patch (text/plain), 7.44 KB, created by
Jonathan Druart
on 2016-08-29 14:42:46 UTC
(
hide
)
Description:
Bug 17216: Update the admin interface
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-08-29 14:42:46 UTC
Size:
7.44 KB
patch
obsolete
>From 350b02cdefe76a10de05f6afd4dd97986100728f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 29 Aug 2016 14:06:46 +0100 >Subject: [PATCH] Bug 17216: Update the admin interface > >--- > admin/authorised_values.pl | 48 ++++++++++++++++------ > .../prog/en/modules/admin/authorised_values.tt | 35 ++++++++++------ > 2 files changed, 58 insertions(+), 25 deletions(-) > >diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl >index b782901..0a79e8d 100755 >--- a/admin/authorised_values.pl >+++ b/admin/authorised_values.pl >@@ -27,6 +27,7 @@ use C4::Koha; > use C4::Output; > > use Koha::AuthorisedValues; >+use Koha::AuthorisedValueCategories; > > my $input = new CGI; > my $id = $input->param('id'); >@@ -113,6 +114,9 @@ if ($op eq 'add_form') { > if ( $already_exists and ( not $id or $already_exists->id != $id ) ) { > push @messages, {type => 'error', code => 'already_exists' }; > } >+ elsif ( $new_category eq 'branches' or $new_category eq 'itemtypes' or $new_category eq 'cn_source' ) { >+ push @messages, {type => 'error', code => 'invalid_category_name' }; >+ } > elsif ( $id ) { # Update > my $av = Koha::AuthorisedValues->new->find( $id ); > >@@ -154,6 +158,36 @@ if ($op eq 'add_form') { > > $op = 'list'; > $searchfield = $new_category; >+} elsif ($op eq 'add_category' ) { >+ my $new_category = $input->param('category'); >+ >+ my $already_exists = Koha::AuthorisedValueCategories->find( >+ { >+ category_name => $new_category, >+ } >+ ); >+ >+ if ( $already_exists ) { >+ push @messages, {type => 'error', code => 'cat_already_exists' }; >+ } >+ else { # Insert >+ my $av = Koha::AuthorisedValueCategory->new( { >+ category_name => $new_category, >+ } ); >+ >+ eval { >+ $av->store; >+ }; >+ >+ if ( $@ ) { >+ push @messages, {type => 'error', code => 'error_on_insert_cat' }; >+ } else { >+ push @messages, { type => 'message', code => 'success_on_insert_cat' }; >+ } >+ } >+ >+ $op = 'list'; >+ $searchfield = $new_category; > } elsif ($op eq 'delete') { > my $av = Koha::AuthorisedValues->new->find( $input->param('id') ); > my $deleted = eval {$av->delete}; >@@ -175,22 +209,12 @@ $template->param( > > if ( $op eq 'list' ) { > # build categories list >- my @categories = Koha::AuthorisedValues->new->categories; >+ my @categories = Koha::AuthorisedValueCategories->search({}, { order_by => ['category_name'] } ); > my @category_list; >- my %categories; # a hash, to check that some hardcoded categories exist. > for my $category ( @categories ) { >- push( @category_list, $category ); >- $categories{$category} = 1; >+ push( @category_list, $category->category_name ); > } > >- # push koha system categories >- foreach (qw(Asort1 Asort2 Bsort1 Bsort2 SUGGEST DAMAGED LOST REPORT_GROUP REPORT_SUBGROUP DEPARTMENT TERM SUGGEST_STATUS ITEMTYPECAT)) { >- push @category_list, $_ unless $categories{$_}; >- } >- >- #reorder the list >- @category_list = sort {$a cmp $b} @category_list; >- > $searchfield ||= $category_list[0]; > > my @avs_by_category = Koha::AuthorisedValues->new->search( { category => $searchfield } ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >index 764fb53..5a3c413 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >@@ -77,23 +77,23 @@ $(document).ready(function() { > [% IF ( action_modify ) %]<div class="note"><i class="fa fa-exclamation"></i> <strong>NOTE:</strong> If you change an authorized value code, existing records using it won't be updated. Changes to value descriptions will show immediately.</div>[% END %] > > <form action="/cgi-bin/koha/admin/authorised_values.pl" name="Aform" method="post"> >- <input type="hidden" name="op" value="add" /> > <fieldset class="rows"><ol> >- <li> >- [% IF ( action_add_category ) %]<label for="category">Category: </label> >- <input type="text" name="category" id="category" size="32" maxlength="32" class="focus" /> >- [% ELSE %]<span class="label">Category</span> >- <input type="hidden" name="category" value="[% category %]" /> [% category %] >- [% END %] >- </li> >+ [% IF action_add_category %] >+ <li> >+ <label for="category">Category: </label> >+ <input type="hidden" name="op" value="add_category" /> >+ <input type="text" name="category" id="category" size="32" maxlength="32" class="focus" /> >+ </li> >+ [% ELSE %] >+ <li> >+ <span class="label">Category</span> >+ <input type="hidden" name="op" value="add" /> >+ <input type="hidden" name="category" value="[% category %]" /> [% category %] >+ </li> > <li> > <label for="authorised_value">Authorized value: </label> >- [% IF ( action_modify ) %]<input type="hidden" id="id" name="id" value="[% id %]" />[% END %] >- [% IF ( action_add_category ) %] >- <input type="text" id="authorised_value" name="authorised_value" value="[% authorised_value %]" maxlength="80" /> >- [% ELSE %] >+ [% IF ( action_modify ) %]<input type="hidden" id="id" name="id" value="[% id %]" />[% END %] > <input type="text" id="authorised_value" name="authorised_value" value="[% authorised_value %]" maxlength="80" class="focus" /> >- [% END %] > </li> > <li> > <label for="lib">Description: </label> >@@ -152,6 +152,7 @@ $(document).ready(function() { > </div> > [% END %] > </div> >+ [% END %] > </fieldset> > <fieldset class="action"> <input type="hidden" name="id" value="[% id %]" /> > <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% category %]">Cancel</a></fieldset> >@@ -176,16 +177,24 @@ $(document).ready(function() { > An error occurred when updating this authorized value. Perhaps the value already exists. > [% CASE 'error_on_insert' %] > An error occurred when inserting this authorized value. Perhaps the value or the category already exists. >+ [% CASE 'error_on_insert_cat' %] >+ An error occurred when inserting this authorized value category. Perhaps the category name already exists. > [% CASE 'error_on_delete' %] > An error occurred when deleting this authorized value. Check the logs. > [% CASE 'success_on_update' %] > Authorized value updated successfully. > [% CASE 'success_on_insert' %] > Authorized value added successfully. >+ [% CASE 'success_on_insert_cat' %] >+ Authorized value category added successfully. > [% CASE 'success_on_delete' %] > Authorized value deleted successfully. > [% CASE 'already_exists' %] > This authorized value already exists. >+ [% CASE 'cat_already_exists' %] >+ This authorized value category already exists. >+ [% CASE 'invalid_category_name' %] >+ The authorized value category 'branches', 'itemtypes' and 'cn_source' are used internally by Koha and are not valid. > [% CASE %] > [% m.code %] > [% END %] >-- >2.8.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 17216
:
54979
|
54980
|
54981
|
54982
|
54983
|
54984
|
54985
|
54987
|
54988
|
54989
|
54990
|
54991
|
54992
|
54993
|
55003
|
55004
|
55005
|
55008
|
55009
|
55010
|
55011
|
55021
|
55022
|
55023
|
55024
|
55025
|
55026
|
55027
|
55028
|
55029
|
55030
|
55031
|
55032
|
55047
|
55207
|
55208
|
55209
|
55210
|
55211
|
55212
|
55213
|
55214
|
55215
|
55216
|
55217
|
55218
|
55365
|
55366
|
55367
|
55368
|
55369
|
55370
|
55371
|
55372
|
55373
|
55374
|
55375
|
55376
|
55692
|
55693
|
55835
|
55840
|
56202
|
56203
|
56204
|
56205
|
56206
|
56207
|
56208
|
56209
|
56210
|
56211
|
56212
|
56213
|
56214
|
56215
|
56216
|
56217
|
56619
|
57729