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 { h } from "preact";
|
||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-input/paper-input";
|
||||||
import { onChangeEvent } from "../../../../common/preact/event";
|
|
||||||
import { AutomationComponent } from "../automation-component";
|
import { AutomationComponent } from "../automation-component";
|
||||||
|
|
||||||
export default class DelayAction extends AutomationComponent<any> {
|
export default class DelayAction extends AutomationComponent<any> {
|
||||||
private onChange: (obj: any) => void;
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.onChange = onChangeEvent.bind(this, "action");
|
this.onChange = this.onChange.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public render({ action, localize }) {
|
public render({ action, localize }) {
|
||||||
@ -26,6 +24,20 @@ export default class DelayAction extends AutomationComponent<any> {
|
|||||||
</div>
|
</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 = {
|
(DelayAction as any).defaultConfig = {
|
||||||
|
@ -18,6 +18,9 @@ export default class WaitAction extends AutomationComponent<any> {
|
|||||||
// Gets fired on mount. If empty, onChangeEvent removes attribute.
|
// Gets fired on mount. If empty, onChangeEvent removes attribute.
|
||||||
// Without the attribute this action is no longer matched to this component.
|
// Without the attribute this action is no longer matched to this component.
|
||||||
public onTemplateChange(ev) {
|
public onTemplateChange(ev) {
|
||||||
|
if (!this.initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.props.onChange(this.props.index, {
|
this.props.onChange(this.props.index, {
|
||||||
...this.props.action,
|
...this.props.action,
|
||||||
[ev.target.getAttribute("name")]: ev.target.value,
|
[ev.target.getAttribute("name")]: ev.target.value,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user