From f9fca5d899339e412da118e7a62d1e660f203f25 Mon Sep 17 00:00:00 2001 From: Jamie Little Date: Fri, 3 May 2024 10:58:08 -0500 Subject: [PATCH] Show checkbox for Welch and Homewood --- 01JHU_INST-JHU/css/prm-request-after.css | 1 + 01JHU_INST-JHU/js/custom.js | 47 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 01JHU_INST-JHU/css/prm-request-after.css diff --git a/01JHU_INST-JHU/css/prm-request-after.css b/01JHU_INST-JHU/css/prm-request-after.css new file mode 100644 index 00000000..12796ee5 --- /dev/null +++ b/01JHU_INST-JHU/css/prm-request-after.css @@ -0,0 +1 @@ +#form_field_genericCheckBox { display: none; } diff --git a/01JHU_INST-JHU/js/custom.js b/01JHU_INST-JHU/js/custom.js index b20130f0..3bcb8987 100644 --- a/01JHU_INST-JHU/js/custom.js +++ b/01JHU_INST-JHU/js/custom.js @@ -60,6 +60,38 @@ } }); + + app.component('prmRequestAfter', { + bindings: { parentCtrl: '<' }, + template: '
', + controller: ['primawsRest', '$scope', function ($scope) { + + this.$onInit = function () { + + // Watch for changes in the dropdown value + $scope.$watch(() => this.parentCtrl.formData["pickupLocation"], (newValue, oldValue) => { + if (newValue !== oldValue) { // Check if the value has actually changed + this.updateCheckboxVisibility(newValue); + } + }); + }; + + this.updateCheckboxVisibility = function (selectedLocationId) { + const homewoodId = "126006350007861$$LIBRARY"; + const welchId = "126007910007861$$LIBRARY"; + + const checkbox = document.getElementById('form_field_genericCheckBox'); + + if (checkbox != null && (selectedLocationId === homewoodId || selectedLocationId === welchId)) { + checkbox.style.display = 'block'; + console.log(selectedLocationId === homewoodId ? "Homewood selected" : "Welch selected"); + } else { + checkbox.style.display = 'none'; + } + }; + }] + }); + /*Services */ /* Simple service used to capitalize the first letter of a string */ @@ -70,6 +102,21 @@ } }); + /* This service is used to get the patron/user's info -- may not be needed, but could be handy */ + app.service("primawsRest", ['$http', function ($http) { + this.myAccountPersonalSettings = function () { + return $http({ + method: 'GET', + url: '/primaws/rest/priv/myaccount/personal_settings', + headers: { + 'Authorization': 'Bearer "' + sessionStorage.primoExploreJwt + '"', + } + }); + } + }]); + + + /* This service is used to keep track of whether the user is logged in or not. */ app.service('AuthService', function () { var isLoggedIn = false;