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

Fix add task fields #142

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
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
35 changes: 25 additions & 10 deletions grocy-chores-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ import {DateTime} from "luxon";
import style from './style.js';

class GrocyChoresCard extends LitElement {

async loadCustomCreateTaskElements() {
if(!customElements.get("ha-date-input") || !customElements.get("ha-textfield")) {
const cardHelpers = await window.loadCardHelpers();
if(!customElements.get("ha-date-input")) {
await cardHelpers.importMoreInfoControl("date");
}
if(!customElements.get("ha-textfield")) {
await cardHelpers.importMoreInfoControl("text");
}
}
}

static get styles() {
return style;
}
Expand Down Expand Up @@ -178,6 +191,10 @@ class GrocyChoresCard extends LitElement {
}
this.config = config;
this._processItems();
if(this.config.show_create_task) {
this.loadCustomCreateTaskElements();
}

}

render() {
Expand Down Expand Up @@ -374,20 +391,18 @@ class GrocyChoresCard extends LitElement {
<mwc-button @click=${() => this._addTask()}>
<ha-icon class="add-icon" icon="mdi:plus"></ha-icon>
</mwc-button>
<paper-input
<ha-textfield
id="add-task"
class="add-input"
no-label-float
placeholder=${this._translate("Add task")}>
</paper-input>
<paper-input
.placeholder=${this._translate("Add task")}>
</ha-textfield>
<ha-date-input
id="add-date"
class="add-input"
type="date"
no-label-float
placeholder=${this._translate("Optional due date")}
value="${this._taskDueDateInputFormat()}">
</paper-input>
.locale=${this._hass.locale}
.label=${this._translate("Optional due date")}
.value="${this._taskDueDateInputFormat()}">
</ha-date-input>
</div>
`
}
Expand Down