@@ -, +, @@ categories - Apply patch - updatedabase - Create a new AV category - Create an authorised value - List the AVs for this category - Remove all the AVs for this category - Click the delete button - Accept - List the AV for Asort1 (internal category) - Delete the AVs for this category (if there is any) - Create a new AV category 'foo' - Create an authorised value - Hit /admin/authorised_values.pl?op=delete_category&categor_name=foo - Hit /admin/authorised_values.pl?op=delete_category&categor_name=Asort1 --- admin/authorised_values.pl | 16 +++++++++--- .../prog/en/modules/admin/authorised_values.tt | 29 ++++++++++++++++------ 2 files changed, 35 insertions(+), 10 deletions(-) --- a/admin/authorised_values.pl +++ a/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, ); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt @@ -32,7 +32,7 @@ [% IF ( action_add_category ) %]New category[% END %] [% ELSIF ( loop ) %] Authorized values › - Authorized values for category [% category | html %] + Authorized values for category [% category_name | html %] [% ELSE %] Authorized values [% END %] @@ -65,7 +65,7 @@
  • Category - [% category | html %] + [% category_name | html %]
  • @@ -132,7 +132,7 @@ [% END %]
    - Cancel
    + Cancel [% END %] @@ -141,12 +141,12 @@
    New category [% IF ( searchfield ) %] - New authorized value for [% category | html %] + New authorized value for [% category.category_name | html %] [% END %]
    [% IF ( searchfield ) %] -

    Authorized values for category [% category | html %]

    +

    Authorized values for category [% category.category_name | html %]

    [% PROCESS category_descriptions code_category = category %] [% ELSE %]

    Authorized values

    @@ -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 @@ [% ELSE %]
    -

    There are no authorized values defined for [% category | html %]

    +

    There are no authorized values defined for [% category.category_name | html %]

    - +
    + [% UNLESS category.is_system %] +
    + + + +
    + [% END %]
    [% 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?")); + }); }); [% END %] --