mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Allow changing entity id (#1508)
* Allow changing entity id * _entityId * Use set properties
This commit is contained in:
parent
201959841c
commit
f7d9aecf47
@ -48,7 +48,14 @@ class MoreInfoSettings extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
</app-toolbar>
|
</app-toolbar>
|
||||||
|
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<paper-input value="{{_name}}" label="[[localize('ui.dialogs.more_info_settings.name')]]"></paper-input>
|
<paper-input
|
||||||
|
value="{{_name}}"
|
||||||
|
label="[[localize('ui.dialogs.more_info_settings.name')]]"
|
||||||
|
></paper-input>
|
||||||
|
<paper-input
|
||||||
|
value="{{_entityId}}"
|
||||||
|
label="[[localize('ui.dialogs.more_info_settings.entity_id')]]"
|
||||||
|
></paper-input>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -70,6 +77,7 @@ class MoreInfoSettings extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_name: String,
|
_name: String,
|
||||||
|
_entityId: String,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,9 +92,15 @@ class MoreInfoSettings extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
|
|
||||||
_registryInfoChanged(newVal) {
|
_registryInfoChanged(newVal) {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
this._name = newVal.name;
|
this.setProperties({
|
||||||
|
_name: newVal.name,
|
||||||
|
_entityId: newVal.entity_id,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this._name = '';
|
this.setProperties({
|
||||||
|
_name: '',
|
||||||
|
_entityId: '',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,10 +114,17 @@ class MoreInfoSettings extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
type: 'config/entity_registry/update',
|
type: 'config/entity_registry/update',
|
||||||
entity_id: this.stateObj.entity_id,
|
entity_id: this.stateObj.entity_id,
|
||||||
name: this._name,
|
name: this._name,
|
||||||
|
new_entity_id: this._entityId,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.registryInfo = info;
|
this.registryInfo = info;
|
||||||
|
|
||||||
|
// Keep the more info dialog open at the new entity.
|
||||||
|
if (this.stateObj.entity_id !== this._entityId) {
|
||||||
|
this.fire('hass-more-info', { entityId: this._entityId });
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('save failed!');
|
alert(`save failed: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,8 @@
|
|||||||
"dialogs": {
|
"dialogs": {
|
||||||
"more_info_settings": {
|
"more_info_settings": {
|
||||||
"save": "Save",
|
"save": "Save",
|
||||||
"name": "Name"
|
"name": "Name",
|
||||||
|
"entity_id": "Entity ID"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"duration": {
|
"duration": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user