mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 02:38:53 +00:00
* 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
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
import { h, Component } from 'preact';
|
|
|
|
import ConditionRow from './condition_row.js';
|
|
|
|
export default class Condition extends Component {
|
|
constructor() {
|
|
super();
|
|
|
|
this.addCondition = this.addCondition.bind(this);
|
|
this.conditionChanged = this.conditionChanged.bind(this);
|
|
}
|
|
|
|
addCondition() {
|
|
const condition = this.props.condition.concat({
|
|
condition: 'state',
|
|
});
|
|
|
|
this.props.onChange(condition);
|
|
}
|
|
|
|
conditionChanged(index, newValue) {
|
|
const condition = this.props.condition.concat();
|
|
|
|
if (newValue === null) {
|
|
condition.splice(index, 1);
|
|
} else {
|
|
condition[index] = newValue;
|
|
}
|
|
|
|
this.props.onChange(condition);
|
|
}
|
|
|
|
render({ condition, hass }) {
|
|
return (
|
|
<div class="triggers">
|
|
{condition.map((cnd, idx) => (
|
|
<ConditionRow
|
|
index={idx}
|
|
condition={cnd}
|
|
onChange={this.conditionChanged}
|
|
hass={hass}
|
|
/>))}
|
|
<paper-card>
|
|
<div class='card-actions add-card'>
|
|
<paper-button onTap={this.addCondition}>Add condition</paper-button>
|
|
</div>
|
|
</paper-card>
|
|
</div>
|
|
);
|
|
}
|
|
}
|