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 }) { return (
{condition.map((cnd, idx) => ( ))}
Add condition
); } }