Bugzilla – Attachment 66022 Details for
Bug 17355
Authorised value categories cannot be deleted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED OFF] Bug 17355 - Allow deletion of authorised value categories
SIGNED-OFF-Bug-17355---Allow-deletion-of-authorise.patch (text/plain), 4.82 KB, created by
Katrin Fischer
on 2017-08-15 15:44:33 UTC
(
hide
)
Description:
[SIGNED OFF] Bug 17355 - Allow deletion of authorised value categories
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2017-08-15 15:44:33 UTC
Size:
4.82 KB
patch
obsolete
>From 39cdd5f9fd5ae3877dd9106b15a99bd7d3950280 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 8 Jun 2017 09:16:45 -0400 >Subject: [PATCH] [SIGNED OFF] Bug 17355 - Allow deletion of authorised value > categories > >Note that this does not capture all internal fields, and isn't a database solution to the problem of marking internal fields. > >To test: > >Add an empty authorised value category, delete it. Make sure it stays deleted. > >Try to delete an empty system authorised value, like ccode. You should not see the button. > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > admin/authorised_values.pl | 38 +++++++++++++++++++++- > .../prog/en/modules/admin/authorised_values.tt | 12 ++++++- > 2 files changed, 48 insertions(+), 2 deletions(-) > >diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl >index 272ed00..bc7f2cd 100755 >--- a/admin/authorised_values.pl >+++ b/admin/authorised_values.pl >@@ -191,6 +191,21 @@ if ($op eq 'add_form') { > } > > $op = 'list'; >+} elsif ($op eq 'del_category' ) { >+ my $del_category = $input->param('category'); >+ if ( Koha::AuthorisedValues->new->search({ category => $del_category })->count > 0 ) { >+ push @messages, {type => 'error', code => 'error_on_delete_cat_notempty' }; >+ } else { >+ my $cat = Koha::AuthorisedValueCategories->new->find( $del_category ); >+ my $deleted = eval {$cat->delete}; >+ if ( $@ or not $deleted ) { >+ push @messages, {type => 'error', code => 'error_on_delete_cat' }; >+ } else { >+ push @messages, { type => 'message', code => 'success_on_delete_cat' }; >+ } >+ } >+ $op = 'list'; >+ $template->param( delete_success => 1 ); > } elsif ($op eq 'delete') { > my $av = Koha::AuthorisedValues->new->find( $id ); > my $deleted = eval {$av->delete}; >@@ -214,12 +229,32 @@ if ( $op eq 'list' ) { > # build categories list > my @categories = Koha::AuthorisedValueCategories->search({ category_name => { -not_in => ['', 'branches', 'itemtypes', 'cn_source']}}, { order_by => ['category_name'] } ); > my @category_list; >+ my $deletable = 1; > for my $category ( @categories ) { > push( @category_list, $category->category_name ); > } >- > $searchfield ||= $category_list[0]; >+ my %cant_del = ( >+ LOC => 1, >+ LOST => 1, >+ WITHDRAWN => 1, >+ Bsort1 => 1, >+ Bsort2 => 1, >+ Asort1 => 1, >+ Asort2 => 1, >+ SUGGEST => 1, >+ DAMAGED => 1, >+ LOST => 1, >+ MANUAL_INV => 1, >+ BOR_NOTES => 1, >+ LOC => 1, >+ CCODE => 1, >+ NOT_LOAN => 1, >+ ); > >+ if ( $cant_del{$searchfield} ) { >+ undef $deletable ; >+ } > my @avs_by_category = Koha::AuthorisedValues->new->search( { category => $searchfield } ); > my @loop_data = (); > # builds value list >@@ -239,6 +274,7 @@ if ( $op eq 'list' ) { > loop => \@loop_data, > category => $searchfield, > categories => \@category_list, >+ deletable => $deletable, > ); > > } >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 5aee840..4865e4f 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 >@@ -182,12 +182,16 @@ $(document).ready(function() { > 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 'error_on_delete_cat_notempty' %] >+ This category cannot be deleted as it contains values. > [% 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_cat' %] >+ Authorized value deleted successfully. > [% CASE 'success_on_delete' %] > Authorized value deleted successfully. > [% CASE 'already_exists' %] >@@ -296,7 +300,13 @@ $(document).ready(function() { > </tr> > [% END %] > </tbody></table>[% ELSE %] >-<div class="dialog message">There are no authorized values defined for [% category %]</div> >+<div class="dialog message">There are no authorized values defined for [% category %] >+[% IF deletable %] >+ <a class="delete btn btn-default btn-xs" href="/cgi-bin/koha/admin/authorised_values.pl?op=del_category&category=[% searchfield %]"><i class="fa fa-trash"></i> Delete category</a> >+[% END %]</div> >+</td> >+ >+</div> > [% END %] > > [% IF ( isprevpage ) %] >-- >2.7.4
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 17355
:
64102
|
65782
|
65869
|
65870
|
66022
|
66023
|
66024
|
103833
|
103834
|
103835
|
103836
|
103837
|
103838
|
104099
|
104100
|
104101
|
104102
|
104103
|
104104
|
104117
|
104118
|
104119
|
104120
|
104121
|
104122
|
104123
|
104352
|
104539