1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00
Files
frontend/js/common/component/script/call_service.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

53 lines
1.0 KiB
JavaScript

import { h, Component } from 'preact';
import JSONTextArea from '../json_textarea.js';
export default class CallServiceAction extends Component {
constructor() {
super();
this.serviceChanged = this.serviceChanged.bind(this);
this.serviceDataChanged = this.serviceDataChanged.bind(this);
}
serviceChanged(ev) {
this.props.onChange(this.props.index, {
...this.props.action,
service: ev.target.value,
});
}
serviceDataChanged(data) {
this.props.onChange(this.props.index, {
...this.props.action,
data,
});
}
render({ action, hass }) {
const { service, data } = action;
return (
<div>
<ha-service-picker
hass={hass}
value={service}
onChange={this.serviceChanged}
/>
<JSONTextArea
label="Service Data"
value={data}
onChange={this.serviceDataChanged}
/>
</div>
);
}
}
CallServiceAction.configKey = 'service';
CallServiceAction.defaultConfig = {
alias: '',
service: '',
data: {}
};