Bug 16055 - Deleting a basket group containing baskets fails silently
Summary: Deleting a basket group containing baskets fails silently
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Jonathan Druart
QA Contact: Testopia
URL: /cgi-bin/koha/acqui/basketgroup.pl
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-11 17:51 UTC by Owen Leonard
Modified: 2016-12-05 21:25 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 16055: Do not allow basketgroup deletion unless empty (3.87 KB, patch)
2016-04-05 08:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 16055: Do not allow basketgroup deletion unless empty (3.97 KB, patch)
2016-04-05 18:35 UTC, Owen Leonard
Details | Diff | Splinter Review
[PASSED QA] Bug 16055: Do not allow basketgroup deletion unless empty (3.99 KB, patch)
2016-04-05 21:45 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2016-03-11 17:51:08 UTC
In the list of basket groups for a vendor there is a "delete" option for each basket group whether or not the basket group contains baskets. If you choose "delete" for a basket group containing a basket it will fail silently and an error will be logged:

DBD::mysql::st execute failed: Cannot delete or update a parent row: a foreign key constraint fails (`aqbasket`, CONSTRAINT `aqbasket_ibfk_3` FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE) [for Statement "DELETE FROM aqbasketgroups WHERE id=?" with ParamValues: 0="3"]

Since the template knows the number of baskets in a basket group it should be easy to hide or disable the delete button in those cases.

It also would be nice to add a JavaScript confirmation before deleting a basket. Right now deletions are completed without any warning.

Keep in mind the work being done in Bug 16038 and Bug 11708 when considering this one.
Comment 1 Jonathan Druart 2016-04-05 08:16:05 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2016-04-05 08:17:21 UTC
(In reply to Owen Leonard from comment #0)
> Keep in mind the work being done in Bug 16038 and Bug 11708 when considering
> this one.

One is blocked and the other one does not apply. Moreover this is a bug fix and it could be great to backport it.
I think this patch should be pushed before the 2 others.
Comment 3 Owen Leonard 2016-04-05 18:35:09 UTC Comment hidden (obsolete)
Comment 4 Katrin Fischer 2016-04-05 21:44:32 UTC
Should we have icons on those buttons? If yes... please add on another bug :)
Comment 5 Katrin Fischer 2016-04-05 21:45:45 UTC
Created attachment 49932 [details] [review]
[PASSED QA] Bug 16055: Do not allow basketgroup deletion unless empty

If a basketgroup has basket attached, it should not be deletable.
This patch just removes the Delete button from the interface if it
cannot be deleted.
When editing a basketgroup, the "Delete basket group" button is no
longer displayed.

Test plan:
1/ Create a basketgroup
2/ Attach 1+ baskets to this basketgroup
3/ Confirm you are not able to delete it
4/ Remove the baskets from this basketgroup
5/ Confirm you are able to delete it

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 6 Brendan Gallagher 2016-04-20 20:30:04 UTC
Pushed to Master - Should be in the May 2016 Release.  Thanks!
Comment 7 Julian Maurice 2016-04-21 08:06:38 UTC
Patch pushed to 3.22.x, will be in 3.22.6