|
Lines 176-181
Link Here
|
| 176 |
[% END %] |
176 |
[% END %] |
| 177 |
</tbody> |
177 |
</tbody> |
| 178 |
</table> |
178 |
</table> |
|
|
179 |
[% IF ( patrons.count == 2 ) %] |
| 180 |
<br /> |
| 181 |
<fieldset id="copy-ui" hidden> |
| 182 |
<div class="form-check"> |
| 183 |
<input type="checkbox" id="copy-checkbox" name="copy" value="1" /> |
| 184 |
<label for="copy-checkbox">Copy values from record to be deleted</label> |
| 185 |
</div> |
| 186 |
<div id="copy-fields" class="container" hidden></div> |
| 187 |
</fieldset> |
| 188 |
[% END %] |
| 179 |
|
189 |
|
| 180 |
<fieldset class="action"> |
190 |
<fieldset class="action"> |
| 181 |
[% FOREACH p IN patrons %] |
191 |
[% FOREACH p IN patrons %] |
|
Lines 239-271
Link Here
|
| 239 |
<div class="modal-body"> |
249 |
<div class="modal-body"> |
| 240 |
<div class="compare"> |
250 |
<div class="compare"> |
| 241 |
<div id="col-label"> |
251 |
<div id="col-label"> |
| 242 |
<div><strong>Name:</strong></div> |
252 |
<div><strong data-field="name">Name:</strong></div> |
| 243 |
<div><strong>Initials:</strong></div> |
253 |
<div><strong data-field="preferred_name">Preferred name:</strong></div> |
| 244 |
<div><strong>Other name:</strong></div> |
254 |
<div><strong data-field="initials">Initials:</strong></div> |
| 245 |
<div><strong>Library:</strong></div> |
255 |
<div><strong data-field="othernames">Other name:</strong></div> |
| 246 |
<div><strong>Card number:</strong></div> |
256 |
<div><strong data-field="branchcode">Library:</strong></div> |
| 247 |
<div><strong>Category:</strong></div> |
257 |
<div><strong data-field="cardnumber">Card number:</strong></div> |
|
|
258 |
<div><strong data-field="categorycode">Category:</strong></div> |
| 248 |
<br /> |
259 |
<br /> |
| 249 |
<div><strong>Address line 1:</strong></div> |
260 |
<div><strong data-field="address">Address line 1:</strong></div> |
| 250 |
<div><strong>Address line 2:</strong></div> |
261 |
<div><strong data-field="address2">Address line 2:</strong></div> |
| 251 |
<div><strong>City:</strong></div> |
262 |
<div><strong data-field="city">City:</strong></div> |
| 252 |
<div><strong>State:</strong></div> |
263 |
<div><strong data-field="state">State:</strong></div> |
| 253 |
<div><strong>ZIP/Postal code:</strong></div> |
264 |
<div><strong data-field="zipcode">ZIP/Postal code:</strong></div> |
| 254 |
<div><strong>Country:</strong></div> |
265 |
<div><strong data-field="country">Country:</strong></div> |
| 255 |
<br /> |
266 |
<br /> |
| 256 |
<div><strong>Registration date:</strong></div> |
267 |
<div><strong data-field="dateenrolled">Registration date:</strong></div> |
| 257 |
<div><strong>Renewal date:</strong></div> |
268 |
<div><strong data-field="date_renewed">Renewal date:</strong></div> |
| 258 |
<div><strong>Expiration date:</strong></div> |
269 |
<div><strong data-field="dateexpiry">Expiration date:</strong></div> |
| 259 |
<div><strong>Date of birth:</strong></div> |
270 |
<div><strong data-field="dateofbirth">Date of birth:</strong></div> |
| 260 |
<div><strong>Restricted:</strong></div> |
271 |
<div><strong data-field="debarred">Restricted:</strong></div> |
| 261 |
<div><strong>Primary email:</strong></div> |
272 |
<div><strong data-field="email">Primary email:</strong></div> |
| 262 |
<div><strong>Secondary email:</strong></div> |
273 |
<div><strong data-field="emailpro">Secondary email:</strong></div> |
| 263 |
<div><strong>Primary phone:</strong></div> |
274 |
<div><strong data-field="phone">Primary phone:</strong></div> |
| 264 |
<div><strong>Secondary phone:</strong></div> |
275 |
<div><strong data-field="phonepro">Secondary phone:</strong></div> |
| 265 |
<div><strong>Other phone:</strong></div> |
276 |
<div><strong data-field="mobile">Other phone:</strong></div> |
| 266 |
<div><strong>Gender:</strong></div> |
277 |
<div><strong data-field="sex">Gender:</strong></div> |
| 267 |
<div><strong>Updated on:</strong></div> |
278 |
<div><strong data-field="updated_on">Updated on:</strong></div> |
| 268 |
<div><strong>Username:</strong></div> |
279 |
<div><strong data-field="userid">Username:</strong></div> |
| 269 |
</div> |
280 |
</div> |
| 270 |
|
281 |
|
| 271 |
[% FOREACH p IN patrons %] |
282 |
[% FOREACH p IN patrons %] |
|
Lines 274-279
Link Here
|
| 274 |
<!-- <pre> block is unindented to avoid unwanted whitespace --> |
285 |
<!-- <pre> block is unindented to avoid unwanted whitespace --> |
| 275 |
<pre> |
286 |
<pre> |
| 276 |
[% IF ( p.surname ) %][% p.surname | html %], [% p.firstname | html %][% ELSE %]-[% END %] |
287 |
[% IF ( p.surname ) %][% p.surname | html %], [% p.firstname | html %][% ELSE %]-[% END %] |
|
|
288 |
[% IF ( p.preferred_name ) %][% p.preferred_name | html %][% ELSE %]-[% END %] |
| 277 |
[% IF ( p.initials ) %][% p.initials | html %][% ELSE %]-[% END %] |
289 |
[% IF ( p.initials ) %][% p.initials | html %][% ELSE %]-[% END %] |
| 278 |
[% IF ( p.othernames ) %][% p.othernames | html %][% ELSE %]-[% END %] |
290 |
[% IF ( p.othernames ) %][% p.othernames | html %][% ELSE %]-[% END %] |
| 279 |
[% IF ( p.branchcode ) %][% p.branchcode | html %][% ELSE %]-[% END %] |
291 |
[% IF ( p.branchcode ) %][% p.branchcode | html %][% ELSE %]-[% END %] |
|
Lines 332-340
Link Here
|
| 332 |
$("#patron-merge-table").on("change", "input", function () { |
344 |
$("#patron-merge-table").on("change", "input", function () { |
| 333 |
if ($(".keeper:checked").length > 0) { |
345 |
if ($(".keeper:checked").length > 0) { |
| 334 |
controls.prop("disabled", false); |
346 |
controls.prop("disabled", false); |
|
|
347 |
$("#copy-ui").prop("hidden", false); |
| 335 |
} else { |
348 |
} else { |
| 336 |
controls.prop("disabled", true); |
349 |
controls.prop("disabled", true); |
| 337 |
} |
350 |
} |
|
|
351 |
if ($("#copy-checkbox").is(":checked")) { |
| 352 |
loadCopyUI(); |
| 353 |
} |
| 338 |
}); |
354 |
}); |
| 339 |
|
355 |
|
| 340 |
$("#compare_patrons").on("click", function (e) { |
356 |
$("#compare_patrons").on("click", function (e) { |
|
Lines 352-364
Link Here
|
| 352 |
|
368 |
|
| 353 |
var diffs = diffString(diff2, diff1); |
369 |
var diffs = diffString(diff2, diff1); |
| 354 |
/* Load the diff HTML in the empty columns */ |
370 |
/* Load the diff HTML in the empty columns */ |
| 355 |
$(".col2 pre, .col3 pre").html(diffs); |
371 |
$("#compareModal .col2 pre, #compareModal .col3 pre").html(diffs); |
| 356 |
}); |
372 |
}); |
| 357 |
|
373 |
|
| 358 |
$("#submit-merge-form").on("click", function () { |
374 |
$("#submit-merge-form").on("click", function () { |
| 359 |
$("#patron-merge-form").submit(); |
375 |
$("#patron-merge-form").submit(); |
| 360 |
}); |
376 |
}); |
|
|
377 |
|
| 378 |
$("#copy-checkbox").on("change", function () { |
| 379 |
$("#copy-fields").prop("hidden", !this.checked); |
| 380 |
$("#compare_patrons").prop("disabled", this.checked); |
| 381 |
if (this.checked) { |
| 382 |
loadCopyUI(); |
| 383 |
} |
| 384 |
}); |
| 361 |
}); |
385 |
}); |
|
|
386 |
|
| 387 |
function loadCopyUI() { |
| 388 |
$("#copy-fields").empty(); |
| 389 |
/* Find which column is the basis for merging */ |
| 390 |
let col0 = $(".keeper:checked").data("borrowernumber"); |
| 391 |
let col1 = $(".keeper:not(:checked)").data("borrowernumber"); |
| 392 |
/* Get the original patron data for comparison */ |
| 393 |
let diff1 = $("#col-" + col0 + "-orig pre") |
| 394 |
.text() |
| 395 |
.split("\n") |
| 396 |
.filter(e => e !== ""); |
| 397 |
let diff2 = $("#col-" + col1 + "-orig pre") |
| 398 |
.text() |
| 399 |
.split("\n") |
| 400 |
.filter(e => e !== ""); |
| 401 |
let labels = $("#col-label strong") |
| 402 |
.text() |
| 403 |
.split(":") |
| 404 |
.filter(e => e !== ""); |
| 405 |
let fields = $("#col-label strong") |
| 406 |
.map((_, e) => e.dataset.field) |
| 407 |
.get(); |
| 408 |
|
| 409 |
const container = $("#copy-fields"); |
| 410 |
container.append( |
| 411 |
`<div class="row mb-2"> |
| 412 |
<div class="col fw-bold">` + |
| 413 |
_("Field") + |
| 414 |
`</div> |
| 415 |
<div class="col fw-bold">` + |
| 416 |
_("Keep") + |
| 417 |
`</div> |
| 418 |
<div class="col fw-bold">` + |
| 419 |
_("Delete") + |
| 420 |
`</div> |
| 421 |
<div class="col fw-bold">` + |
| 422 |
_("Copy value") + |
| 423 |
`</div> |
| 424 |
</div>` |
| 425 |
); |
| 426 |
|
| 427 |
labels.forEach((label, i) => { |
| 428 |
if (diff1[i] !== diff2[i]) { |
| 429 |
container.append( |
| 430 |
`<div class="row"> |
| 431 |
<div class="col"> |
| 432 |
<label for="copy${fields[i]}"> |
| 433 |
<strong>` + |
| 434 |
_(label) + |
| 435 |
`:</strong> |
| 436 |
</div> |
| 437 |
<div class="col col2"><pre data-og="${diff1[i]}"></pre></div> |
| 438 |
<div class="col col3"><pre data-og="${diff2[i]}"></pre></div> |
| 439 |
<div class="col form-check"> |
| 440 |
<input type="checkbox" name="${fields[i]}" value="${diff2[i]}" id="copy${fields[i]}"> |
| 441 |
</div> |
| 442 |
</div>` |
| 443 |
); |
| 444 |
|
| 445 |
let diffs = diffString(diff2[i], diff1[i]); |
| 446 |
container.find(".row:last-child pre").html(diffs); |
| 447 |
} |
| 448 |
}); |
| 449 |
|
| 450 |
$("#copy-fields .row input[type=checkbox]").on("click", function () { |
| 451 |
let ins = $(this).closest(".row").find(".col2 pre").data("og").toString(); |
| 452 |
let del = $(this).closest(".row").find(".col3 pre").data("og").toString(); |
| 453 |
let diffs; |
| 454 |
if ($(this).is(":checked")) { |
| 455 |
diffs = diffString(ins, del); |
| 456 |
} else { |
| 457 |
diffs = diffString(del, ins); |
| 458 |
} |
| 459 |
$(this).closest(".row").find(".col2 pre, .col3 pre").html(diffs); |
| 460 |
}); |
| 461 |
} |
| 362 |
</script> |
462 |
</script> |
| 363 |
[% END %] |
463 |
[% END %] |
| 364 |
|
464 |
|
| 365 |
- |
|
|