-
-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-50581 Calendar: Repair the removal of a custom field
- Loading branch information
Showing
4 changed files
with
80 additions
and
43 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
calendar/calendar-tool/tool/src/webapp/js/sakai-calendar-fields.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 += "<li>" + node.getAttribute("name") + "</li>"; | ||
} | ||
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters