rebuilt condition editor
This commit is contained in:
1 parent
6da5a7592e
commit
cc2597c408
18 files changed
+599
-445
No files matched your search
@@ -1,28 +1,26 @@
|
||||
import { AutomationCondition, LogicCondition } from "types/automations/conditions";
|
||||
import {
|
||||
AutomationCondition,
|
||||
LogicCondition,
|
||||
} from "types/automations/conditions";
|
||||
|
||||
|
||||
export const genUpdateMethods = (
|
||||
condition: LogicCondition,
|
||||
onChange: (c: LogicCondition) => void
|
||||
) => (i: number) => ({
|
||||
onUpdate: (update: AutomationCondition) => onChange({
|
||||
export const genUpdateMethods =
|
||||
(condition: LogicCondition, onChange: (c: LogicCondition) => void) =>
|
||||
(i: number) => ({
|
||||
onUpdate: (update: AutomationCondition) =>
|
||||
onChange({
|
||||
...condition,
|
||||
conditions: [
|
||||
...condition.conditions.slice(0, i),
|
||||
update,
|
||||
...condition.conditions.slice(i + 1)
|
||||
]
|
||||
}),
|
||||
onDelete: (which: 'root' | number) => {
|
||||
if (which === 'root') {
|
||||
onChange({
|
||||
...condition,
|
||||
conditions: condition.conditions.slice(0, i).concat(
|
||||
condition.conditions.slice(i + 1)
|
||||
)
|
||||
})
|
||||
} else {
|
||||
throw new Error("Not Implemented")
|
||||
}
|
||||
}
|
||||
})
|
||||
...condition.conditions.slice(0, i),
|
||||
update,
|
||||
...condition.conditions.slice(i + 1),
|
||||
],
|
||||
}),
|
||||
onDelete: () => {
|
||||
onChange({
|
||||
...condition,
|
||||
conditions: condition.conditions
|
||||
.slice(0, i)
|
||||
.concat(condition.conditions.slice(i + 1)),
|
||||
});
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user