251 files
This commit is contained in:
@@ -43,6 +43,14 @@ export function createIncentiveCard(P) {
|
||||
return fn ? fn(this.hass, key, params) : key;
|
||||
}
|
||||
|
||||
/** Avatar: child's photo → MDI avatar → default icon. */
|
||||
_avatarGlyph(source, fallback = "mdi:account-circle", cls = "tm-face-img") {
|
||||
const face = window.__taskmate_child_visual(source);
|
||||
return face.kind === "image"
|
||||
? html`<img class="${cls}" src="${face.url}" alt="" loading="lazy">`
|
||||
: html`<ha-icon icon="${face.kind === "icon" ? face.icon : fallback}"></ha-icon>`;
|
||||
}
|
||||
|
||||
_tp(key, params) {
|
||||
return this._t(P.i18n + "." + key, params);
|
||||
}
|
||||
@@ -448,7 +456,9 @@ export function createIncentiveCard(P) {
|
||||
}
|
||||
|
||||
_getChildren() {
|
||||
return this._getAttrs().children || [];
|
||||
// Adult profiles stay off the picker unless show_adults is set (#1071).
|
||||
const all = this._getAttrs().children || [];
|
||||
return (window.__taskmate_family_children ? window.__taskmate_family_children(all, this.config) : all);
|
||||
}
|
||||
|
||||
_getBonuses() {
|
||||
@@ -617,7 +627,7 @@ export function createIncentiveCard(P) {
|
||||
${children.map(c => html`
|
||||
<div class="child-tab ${selected?.id === c.id ? "selected" : ""}"
|
||||
@click=${() => this._selectChild(c.id)}>
|
||||
<ha-icon icon="${c.avatar || "mdi:account-circle"}"></ha-icon>
|
||||
${this._avatarGlyph(c, "mdi:account-circle", "tm-face-chip")}
|
||||
${c.name}
|
||||
</div>
|
||||
`)}
|
||||
@@ -821,11 +831,11 @@ export function createIncentiveCard(P) {
|
||||
_designTone(i) { return `var(--tmd-c${(i % 6) + 1})`; }
|
||||
|
||||
_av(child, tone, size) {
|
||||
const a = child.avatar || "";
|
||||
const inner = a.startsWith("mdi:")
|
||||
? html`<ha-icon icon="${a}"></ha-icon>`
|
||||
: a
|
||||
? html`<img src="${a}" alt="${child.name}">`
|
||||
const face = window.__taskmate_child_visual(child);
|
||||
const inner = face.kind === "icon"
|
||||
? html`<ha-icon icon="${face.icon}"></ha-icon>`
|
||||
: face.kind === "image"
|
||||
? html`<img src="${face.url}" alt="${child.name}">`
|
||||
: (child.name || "?").split(" ").map(w => w[0]).slice(0, 2).join("").toUpperCase();
|
||||
return html`<div class="av" style="--av:${size}px;--ac:${tone}">${inner}</div>`;
|
||||
}
|
||||
@@ -1087,6 +1097,7 @@ export function createIncentiveCard(P) {
|
||||
title: this._t('common.editor.card_title'),
|
||||
show_parent_actions: this._t('common.editor.show_parent_actions'),
|
||||
card_design: this._t('common.design.field_label'),
|
||||
show_adults: this._t('common.editor.show_adults'),
|
||||
};
|
||||
return labels[entry.name] ?? entry.name;
|
||||
};
|
||||
@@ -1095,6 +1106,7 @@ export function createIncentiveCard(P) {
|
||||
const helpers = {
|
||||
entity: this._t('common.editor.overview_entity_helper'),
|
||||
show_parent_actions: this._t('common.editor.show_parent_actions_helper'),
|
||||
show_adults: this._t('common.editor.show_adults_helper'),
|
||||
};
|
||||
return helpers[entry.name] ?? '';
|
||||
};
|
||||
@@ -1106,6 +1118,7 @@ export function createIncentiveCard(P) {
|
||||
title: this.config.title || '',
|
||||
show_parent_actions: this.config.show_parent_actions !== false,
|
||||
card_design: this.config.card_design || 'global',
|
||||
show_adults: this.config.show_adults === true,
|
||||
};
|
||||
return html`
|
||||
<div class="info-note">
|
||||
@@ -1115,7 +1128,7 @@ export function createIncentiveCard(P) {
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${data}
|
||||
.schema=${this._buildSchema()}
|
||||
.schema=${this._buildSchema().concat(window.__taskmate_adults_field ? window.__taskmate_adults_field(this.hass, this.config) : [])}
|
||||
.computeLabel=${this._computeLabel}
|
||||
.computeHelper=${this._computeHelper}
|
||||
@value-changed=${this._formChanged}
|
||||
@@ -1145,6 +1158,7 @@ export function createIncentiveCard(P) {
|
||||
for (const [key, value] of Object.entries(newValues)) {
|
||||
if (value === '' || value === null || value === undefined) delete newConfig[key];
|
||||
else if (key === 'card_design' && value === 'global') delete newConfig[key];
|
||||
else if (key === 'show_adults' && value === false) delete newConfig[key];
|
||||
else newConfig[key] = value;
|
||||
}
|
||||
this._fire(newConfig);
|
||||
|
||||
Reference in New Issue
Block a user