Bug 24616

Summary: Cannot copy notice to another library if it already exists
Product: Koha Reporter: Christopher Brannon <cbrannon>
Component: NoticesAssignee: Emmi Takkinen <emmi.takkinen>
Status: RESOLVED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: normal    
Priority: P5 - low CC: david, emmi.takkinen, lucas, marie-luce.laflamme, martin.renvoize, nick, philip.orr
Version: masterKeywords: release-notes-needed
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.03
Attachments: Bug 24616: Allow copying notice to a branch even if it exists in that branch
Bug 24616: Allow copying notice to a branch even if it exists in that branch
Bug 24616: Allow copying notice to a branch even if it exists in that branch
Bug 24616: Do not save form if user press cancel
Bug 24616: Do not save form if user press cancel
Bug 24616: Do not save form if user press cancel
Bug 24616: Allow copying notice to a branch even if it exists in that branch
Bug 24616: Do not save form if user press cancel
Bug 24616: (QA follow-up) Remove "This has bug" comment

Description Christopher Brannon 2020-02-07 22:16:49 UTC
If you try to copy a notice or slip to another branch and that branch already has that notice or slip, it will not let you save it.  There needs to be a way to overwrite the existing notice or slip without having to delete first then copy.
Comment 1 Emmi Takkinen 2022-07-27 11:32:08 UTC
We are facing this same problem. I guess one possible solution could be move to "Modify notice" page instead "Add notice" if notice already exists.
Comment 2 Emmi Takkinen 2022-07-29 06:05:10 UTC
Created attachment 138242 [details] [review]
Bug 24616: Allow copying notice to a branch even if it exists in that branch

If you try to copy notice or slip to a branch which already
has that notice or slip Koha won't let you save it. Instead
pop-up saying branch already has that notice is displayed.

This patch allows users to copy and override already existing
notice or slip.

To test:
1. Find notice which exists e.g. in all branches and branch A.
2. Copy that notice, add notice screen is displayed.
3. Press save.
=> Pop-up informing that notice already exists in branch A
is displayed.
4. Apply this patch.
5. Repeat steps 2. and 3.
=> Notice is saved succesfully.

Also try to save the notice you tested with as a new (same code)
to branch A. Confirm that pop-up is displayed as it should be.

