mirror of
https://github.com/xiaoshi930/xiaoshi-pad-card.git
synced 2025-11-28 16:49:42 +00:00
Update xiaoshi-device-consumables-card.js
This commit is contained in:
@@ -502,7 +502,6 @@ class XiaoshiConsumablesCardEditor extends LitElement {
|
|||||||
} else {
|
} else {
|
||||||
newEntities = [...currentEntities, {
|
newEntities = [...currentEntities, {
|
||||||
entity_id: entityId,
|
entity_id: entityId,
|
||||||
attribute: null,
|
|
||||||
overrides: undefined
|
overrides: undefined
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@@ -544,10 +543,18 @@ class XiaoshiConsumablesCardEditor extends LitElement {
|
|||||||
const newEntities = [...currentEntities];
|
const newEntities = [...currentEntities];
|
||||||
|
|
||||||
if (newEntities[index]) {
|
if (newEntities[index]) {
|
||||||
newEntities[index] = {
|
const trimmedValue = attributeValue.trim();
|
||||||
...newEntities[index],
|
if (trimmedValue === '') {
|
||||||
attribute: attributeValue.trim() || null
|
// 如果属性为空,则从配置中移除 attribute 字段
|
||||||
};
|
const { attribute, ...entityWithoutAttribute } = newEntities[index];
|
||||||
|
newEntities[index] = entityWithoutAttribute;
|
||||||
|
} else {
|
||||||
|
// 如果属性不为空,则设置属性值
|
||||||
|
newEntities[index] = {
|
||||||
|
...newEntities[index],
|
||||||
|
attribute: trimmedValue
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config = {
|
this.config = {
|
||||||
|
|||||||
Reference in New Issue
Block a user