Add an All Days button to the schedule editor
All checks were successful
Deploy / deploy (push) Successful in 25s
All checks were successful
Deploy / deploy (push) Successful in 25s
Selects all 7 day toggles in one click instead of clicking each one. Scoped selectors to .day-toggle[data-day] throughout so the new button (which has no data-day) can't accidentally get read as a day or toggled by the generic day-button click handler. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H6TgffxTvYhqxykAbVQg2v
This commit is contained in:
parent
0f336b3d0c
commit
63e2296d1c
3 changed files with 12 additions and 4 deletions
|
|
@ -59,19 +59,26 @@ function initRuleCard(card) {
|
|||
saveSchedule(card, { enabledOverride: e.target.checked });
|
||||
});
|
||||
|
||||
card.querySelectorAll(".day-toggle").forEach((btn) => {
|
||||
card.querySelectorAll(".day-toggle[data-day]").forEach((btn) => {
|
||||
btn.addEventListener("click", () => btn.classList.toggle("active"));
|
||||
});
|
||||
|
||||
const allDaysBtn = card.querySelector(".day-toggle-all");
|
||||
if (allDaysBtn) {
|
||||
allDaysBtn.addEventListener("click", () => {
|
||||
card.querySelectorAll(".day-toggle[data-day]").forEach((btn) => btn.classList.add("active"));
|
||||
});
|
||||
}
|
||||
|
||||
card.querySelector(".add-schedule").addEventListener("click", () => {
|
||||
const time = card.querySelector(".new-time").value;
|
||||
const days = [...card.querySelectorAll(".day-toggle.active")].map((b) => b.dataset.day);
|
||||
const days = [...card.querySelectorAll(".day-toggle[data-day].active")].map((b) => b.dataset.day);
|
||||
if (!time || days.length === 0) {
|
||||
alert("Pick a time and at least one day.");
|
||||
return;
|
||||
}
|
||||
addChip(card, time, days);
|
||||
card.querySelectorAll(".day-toggle.active").forEach((b) => b.classList.remove("active"));
|
||||
card.querySelectorAll(".day-toggle[data-day].active").forEach((b) => b.classList.remove("active"));
|
||||
saveSchedule(card);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue