Bug 41067: Disable OPAC mandatory when not editable
If a patron attribute is not editable at the OPAC it should not be
possible to make it mandatory.
Test plan:
Create a new patron attribute and confirm that checkboxes behaviour is
consistent.
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit d4a17b1b56)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
98ec1e1134
commit
f899e5447e
|
|
@ -408,6 +408,40 @@
|
|||
[% INCLUDE 'datatables.inc' %]
|
||||
[% INCLUDE 'select2.inc' %]
|
||||
<script>
|
||||
const opac_display = document.getElementById("opac_display");
|
||||
const opac_editable = document.getElementById("opac_editable");
|
||||
const opac_mandatory = document.getElementById("opac_mandatory");
|
||||
|
||||
function setDisabled(el, disabled) {
|
||||
const label = el.closest("label");
|
||||
if (disabled) {
|
||||
el.checked = false;
|
||||
el.disabled = true;
|
||||
if (label) label.setAttribute("aria-disabled", "true");
|
||||
} else {
|
||||
el.disabled = false;
|
||||
if (label) label.removeAttribute("aria-disabled");
|
||||
}
|
||||
}
|
||||
|
||||
function updateCheckboxes() {
|
||||
if (!opac_display.checked) {
|
||||
setDisabled(opac_editable, true);
|
||||
} else {
|
||||
setDisabled(opac_editable, false);
|
||||
}
|
||||
if (opac_editable.checked) {
|
||||
setDisabled(opac_mandatory, false);
|
||||
} else {
|
||||
setDisabled(opac_mandatory, true);
|
||||
}
|
||||
}
|
||||
|
||||
opac_display.addEventListener("change", updateCheckboxes);
|
||||
opac_editable.addEventListener("change", updateCheckboxes);
|
||||
|
||||
updateCheckboxes();
|
||||
|
||||
$(document).ready(function () {
|
||||
function toggle_search_default() {
|
||||
if ($("#staff_searchable").is(":checked")) {
|
||||
|
|
@ -426,18 +460,6 @@
|
|||
$("#branches option:first").attr("selected", "selected");
|
||||
}
|
||||
|
||||
$("#opac_display")
|
||||
.change(function () {
|
||||
if (this.checked) {
|
||||
$("#opac_editable").removeAttr("disabled").parent().removeAttr("aria-disabled");
|
||||
$("#opac_mandatory").removeAttr("disabled").parent().removeAttr("aria-disabled");
|
||||
} else {
|
||||
$("#opac_editable").attr("disabled", true).parent().attr("aria-disabled", "true");
|
||||
$("#opac_mandatory").attr("disabled", true).parent().attr("aria-disabled", "true");
|
||||
}
|
||||
})
|
||||
.change();
|
||||
|
||||
$("#is_date")
|
||||
.change(function () {
|
||||
if (this.checked) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue