1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 10:48:44 +00:00
Files
frontend/js/common/component/script/index.js
Paulus Schoutsen 0707528bd7 Entity dropdown improvement (#674)
* Ignore hass changes while dropdown is open

* Upgrade vaadin-combo-box

* Fix styling on dev-service panel

* Fix styling for ha-entity-dropdown

* Fix height vaadin-combo-box dropdown

* Rename ha-entity-dropdown to ha-entity-picker

* More entity improvement (#675)

* Update script and automation editor to use entity picker

* Add entity and service picker to service dev panel

* Lint
2017-11-25 16:00:43 -08:00

52 lines
1.1 KiB
JavaScript

import { h, Component } from 'preact';
import ActionRow from './action_row.js';
export default class Script extends Component {
constructor() {
super();
this.addAction = this.addAction.bind(this);
this.actionChanged = this.actionChanged.bind(this);
}
addAction() {
const script = this.props.script.concat({
service: '',
});
this.props.onChange(script);
}
actionChanged(index, newValue) {
const script = this.props.script.concat();
if (newValue === null) {
script.splice(index, 1);
} else {
script[index] = newValue;
}
this.props.onChange(script);
}
render({ script, hass }) {
return (
<div class="script">
{script.map((act, idx) => (
<ActionRow
index={idx}
action={act}
onChange={this.actionChanged}
hass={hass}
/>))}
<paper-card>
<div class='card-actions add-card'>
<paper-button onTap={this.addAction}>Add action</paper-button>
</div>
</paper-card>
</div>
);
}
}