From 38be75d09814f17095c375272cff85f4e1b68249 Mon Sep 17 00:00:00 2001 From: "Horner, Sean A" Date: Wed, 20 Nov 2024 14:09:14 -0800 Subject: [PATCH] SAK-50581 Calendar: Repair the removal of a custom field --- .../src/webapp/js/sakai-calendar-fields.js | 64 +++++++++++++++++++ .../chef_calendar-customize_fields.vm | 43 ++----------- .../default/src/sass/base/_defaults.scss | 8 +++ .../modules/tool/gradebook/_gradebook.scss | 8 +-- 4 files changed, 80 insertions(+), 43 deletions(-) create mode 100644 calendar/calendar-tool/tool/src/webapp/js/sakai-calendar-fields.js diff --git a/calendar/calendar-tool/tool/src/webapp/js/sakai-calendar-fields.js b/calendar/calendar-tool/tool/src/webapp/js/sakai-calendar-fields.js new file mode 100644 index 000000000000..cc2d2f4af354 --- /dev/null +++ b/calendar/calendar-tool/tool/src/webapp/js/sakai-calendar-fields.js @@ -0,0 +1,64 @@ +const deleteList = document.getElementById('deleted-event-list'); +const removeBtn = document.getElementById('removeFieldButton'); +const hiddenRemoveBtn = document.getElementById('removeFieldSubmission'); +const container = document.querySelector("#optionsForm"); + +function getCheckedFieldNodes() { + return container.querySelectorAll("input[id*='addedFields']:checked"); +} + +function getCheckedFieldList() { + const nodes = getCheckedFieldNodes(); + let list = ""; + for (const node of nodes) { + list += "
  • " + node.getAttribute("name") + "
  • "; + } + return list; +} + +function setRemoveButtonState() { + removeBtn.disabled = (getCheckedFieldNodes().length == 0); +} + +const checkboxes = container.querySelectorAll("input[id*='addedFields']"); +checkboxes.forEach(function(elem) { + elem.addEventListener("input", function() { + setRemoveButtonState(); + deleteList.innerHTML = getCheckedFieldList(); + }); +}); + +let confirmationModal = function(callback){ + const confirmBtn = document.getElementById('modal-btn-confirm'); + const cancelBtn = document.getElementById('modal-btn-cancel'); + + confirmBtn.addEventListener('click', () => { + callback(true); + }); + + confirmBtn.addEventListener('keydown', (event) => { + if (event.code === 'Space' || event.code === 'Enter') { + confirmBtn.click(); + } + }); + + cancelBtn.addEventListener('click', () => { + callback(false); + }); + + cancelBtn.addEventListener('keydown', (event) => { + if (event.code === 'Space' || event.code === 'Enter') { + cancelBtn.click(); + } + }); +}; + +confirmationModal(function(confirm) { + if (confirm) { + hiddenRemoveBtn.click(); + } +}); + +window.addEventListener("DOMContentLoaded", () => { + setRemoveButtonState(); +}); diff --git a/calendar/calendar-tool/tool/src/webapp/vm/calendar/chef_calendar-customize_fields.vm b/calendar/calendar-tool/tool/src/webapp/vm/calendar/chef_calendar-customize_fields.vm index 08c93e97be24..7dac2b0a421b 100644 --- a/calendar/calendar-tool/tool/src/webapp/vm/calendar/chef_calendar-customize_fields.vm +++ b/calendar/calendar-tool/tool/src/webapp/vm/calendar/chef_calendar-customize_fields.vm @@ -106,15 +106,15 @@ #end
    - +
    -