Bug 15707: Display error if group title is already used

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Edit: I added !$branchcode && to the checked condition so we can add multiple
libraries back.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Kyle Hall 2017-03-01 13:58:54 +00:00 committed by Jonathan Druart
parent 1c4d57a790
commit f32cdb7211
2 changed files with 18 additions and 9 deletions

View file

@ -48,16 +48,21 @@ if ( $action eq 'add' ) {
my $description = $cgi->param('description') || undef; my $description = $cgi->param('description') || undef;
my $branchcode = $cgi->param('branchcode') || undef; my $branchcode = $cgi->param('branchcode') || undef;
my $group = Koha::Library::Group->new( if ( !$branchcode && Koha::Library::Groups->search( { title => $title } )->count() ) {
{ $template->param( error_duplicate_title => $title );
parent_id => $parent_id, }
title => $title, else {
description => $description, my $group = Koha::Library::Group->new(
branchcode => $branchcode, {
} parent_id => $parent_id,
)->store(); title => $title,
description => $description,
branchcode => $branchcode,
}
)->store();
$template->param( added => $group ); $template->param( added => $group );
}
} }
elsif ( $action eq 'edit' ) { elsif ( $action eq 'edit' ) {
my $id = $cgi->param('id') || undef; my $id = $cgi->param('id') || undef;

View file

@ -108,6 +108,10 @@
[% deleted.library | $KohaSpan class = 'name' %] has been removed from group. [% deleted.library | $KohaSpan class = 'name' %] has been removed from group.
[% END %] [% END %]
</div> </div>
[% ELSIF error_duplicate_title %]
<div class="dialog alert error-duplicate-group-title">
A group with the title [% error_duplicate_title | $KohaSpan class = 'name' %] already exists.
</div>
[% END %] [% END %]
<div id="doc3" class="yui-t2"> <div id="doc3" class="yui-t2">