Skip to content

Commit

Permalink
Allow disabling time range
Browse files Browse the repository at this point in the history
  • Loading branch information
amitfin committed May 22, 2023
1 parent c4767c4 commit 63be8b4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion daily-schedule-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class DailyScheduleCard extends HTMLElement {

_setCardRowValue(content, state) {
let value = state
.filter((range) => !range.disabled)
.map((range) => range.from.slice(0, -3) + "-" + range.to.slice(0, -3))
.join(", ");
if (!value.length) {
Expand Down Expand Up @@ -261,9 +262,17 @@ class DailyScheduleCard extends HTMLElement {
}.bind(this);
row.appendChild(to_input);

const toggle = document.createElement("ha-switch");
toggle.style.marginLeft = "auto";
toggle.checked = !range.disabled;
toggle.addEventListener("change", () => {
range.disabled = !range.disabled;
this._saveBackendEntity();
});
row.appendChild(toggle);

const remove = document.createElement("ha-icon");
remove.icon = "mdi:delete-outline";
remove.style.marginLeft = "auto";
remove.style.cursor = "pointer";
remove.onclick = function () {
this._dialog._schedule = this._dialog._schedule.filter((_, i) => i !== index);
Expand Down

0 comments on commit 63be8b4

Please sign in to comment.