mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-30 20:56:36 +00:00
Fix editing delay action (#4309)
This commit is contained in:
parent
808cde033f
commit
73b3262491
@ -1,14 +1,12 @@
|
||||
import { h } from "preact";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import { onChangeEvent } from "../../../../common/preact/event";
|
||||
import { AutomationComponent } from "../automation-component";
|
||||
|
||||
export default class DelayAction extends AutomationComponent<any> {
|
||||
private onChange: (obj: any) => void;
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.onChange = onChangeEvent.bind(this, "action");
|
||||
this.onChange = this.onChange.bind(this);
|
||||
}
|
||||
|
||||
public render({ action, localize }) {
|
||||
@ -26,6 +24,20 @@ export default class DelayAction extends AutomationComponent<any> {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
private onChange(ev) {
|
||||
if (
|
||||
!this.initialized ||
|
||||
ev.target.value === this.props.action[ev.target.name]
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.onChange(this.props.index, {
|
||||
...this.props.action,
|
||||
[ev.target.name]: ev.target.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
(DelayAction as any).defaultConfig = {
|
||||
|
@ -18,6 +18,9 @@ export default class WaitAction extends AutomationComponent<any> {
|
||||
// Gets fired on mount. If empty, onChangeEvent removes attribute.
|
||||
// Without the attribute this action is no longer matched to this component.
|
||||
public onTemplateChange(ev) {
|
||||
if (!this.initialized) {
|
||||
return;
|
||||
}
|
||||
this.props.onChange(this.props.index, {
|
||||
...this.props.action,
|
||||
[ev.target.getAttribute("name")]: ev.target.value,
|
||||
|
Loading…
x
Reference in New Issue
Block a user