Bug 30303 - Add ability to select which values to retain when merging patrons
Summary: Add ability to select which values to retain when merging patrons
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Brendan Lawlor
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-16 12:15 UTC by Andrew Fuerste-Henry
Modified: 2025-10-02 17:44 UTC (History)
15 users (show)

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


Attachments
Bug 30303: Add ui for copying values when merging patrons (11.19 KB, patch)
2025-09-12 12:24 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 30303: Copy values to keeper record when merging patrons (1.83 KB, patch)
2025-09-12 12:24 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 30303: (follow-up) Update diff highlighting instead of swapping columns (2.28 KB, patch)
2025-09-18 17:29 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 30303: (follow-up) Stop the back button from loading from cache (989 bytes, patch)
2025-10-02 13:33 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 30303: (follow-up) Only copy values if merge returns results (777 bytes, patch)
2025-10-02 14:17 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 30303: Add ui for copying values when merging patrons (11.25 KB, patch)
2025-10-02 17:43 UTC, Lari Taskula
Details | Diff | Splinter Review
Bug 30303: Copy values to keeper record when merging patrons (1.88 KB, patch)
2025-10-02 17:43 UTC, Lari Taskula
Details | Diff | Splinter Review
Bug 30303: (follow-up) Update diff highlighting instead of swapping columns (2.33 KB, patch)
2025-10-02 17:44 UTC, Lari Taskula
Details | Diff | Splinter Review
Bug 30303: (follow-up) Only copy values if merge returns results (835 bytes, patch)
2025-10-02 17:44 UTC, Lari Taskula
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Fuerste-Henry 2022-03-16 12:15:24 UTC
When merging two patron records, one simply picks one record to retain values from. It would be helpful to have an interface more like what we see when merging biblio records, where one can select values from either pre-merge record to be retained post-merge.
Comment 1 Christopher Brannon 2022-03-16 15:19:17 UTC
This would be great!!! +++++1
Comment 2 Elaine Bradtke 2022-05-24 18:17:44 UTC
Important for libraries that allow self registration.  Users  create their own logins without linking to their existing card.  If we try to merge the two, the login information (password, etc.) is lost.
Comment 3 Rebecca Coert 2024-01-17 16:16:49 UTC
This would be very useful, especially if the Registration Date field was included.  I often merge newer accounts (with the correct information) for users that have returned, but have an old/expired account.  It would be nice to keep their original registration date.
Comment 4 Nancy M. 2025-08-12 15:09:02 UTC
Our network offers self-registration and I merge many cards. I'm truly amazed this is not already an option when merging. Patrons who are registered more than once often have updated information that is not in the older record. This would be an important enhancement as more libraries are offering online registration.
Comment 5 Brendan Lawlor 2025-09-12 12:24:44 UTC
Created attachment 186382 [details] [review]
Bug 30303: Add ui for copying values when merging patrons

When merging two patrons this patch adds a new checkbox to
'Copy values from the record to be deleted'

To test:
- Apply patches and restart_all
1. From select two patrons and click 'Merge selected patrons'
2. Select one of the records
3. Check the new box to 'Copy values from the record to be deleted'
4. A diff of the two patrons is shown with checkboxes for each field
5. Confirm checking and un-checking the boxes updates the diff as expected
6. Confirm changing the patron selection updates the diff as expected.
7. Confirm un-checking and re-checking the Copy values from the record to be deleted
   resets the check boxes for the fields to copy
8. Select some fields to copy values and click merge patrons
9. Confirm the values were copied as expected

Sponsored-by: CLAMS
Comment 6 Brendan Lawlor 2025-09-12 12:24:47 UTC
Created attachment 186383 [details] [review]
Bug 30303: Copy values to keeper record when merging patrons
Comment 7 Brendan Lawlor 2025-09-18 17:29:59 UTC
Created attachment 186572 [details] [review]
Bug 30303: (follow-up) Update diff highlighting instead of swapping columns

This patch makes the ui more visually consistent and intuitive
Comment 8 Lari Taskula 2025-10-02 10:35:52 UTC
This is so cool!

I noticed that after merging, if I hit the browser's back button, it takes me back to the field selection where I am once again able to select the fields to retain. Surprisingly, the new choices would still apply after hitting "Merge" the second time, even if Koha says "No valid patrons to merge were found.". But in some sense this feels more like a feature than a bug, because I might have forgotten to select something and this allows me to correct my error.
Comment 9 Brendan Lawlor 2025-10-02 13:33:27 UTC
Created attachment 187269 [details] [review]
Bug 30303: (follow-up) Stop the back button from loading from cache
Comment 10 Brendan Lawlor 2025-10-02 13:42:47 UTC
(In reply to Lari Taskula from comment #8)
> This is so cool!

Thanks Lari!

> I noticed that after merging, if I hit the browser's back button, it takes
> me back to the field selection where I am once again able to select the
> fields to retain. Surprisingly, the new choices would still apply after
> hitting "Merge" the second time, even if Koha says "No valid patrons to
> merge were found.". But in some sense this feels more like a feature than a
> bug, because I might have forgotten to select something and this allows me
> to correct my error.

This is sort of just the nature of the browser using a web app like Koha. Different browsers may behave differently too. 

I understand how in this case it could be confusing though.

I think this might be better handled on the server side with HTTP Cache-Control headers like no-cache, no-store or must-revalidate, but this could also be done with javascript to force a reload when the browser's back button is used.

I'm not sure if it's necessary, but the last patch forces a reload when you use the back button like this:

// Stop the back button loading from cache
window.onpageshow = function (e) {
    if (e.persisted) {
        window.location.reload();
    }
}
Comment 11 Brendan Lawlor 2025-10-02 14:17:35 UTC
Created attachment 187295 [details] [review]
Bug 30303: (follow-up) Only copy values if merge returns results
Comment 12 Brendan Lawlor 2025-10-02 14:23:29 UTC
On second thought I think the better solution is to only copy the values if the merge returns results.

That way if you use the back button you'll still see the page from the cache, but if you try to select more values to copy and submit the form again no values will be copied. That way the No valid patrons to merge were found message is accurate.

Thanks for testing and feedback Lari!
Comment 13 Lari Taskula 2025-10-02 17:43:55 UTC
Created attachment 187306 [details] [review]
Bug 30303: Add ui for copying values when merging patrons

When merging two patrons this patch adds a new checkbox to
'Copy values from the record to be deleted'

To test:
- Apply patches and restart_all
1. From select two patrons and click 'Merge selected patrons'
2. Select one of the records
3. Check the new box to 'Copy values from the record to be deleted'
4. A diff of the two patrons is shown with checkboxes for each field
5. Confirm checking and un-checking the boxes updates the diff as expected
6. Confirm changing the patron selection updates the diff as expected.
7. Confirm un-checking and re-checking the Copy values from the record to be deleted
   resets the check boxes for the fields to copy
8. Select some fields to copy values and click merge patrons
9. Confirm the values were copied as expected

Sponsored-by: CLAMS
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Comment 14 Lari Taskula 2025-10-02 17:43:58 UTC
Created attachment 187307 [details] [review]
Bug 30303: Copy values to keeper record when merging patrons

Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Comment 15 Lari Taskula 2025-10-02 17:44:00 UTC
Created attachment 187308 [details] [review]
Bug 30303: (follow-up) Update diff highlighting instead of swapping columns

This patch makes the ui more visually consistent and intuitive

Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Comment 16 Lari Taskula 2025-10-02 17:44:03 UTC
Created attachment 187309 [details] [review]
Bug 30303: (follow-up) Only copy values if merge returns results

Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>