Bugzilla – Attachment 103838 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]
Bug 17355: Add the ability to remove authorised value categories
Bug-17355-Add-the-ability-to-remove-authorised-val.patch (text/plain), 8.10 KB, created by
Jonathan Druart
on 2020-04-28 10:08:17 UTC
(
hide
)
Description:
Bug 17355: Add the ability to remove authorised value categories
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-04-28 10:08:17 UTC
Size:
8.10 KB
patch
obsolete
>From 8a43cb6bc6b3ca746c11b794f1cac2e14e66608e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 28 Apr 2020 11:53:57 +0200 >Subject: [PATCH] Bug 17355: Add the ability to remove authorised value > categories > >This new patch set is adding a new DB field is_system to distinguish >internal categories. > >The list of internal categories is in the patch "DB changes - set >is_system for categories" and can be discussed/extended. > >Test plan: >1. >- Create a new AV category >- Create an authorised value >- List the AVs for this category >- Remove all the AVs for this category >=> You see 2 buttons "Add a new authorised value" and "Delete category >'XXX'" >- Click the delete button >=> You get a popup >- Accept >=> The category is deleted > >2. >- List the AV for Asort1 (internal category) >/cgi-bin/koha/admin/authorised_values.pl?searchfield=Asort1 >- Delete the AVs for this category (if there is any) >=> You do not see the "Delete category" button > >3. >- Create a new AV category 'foo' >- Create an authorised value >- Hit /admin/authorised_values.pl?op=delete_category&categor_name=foo >=> You get an error message (the category cannot be deleted if it has AV >linked) > >4. >- Hit /admin/authorised_values.pl?op=delete_category&categor_name=Asort1 >=> You get an error message (the category Asort1 cannot be deleted, it's an >internal category. >--- > admin/authorised_values.pl | 16 ++++++++-- > .../en/modules/admin/authorised_values.tt | 29 ++++++++++++++----- > 2 files changed, 35 insertions(+), 10 deletions(-) > >diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl >index 945bd62b73..e8cffdd697 100755 >--- a/admin/authorised_values.pl >+++ b/admin/authorised_values.pl >@@ -88,7 +88,7 @@ if ($op eq 'add_form') { > ); > } else { > $template->param( >- category => $category, >+ category_name => $category, > imagesets => C4::Koha::getImageSets(), > ); > } >@@ -193,7 +193,17 @@ if ($op eq 'add_form') { > } > > $op = 'list'; >- $template->param( delete_success => 1 ); >+} elsif ($op eq 'delete_category') { >+ my $category_name = $input->param('category_name'); >+ my $avc = Koha::AuthorisedValueCategories->find( $category_name ); >+ my $deleted = eval {$avc->delete}; >+ if ( $@ or not $deleted ) { >+ push @messages, {type => 'error', code => 'error_on_delete_category' }; >+ } else { >+ push @messages, { type => 'message', code => 'success_on_delete_category' }; >+ } >+ >+ $op = 'list'; > } > > $template->param( >@@ -229,7 +239,7 @@ if ( $op eq 'list' ) { > > $template->param( > loop => \@loop_data, >- category => $searchfield, >+ category => Koha::AuthorisedValueCategories->find($searchfield), # TODO Move this up and add a Koha::AVC->authorised_values method to replace call for avs_by_category > categories => \@category_list, > ); > >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 16ab04be9a..17bd962d87 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 >@@ -32,7 +32,7 @@ > [% IF ( action_add_category ) %]New category[% END %] > [% ELSIF ( loop ) %] > <a href="/cgi-bin/koha/admin/authorised_values.pl">Authorized values</a> › >- Authorized values for category [% category | html %] >+ Authorized values for category [% category_name | html %] > [% ELSE %] > Authorized values > [% END %] >@@ -65,7 +65,7 @@ > <li> > <span class="label">Category</span> > <input type="hidden" name="op" value="add" /> >- <input type="hidden" name="category" value="[% category | html %]" /> [% category | html %] >+ <input type="hidden" name="category" value="[% category_name | html %]" /> [% category_name | html %] > </li> > <li> > <label for="authorised_value">Authorized value: </label> >@@ -132,7 +132,7 @@ > [% END %] > </fieldset> > <fieldset class="action"> <input type="hidden" name="id" value="[% id | html %]" /> >- <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% category | url %]">Cancel</a></fieldset> >+ <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% category_name | url %]">Cancel</a></fieldset> > </form> > [% END %] > >@@ -141,12 +141,12 @@ > <div id="toolbar" class="btn-toolbar"> > <a id="addcat" class="btn btn-default" href= "/cgi-bin/koha/admin/authorised_values.pl?op=add_form"><i class="fa fa-plus"> </i> New category</a> > [% IF ( searchfield ) %] >- <a id="addauth" class="btn btn-default" href= "/cgi-bin/koha/admin/authorised_values.pl?op=add_form&category=[% category | url %]"><i class="fa fa-plus"> </i> New authorized value for [% category | html %]</a> >+ <a id="addauth" class="btn btn-default" href= "/cgi-bin/koha/admin/authorised_values.pl?op=add_form&category=[% category.category_name | url %]"><i class="fa fa-plus"> </i> New authorized value for [% category.category_name | html %]</a> > [% END %] > </div> > > [% IF ( searchfield ) %] >- <h1>Authorized values for category [% category | html %]</h1> >+ <h1>Authorized values for category [% category.category_name | html %]</h1> > [% PROCESS category_descriptions code_category = category %] > [% ELSE %] > <h1>Authorized values</h1> >@@ -169,6 +169,8 @@ > 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_category' %] >+ An error occurred when deleting this authorized value category. Check the logs. > [% CASE 'success_on_update' %] > Authorized value updated successfully. > [% CASE 'success_on_insert' %] >@@ -177,6 +179,8 @@ > Authorized value category added successfully. > [% CASE 'success_on_delete' %] > Authorized value deleted successfully. >+ [% CASE 'success_on_delete_category' %] >+ Authorized value category deleted successfully. > [% CASE 'cat_already_exists' %] > This authorized value category already exists. > [% CASE 'invalid_category_name' %] >@@ -250,12 +254,19 @@ > </tbody></table> > [% ELSE %] > <div class="dialog message"> >- <p>There are no authorized values defined for [% category | html %]</p> >+ <p>There are no authorized values defined for [% category.category_name | html %]</p> > <form action="/cgi-bin/koha/admin/authorised_values.pl" method="get"> > <input type="hidden" name="op" value="add_form" /> >- <input type="hidden" name="category" value="[% category | html %]" /> >+ <input type="hidden" name="category" value="[% category.category_name | html %]" /> > <button type="submit"><i class="fa fa-plus"></i> Add a new authorized value</button> > </form> >+ [% UNLESS category.is_system %] >+ <form id="delete_category" action="/cgi-bin/koha/admin/authorised_values.pl" method="post"> >+ <input type="hidden" name="op" value="delete_category" /> >+ <input type="hidden" name="category_name" value="[% category.category_name | html %]" /> >+ <button type="submit"><i class="fa fa-plus"></i> Delete category '[% category.category_name | html %]' </button> >+ </form> >+ [% END %] > </div> > [% END %] > >@@ -326,6 +337,10 @@ > $('#category').submit(); > }); > $(".library_limitation").tooltip(); >+ >+ $("#delete_category").on('submit', function(){ >+ return confirm(_("Are you sure you want to delete this authorized value category?")); >+ }); > }); > </script> > [% END %] >-- >2.20.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 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