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:
parent
1c4d57a790
commit
f32cdb7211
2 changed files with 18 additions and 9 deletions
|
@ -48,16 +48,21 @@ if ( $action eq 'add' ) {
|
|||
my $description = $cgi->param('description') || undef;
|
||||
my $branchcode = $cgi->param('branchcode') || undef;
|
||||
|
||||
my $group = Koha::Library::Group->new(
|
||||
{
|
||||
parent_id => $parent_id,
|
||||
title => $title,
|
||||
description => $description,
|
||||
branchcode => $branchcode,
|
||||
}
|
||||
)->store();
|
||||
if ( !$branchcode && Koha::Library::Groups->search( { title => $title } )->count() ) {
|
||||
$template->param( error_duplicate_title => $title );
|
||||
}
|
||||
else {
|
||||
my $group = Koha::Library::Group->new(
|
||||
{
|
||||
parent_id => $parent_id,
|
||||
title => $title,
|
||||
description => $description,
|
||||
branchcode => $branchcode,
|
||||
}
|
||||
)->store();
|
||||
|
||||
$template->param( added => $group );
|
||||
$template->param( added => $group );
|
||||
}
|
||||
}
|
||||
elsif ( $action eq 'edit' ) {
|
||||
my $id = $cgi->param('id') || undef;
|
||||
|
|
|
@ -108,6 +108,10 @@
|
|||
[% deleted.library | $KohaSpan class = 'name' %] has been removed from group.
|
||||
[% END %]
|
||||
</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 %]
|
||||
|
||||
<div id="doc3" class="yui-t2">
|
||||
|
|
Loading…
Reference in a new issue