mirror of
https://github.com/xiaoshi930/xiaoshi-pad-card.git
synced 2025-11-28 16:49:42 +00:00
Update xiaoshi-device-balance-card.js
This commit is contained in:
@@ -466,11 +466,12 @@ class XiaoshiBalanceCardEditor extends LitElement {
|
|||||||
newEntities = currentEntities.filter(e => e.entity_id !== entityId);
|
newEntities = currentEntities.filter(e => e.entity_id !== entityId);
|
||||||
} else {
|
} else {
|
||||||
// 添加实体
|
// 添加实体
|
||||||
newEntities = [...currentEntities, {
|
const newEntity = {
|
||||||
entity_id: entityId,
|
entity_id: entityId,
|
||||||
attribute: null,
|
|
||||||
overrides: undefined
|
overrides: undefined
|
||||||
}];
|
};
|
||||||
|
// 只有在明确指定属性时才添加 attribute 字段
|
||||||
|
newEntities = [...currentEntities, newEntity];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config = {
|
this.config = {
|
||||||
@@ -510,10 +511,17 @@ class XiaoshiBalanceCardEditor extends LitElement {
|
|||||||
const newEntities = [...currentEntities];
|
const newEntities = [...currentEntities];
|
||||||
|
|
||||||
if (newEntities[index]) {
|
if (newEntities[index]) {
|
||||||
newEntities[index] = {
|
const updatedEntity = { ...newEntities[index] };
|
||||||
...newEntities[index],
|
|
||||||
attribute: attributeValue.trim() || null
|
if (attributeValue.trim()) {
|
||||||
};
|
// 只有当属性值不为空时才设置 attribute 字段
|
||||||
|
updatedEntity.attribute = attributeValue.trim();
|
||||||
|
} else {
|
||||||
|
// 如果属性值为空,则移除 attribute 字段
|
||||||
|
delete updatedEntity.attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
newEntities[index] = updatedEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config = {
|
this.config = {
|
||||||
|
|||||||
Reference in New Issue
Block a user