Skip to content

Commit

Permalink
Fix adding tasks (#160)
Browse files Browse the repository at this point in the history
* Fix adding tasks

Display was set to none which was either always broken or then it broke recently
but the whole add-task-row was hidden.
Also removed the default value on the date-input, since the date is optional
if you set it to something, you can't set it back to nothing.

* Make the add-task-row hidden by default
  • Loading branch information
BlueSoapTurtle authored Nov 20, 2024
1 parent 2d01512 commit 5ddb5ed
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions grocy-chores-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class GrocyChoresCard extends LitElement {

_renderAddTask() {
return html`
<div style="display: none;" id="add-task-row" class="add-row">
<div id="add-task-row" class="add-row hidden-class">
<mwc-button @click=${() => this._addTask()}>
<ha-icon class="add-icon" icon="mdi:plus"></ha-icon>
</mwc-button>
Expand All @@ -400,8 +400,7 @@ class GrocyChoresCard extends LitElement {
id="add-date"
class="add-input"
.locale=${this._hass.locale}
.label=${this._translate("Optional due date")}
.value="${this._taskDueDateInputFormat()}">
.label=${this._translate("Optional due date")}>
</ha-date-input>
</div>
`
Expand Down Expand Up @@ -745,14 +744,14 @@ class GrocyChoresCard extends LitElement {
}

_toggleAddTask() {
const x = this.shadowRoot.getElementById("add-task-row");
const icon = this.shadowRoot.getElementById("add-task-icon");
if (x.style.display === "none") {
x.style.display = "flex";
icon.icon = "mdi:chevron-up";
const addTaskRow = this.shadowRoot.getElementById("add-task-row");
const addTaskIcon = this.shadowRoot.getElementById("add-task-icon");
if (addTaskRow.classList.contains('hidden-class')) {
addTaskRow.classList.remove('hidden-class');
addTaskIcon.icon = "mdi:chevron-up";
} else {
x.style.display = "none";
icon.icon = "mdi:chevron-down";
addTaskRow.classList.add('hidden-class');
addTaskIcon.icon = "mdi:chevron-down";
}
}

Expand Down

0 comments on commit 5ddb5ed

Please sign in to comment.