Bugzilla – Attachment 186382 Details for
Bug 30303
Add ability to select which values to retain when merging patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30303: Add ui for copying values when merging patrons
Bug-30303-Add-ui-for-copying-values-when-merging-p.patch (text/plain), 11.19 KB, created by
Brendan Lawlor
on 2025-09-12 12:24:44 UTC
(
hide
)
Description:
Bug 30303: Add ui for copying values when merging patrons
Filename:
MIME Type:
Creator:
Brendan Lawlor
Created:
2025-09-12 12:24:44 UTC
Size:
11.19 KB
patch
obsolete
>From 43805f10eb795cd257ab5eb185655ff1bd576853 Mon Sep 17 00:00:00 2001 >From: Brendan Lawlor <blawlor@clamsnet.org> >Date: Thu, 11 Sep 2025 15:58:35 +0000 >Subject: [PATCH] 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 >--- > .../prog/en/modules/members/merge-patrons.tt | 152 +++++++++++++++--- > 1 file changed, 126 insertions(+), 26 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/merge-patrons.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/merge-patrons.tt >index c912466d4e..0ba7575220 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/merge-patrons.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/merge-patrons.tt >@@ -176,6 +176,16 @@ > [% END %] > </tbody> > </table> >+ [% IF ( patrons.count == 2 ) %] >+ <br /> >+ <fieldset id="copy-ui" hidden> >+ <div class="form-check"> >+ <input type="checkbox" id="copy-checkbox" name="copy" value="1" /> >+ <label for="copy-checkbox">Copy values from record to be deleted</label> >+ </div> >+ <div id="copy-fields" class="container" hidden></div> >+ </fieldset> >+ [% END %] > > <fieldset class="action"> > [% FOREACH p IN patrons %] >@@ -239,33 +249,34 @@ > <div class="modal-body"> > <div class="compare"> > <div id="col-label"> >- <div><strong>Name:</strong></div> >- <div><strong>Initials:</strong></div> >- <div><strong>Other name:</strong></div> >- <div><strong>Library:</strong></div> >- <div><strong>Card number:</strong></div> >- <div><strong>Category:</strong></div> >+ <div><strong data-field="name">Name:</strong></div> >+ <div><strong data-field="preferred_name">Preferred name:</strong></div> >+ <div><strong data-field="initials">Initials:</strong></div> >+ <div><strong data-field="othernames">Other name:</strong></div> >+ <div><strong data-field="branchcode">Library:</strong></div> >+ <div><strong data-field="cardnumber">Card number:</strong></div> >+ <div><strong data-field="categorycode">Category:</strong></div> > <br /> >- <div><strong>Address line 1:</strong></div> >- <div><strong>Address line 2:</strong></div> >- <div><strong>City:</strong></div> >- <div><strong>State:</strong></div> >- <div><strong>ZIP/Postal code:</strong></div> >- <div><strong>Country:</strong></div> >+ <div><strong data-field="address">Address line 1:</strong></div> >+ <div><strong data-field="address2">Address line 2:</strong></div> >+ <div><strong data-field="city">City:</strong></div> >+ <div><strong data-field="state">State:</strong></div> >+ <div><strong data-field="zipcode">ZIP/Postal code:</strong></div> >+ <div><strong data-field="country">Country:</strong></div> > <br /> >- <div><strong>Registration date:</strong></div> >- <div><strong>Renewal date:</strong></div> >- <div><strong>Expiration date:</strong></div> >- <div><strong>Date of birth:</strong></div> >- <div><strong>Restricted:</strong></div> >- <div><strong>Primary email:</strong></div> >- <div><strong>Secondary email:</strong></div> >- <div><strong>Primary phone:</strong></div> >- <div><strong>Secondary phone:</strong></div> >- <div><strong>Other phone:</strong></div> >- <div><strong>Gender:</strong></div> >- <div><strong>Updated on:</strong></div> >- <div><strong>Username:</strong></div> >+ <div><strong data-field="dateenrolled">Registration date:</strong></div> >+ <div><strong data-field="date_renewed">Renewal date:</strong></div> >+ <div><strong data-field="dateexpiry">Expiration date:</strong></div> >+ <div><strong data-field="dateofbirth">Date of birth:</strong></div> >+ <div><strong data-field="debarred">Restricted:</strong></div> >+ <div><strong data-field="email">Primary email:</strong></div> >+ <div><strong data-field="emailpro">Secondary email:</strong></div> >+ <div><strong data-field="phone">Primary phone:</strong></div> >+ <div><strong data-field="phonepro">Secondary phone:</strong></div> >+ <div><strong data-field="mobile">Other phone:</strong></div> >+ <div><strong data-field="sex">Gender:</strong></div> >+ <div><strong data-field="updated_on">Updated on:</strong></div> >+ <div><strong data-field="userid">Username:</strong></div> > </div> > > [% FOREACH p IN patrons %] >@@ -274,6 +285,7 @@ > <!-- <pre> block is unindented to avoid unwanted whitespace --> > <pre> > [% IF ( p.surname ) %][% p.surname | html %], [% p.firstname | html %][% ELSE %]-[% END %] >+[% IF ( p.preferred_name ) %][% p.preferred_name | html %][% ELSE %]-[% END %] > [% IF ( p.initials ) %][% p.initials | html %][% ELSE %]-[% END %] > [% IF ( p.othernames ) %][% p.othernames | html %][% ELSE %]-[% END %] > [% IF ( p.branchcode ) %][% p.branchcode | html %][% ELSE %]-[% END %] >@@ -332,9 +344,13 @@ > $("#patron-merge-table").on("change", "input", function () { > if ($(".keeper:checked").length > 0) { > controls.prop("disabled", false); >+ $("#copy-ui").prop("hidden", false); > } else { > controls.prop("disabled", true); > } >+ if ($("#copy-checkbox").is(":checked")) { >+ loadCopyUI(); >+ } > }); > > $("#compare_patrons").on("click", function (e) { >@@ -352,13 +368,97 @@ > > var diffs = diffString(diff2, diff1); > /* Load the diff HTML in the empty columns */ >- $(".col2 pre, .col3 pre").html(diffs); >+ $("#compareModal .col2 pre, #compareModal .col3 pre").html(diffs); > }); > > $("#submit-merge-form").on("click", function () { > $("#patron-merge-form").submit(); > }); >+ >+ $("#copy-checkbox").on("change", function () { >+ $("#copy-fields").prop("hidden", !this.checked); >+ $("#compare_patrons").prop("disabled", this.checked); >+ if (this.checked) { >+ loadCopyUI(); >+ } >+ }); > }); >+ >+ function loadCopyUI() { >+ $("#copy-fields").empty(); >+ /* Find which column is the basis for merging */ >+ let col0 = $(".keeper:checked").data("borrowernumber"); >+ let col1 = $(".keeper:not(:checked)").data("borrowernumber"); >+ /* Get the original patron data for comparison */ >+ let diff1 = $("#col-" + col0 + "-orig pre") >+ .text() >+ .split("\n") >+ .filter(e => e !== ""); >+ let diff2 = $("#col-" + col1 + "-orig pre") >+ .text() >+ .split("\n") >+ .filter(e => e !== ""); >+ let labels = $("#col-label strong") >+ .text() >+ .split(":") >+ .filter(e => e !== ""); >+ let fields = $("#col-label strong") >+ .map((_, e) => e.dataset.field) >+ .get(); >+ >+ const container = $("#copy-fields"); >+ container.append( >+ `<div class="row mb-2"> >+ <div class="col fw-bold">` + >+ _("Field") + >+ `</div> >+ <div class="col fw-bold">` + >+ _("Keep") + >+ `</div> >+ <div class="col fw-bold">` + >+ _("Delete") + >+ `</div> >+ <div class="col fw-bold">` + >+ _("Copy value") + >+ `</div> >+ </div>` >+ ); >+ >+ labels.forEach((label, i) => { >+ if (diff1[i] !== diff2[i]) { >+ container.append( >+ `<div class="row"> >+ <div class="col"> >+ <label for="copy${fields[i]}"> >+ <strong>` + >+ _(label) + >+ `:</strong> >+ </div> >+ <div class="col col2"><pre data-og="${diff1[i]}"></pre></div> >+ <div class="col col3"><pre data-og="${diff2[i]}"></pre></div> >+ <div class="col form-check"> >+ <input type="checkbox" name="${fields[i]}" value="${diff2[i]}" id="copy${fields[i]}"> >+ </div> >+ </div>` >+ ); >+ >+ let diffs = diffString(diff2[i], diff1[i]); >+ container.find(".row:last-child pre").html(diffs); >+ } >+ }); >+ >+ $("#copy-fields .row input[type=checkbox]").on("click", function () { >+ let ins = $(this).closest(".row").find(".col2 pre").data("og").toString(); >+ let del = $(this).closest(".row").find(".col3 pre").data("og").toString(); >+ let diffs; >+ if ($(this).is(":checked")) { >+ diffs = diffString(ins, del); >+ } else { >+ diffs = diffString(del, ins); >+ } >+ $(this).closest(".row").find(".col2 pre, .col3 pre").html(diffs); >+ }); >+ } > </script> > [% END %] > >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30303
:
186382
|
186383
|
186572
|
187269
|
187295
|
187306
|
187307
|
187308
|
187309