Sponsored-by: Koha-Suomi Oy
Comment 3 Emmi Takkinen 2022-07-29 06:09:04 UTC
(In reply to Emmi Takkinen from comment #1)
> We are facing this same problem. I guess one possible solution could be move
> to "Modify notice" page instead "Add notice" if notice already exists.

This wasn't the solution, but I still think we should move to "Modify notice" page in these cases. However I was unsure if this is in scope of this bug or should I open a separete bug report for this (if it doesn't already exists).
Comment 4 Christopher Brannon 2022-07-29 16:29:40 UTC
It works, but I don't think this is a complete solution.  It needs to warn you that you are overwriting an existing notice or slip and give you the option to proceed or cancel.  This is too dangerous as is.
Comment 5 Emmi Takkinen 2022-08-01 08:26:42 UTC
(In reply to Christopher Brannon from comment #4)
> It works, but I don't think this is a complete solution.  It needs to warn
> you that you are overwriting an existing notice or slip and give you the
> option to proceed or cancel.  This is too dangerous as is.

That's a good point. I'll take a look at this again.
Comment 6 Emmi Takkinen 2022-08-02 12:24:54 UTC
Created attachment 138503 [details] [review]
Bug 24616: Allow copying notice to a branch even if it exists in that branch

If you try to copy notice or slip to a branch which already
has that notice or slip Koha won't let you save it. Instead
pop-up saying branch already has that notice is displayed.

This patch allows users to copy and override already existing
notice or slip.

To test:
1. Find notice which exists e.g. in all branches and branch A.
2. Copy that notice, add notice screen is displayed.
3. Press save.
=> Pop-up informing that notice already exists in branch A
is displayed.
4. Apply this patch.
5. Repeat steps 2. and 3.
6. Pop-up to confirm overwrite of notice is displayed.
=> Confirm that if you press OK, notice is saved succesfully.
=> Otherwise, changes to notice should not be saved.

Also try to save the notice you tested with as a new (same code)
to branch A. Confirm that pop-up is displayed as it should be.

Sponsored-by: Koha-Suomi Oy
Comment 7 ByWater Sandboxes 2022-10-26 14:14:06 UTC
Created attachment 142672 [details] [review]
Bug 24616: Allow copying notice to a branch even if it exists in that branch

If you try to copy notice or slip to a branch which already
has that notice or slip Koha won't let you save it. Instead
pop-up saying branch already has that notice is displayed.

This patch allows users to copy and override already existing
notice or slip.

To test:
1. Find notice which exists e.g. in all branches and branch A.
2. Copy that notice, add notice screen is displayed.
3. Press save.
=> Pop-up informing that notice already exists in branch A
is displayed.
4. Apply this patch.
5. Repeat steps 2. and 3.
6. Pop-up to confirm overwrite of notice is displayed.
=> Confirm that if you press OK, notice is saved succesfully.
=> Otherwise, changes to notice should not be saved.

Also try to save the notice you tested with as a new (same code)
to branch A. Confirm that pop-up is displayed as it should be.

Sponsored-by: Koha-Suomi Oy

Signed-off-by: Nick <nick@bywatersolutions.com>
Comment 8 Katrin Fischer 2022-10-27 18:58:52 UTC
I am sorry, but there is a major issue:

When I save the changes, I get the overwrite warning, but: if I choose cancel, the changes are still saved. :(
Comment 9 Emmi Takkinen 2022-11-01 10:01:28 UTC
Created attachment 142850 [details] [review]
Bug 24616: Do not save form if user press cancel

If one starts to copy a notice but then cancels
this when pop-up is displayed, changes are still
saved. This patch fixes this.

To test:
1. Copy notice to a library where it already exists
2. Press save and then cancel when pop-up is
displayed
=> Form and changes are still saved
3. Apply this patch.
4. Repeat steps 1. and 2.
=> Form is no longer saved

Sponsored-by: Koha-Suomi Oy
Comment 10 Emmi Takkinen 2022-11-01 10:15:59 UTC
Changing back to ASSIGNED, latest patch broke saving the form.
Comment 11 Emmi Takkinen 2022-11-01 10:57:47 UTC
Created attachment 142856 [details] [review]
Bug 24616: Do not save form if user press cancel

If one starts to copy a notice but then cancels
this when pop-up is displayed, changes are still
saved. This patch fixes this.

To test:
1. Copy notice to a library where it already exists
2. Press save and then cancel when pop-up is
displayed
=> Form and changes are still saved
3. Apply this patch.
4. Repeat steps 1. and 2.
=> Form is no longer saved

Sponsored-by: Koha-Suomi Oy
Comment 12 Emmi Takkinen 2022-11-10 06:22:38 UTC
Setting this as Needs Signoff, notice form shouldn't now be saved when pressing cancel on pop-up.
Comment 13 Marie-Luce Laflamme 2023-01-12 16:48:48 UTC
The patch seems to work well. It did warn me of the existing notice and let me save the change anyway.
Comment 14 ByWater Sandboxes 2023-01-12 16:49:32 UTC
Created attachment 145238 [details] [review]
Bug 24616: Do not save form if user press cancel

If one starts to copy a notice but then cancels
this when pop-up is displayed, changes are still
saved. This patch fixes this.

To test:
1. Copy notice to a library where it already exists
2. Press save and then cancel when pop-up is
displayed
=> Form and changes are still saved
3. Apply this patch.
4. Repeat steps 1. and 2.
=> Form is no longer saved

Sponsored-by: Koha-Suomi Oy
Signed-off-by: ml-inlibro <marie-luce.laflamme@inlibro.com>
Comment 15 David Nind 2023-01-13 02:24:42 UTC
Changed status to now signed off - see comment #13 and signed off patch.
Comment 16 Katrin Fischer 2023-02-03 14:52:40 UTC
Created attachment 146148 [details] [review]
Bug 24616: Allow copying notice to a branch even if it exists in that branch

If you try to copy notice or slip to a branch which already
has that notice or slip Koha won't let you save it. Instead
pop-up saying branch already has that notice is displayed.

This patch allows users to copy and override already existing
notice or slip.

To test:
1. Find notice which exists e.g. in all branches and branch A.
2. Copy that notice, add notice screen is displayed.
3. Press save.
=> Pop-up informing that notice already exists in branch A
is displayed.
4. Apply this patch.
5. Repeat steps 2. and 3.
6. Pop-up to confirm overwrite of notice is displayed.
=> Confirm that if you press OK, notice is saved succesfully.
=> Otherwise, changes to notice should not be saved.

Also try to save the notice you tested with as a new (same code)
to branch A. Confirm that pop-up is displayed as it should be.

Sponsored-by: Koha-Suomi Oy

Signed-off-by: Nick <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 17 Katrin Fischer 2023-02-03 14:52:44 UTC
Created attachment 146149 [details] [review]
Bug 24616: Do not save form if user press cancel

If one starts to copy a notice but then cancels
this when pop-up is displayed, changes are still
saved. This patch fixes this.

To test:
1. Copy notice to a library where it already exists
2. Press save and then cancel when pop-up is
displayed
=> Form and changes are still saved
3. Apply this patch.
4. Repeat steps 1. and 2.
=> Form is no longer saved

Sponsored-by: Koha-Suomi Oy
Signed-off-by: ml-inlibro <marie-luce.laflamme@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 18 Katrin Fischer 2023-02-03 14:52:49 UTC
Created attachment 146150 [details] [review]
Bug 24616: (QA follow-up) Remove "This has bug" comment

... hopefully because there is no more bug now!

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 19 Katrin Fischer 2023-02-03 14:56:27 UTC
1) Removed this comment (hopefully rightfully) in a follow-up:

+//This has bug

2) return confirm(__("A letter with the code '%s' already exists for '%s'. Overwrite this letter?").format(new_lettercode, new_branchcode));

We get the branchcode in the message instead of the library's name. But: This is already the case for the old error that doesn't allow you to overwrite. So I filed:
Bug 32880 - Show library's name instead of branchcode in dialog when overwriting an existing notice
Comment 20 Tomás Cohen Arazi 2023-02-06 21:35:29 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 21 Matt Blenkinsop 2023-02-07 15:23:54 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 22 Lucas Gass 2023-02-14 22:40:18 UTC
Enhancement will not be backported to 22.05.x
Comment 23 Philip Orr 2023-12-01 15:23:20 UTC
Since the "copy notice" function wasn't in the manual yet, I added 
some documentation for that.
No need for documentation on this bug though since the error message 
is self-explanatory.