Skip to content

Commit

Permalink
Fix checkbox showing and hiding shifts
Browse files Browse the repository at this point in the history
The entire system is trash, this is patchcode over patchcode. Who uses
onclick attributes in this century
  • Loading branch information
PencilAmazing committed Jan 16, 2025
1 parent 20cd072 commit a483a7e
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions app/javascript/entrypoints/admin_availability_calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ const hideShowEvents = (event, eventName) => {
if (!(hiddenIds[id] === "none")) {
el.checked = showUnavailabilities === "block";
}
showUnavailabilities = document.getElementById(
"hide-show-unavailabilities"
).checked
? "block"
: "none";
// showUnavailabilities = document.getElementById(
// "hide-show-unavailabilities"
// ).checked
// ? "block"
// : "none";
});
} else if (eventName === "id") {
document.querySelectorAll(`[data-user-id="${event}"]`).forEach((el) => {
Expand All @@ -345,17 +345,20 @@ const hideShowEvents = (event, eventName) => {
}
if (eventName === "check") {
for (let e of calendar.getEvents()) {
e.setProp("display", showUnavailabilities);
//e.setProp("display", showUnavailabilities);
}
}
};

// Hide/Show unavailabilities toggle
// FIXME This whole thing is a disaster, get rid of it
document
.getElementById("hide-show-unavailabilities")
.addEventListener("click", () => {
showUnavailabilities = showUnavailabilities === "block" ? "none" : "block";
hideShowEvents(showUnavailabilities, "unavailabilities");
.addEventListener("change", (total) => {
document.querySelectorAll(".shift-hide-button").forEach((i) => {
i.checked = total.target.checked;
i.dispatchEvent(new Event("click"));
});
});

// Hide/Show unavailabilities for a single staff
Expand Down

0 comments on commit a483a7e

Please sign in to comment.