Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAK-50581 Calendar unable to remove a custom field #13048

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
SAK-50581 Calendar: Repair the removal of a custom field
hornersa committed Nov 20, 2024
commit 38be75d09814f17095c375272cff85f4e1b68249
64 changes: 64 additions & 0 deletions calendar/calendar-tool/tool/src/webapp/js/sakai-calendar-fields.js
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();
});
Original file line number Diff line number Diff line change
@@ -106,23 +106,23 @@
#end
</table>
<div class="act">
<input id="removeFieldButton" type="button" value="$tlang.getString('cust.rem.btn')" accesskey="d" />
<input id="removeFieldButton" type="button" value="$tlang.getString('cust.rem.btn')" accesskey="d" data-bs-toggle="modal" data-bs-target="#confirmation-modal" />
<input id="removeFieldSubmission" type="submit" name="eventSubmit_doDeletefield" class="d-none" />
</div >
<div class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" id="confirmation-modal">
<div class="modal-dialog modal-md">
<div class="modal fade" id="confirmation-modal" tabindex="-1" role="dialog" aria-hidden="true" aria-labelledby="exampleModalLabel">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="$tlang.getString('gen.close')"><span class="fa fa-times" aria-hidden="true"></span></button>
<h4 class="modal-title">$tlang.getString('cust.rem.btn')</h4>
<h4 class="modal-title" id="modalLabel">$tlang.getString('cust.rem.btn')</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="$tlang.getString('gen.close')"></button>
</div>
<div class="modal-body">
<div class="sak-banner-warn">$tlang.getString('java.alert.areyou')</div>
<ul id="deleted-event-list"></ul>
</div>
<div class="modal-footer act">
<button type="button" class="active" id="modal-btn-confirm">$tlang.getString('cust.confirm.yes')</button>
<button type="button" class="btn btn-default" id="modal-btn-cancel">$tlang.getString('cust.confirm.no')</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal" id="modal-btn-cancel">$tlang.getString('cust.confirm.no')</button>
</div>
</div>
</div>
@@ -131,33 +131,4 @@
<input type="hidden" name="sakai_csrf_token" value="$sakai_csrf_token" />
</form>
</div>

<script>
var confirmationModal = function(callback){
$('#removeFieldButton').on('click', function(e) {
if($("input[id*='addedFields']:checked").length > 0) {
e.preventDefault();
$('#noFieldSelected').hide();
$('#confirmation-modal').modal('show');
} else {
$('#noFieldSelected').show();
}
});

$('#modal-btn-confirm').on('click', function(){
callback(true);
$('#confirmation-modal').modal('hide');
});

$('#modal-btn-cancel').on('click', function(){
callback(false);
$('#confirmation-modal').modal('hide');
});
};

confirmationModal(function(confirm) {
if (confirm) {
$('#removeFieldSubmission').click();
}
});
</script>
<script src="/sakai-calendar-tool/js/sakai-calendar-fields.js"></script>
8 changes: 8 additions & 0 deletions library/src/skins/default/src/sass/base/_defaults.scss
Original file line number Diff line number Diff line change
@@ -176,13 +176,21 @@ input[type="checkbox"]{
background-repeat: no-repeat;
background-position: 1px 1px;
}
&:disabled{
cursor: not-allowed;
background-color: var(--sakai-background-color-3);
}
ottenhoff marked this conversation as resolved.
Show resolved Hide resolved
}
input[type="radio"]{
@include border-radius(24px);
&:checked{
background: var(--radio-button-background); // fallback support
background: radial-gradient(circle at center, var(--radio-button-background) 0%, var(--radio-button-background) 48%, var(--sakai-background-color-1) 58%);
}
&:disabled{
cursor: not-allowed;
background-color: var(--sakai-background-color-3);
}
}

select{
Original file line number Diff line number Diff line change
@@ -1371,12 +1371,6 @@
}

div.wicket-modal, .#{$namespace}sakai-gradebookng {
/* Bootstrap > Morpheus overrides */
.checkbox input[type="checkbox"][disabled],
.radio input[type="radio"][disabled]{
background-color: var(--sakai-background-color-3);
cursor: not-allowed;
}
.checkbox input[type="checkbox"][disabled]+span,
.radio input[type="radio"][disabled]+span,
.checkbox input[type="checkbox"][disabled]+label,
@@ -1668,4 +1662,4 @@ max-height:100px;
.gb-cell-selected {
background-color: rgba(173, 216, 230, 0.2);
border: 2px solid rgba(173, 216, 230, 0.7);
}
}