From 59aa16702d4e6eb78093391c6bf9c801edbffa54 Mon Sep 17 00:00:00 2001 From: aarkue Date: Wed, 28 Aug 2024 23:36:02 +0200 Subject: [PATCH] Update & Improve Predicate Names --- frontend/src/components/TimeDurationInput.tsx | 22 +++++---- .../helper/box/FilterChooser.tsx | 48 +++++++++---------- .../helper/box/FilterOrConstraintEditor.tsx | 36 +++++++------- 3 files changed, 57 insertions(+), 49 deletions(-) diff --git a/frontend/src/components/TimeDurationInput.tsx b/frontend/src/components/TimeDurationInput.tsx index 7d4224f..bbb977b 100644 --- a/frontend/src/components/TimeDurationInput.tsx +++ b/frontend/src/components/TimeDurationInput.tsx @@ -59,9 +59,11 @@ export function formatSeconds( export default function TimeDurationInput({ durationSeconds, onChange, + placeholder }: { durationSeconds: number; onChange: (newSeconds: number | undefined) => unknown; + placeholder?: string; }) { const [unit, setUnit] = useState<(typeof TIME_DURATION_UNITS)[number]>( getFittingUnit(durationSeconds), @@ -82,7 +84,8 @@ export default function TimeDurationInput({ ); }, [durationSeconds]); - function handleValueChange(inputValue: string) { + function handleValueChange(inputValue: string, useUnit = unit) { + inputValue = inputValue.toLowerCase(); if ( inputValue === "∞" || inputValue === "inf" || @@ -106,7 +109,7 @@ export default function TimeDurationInput({ const val = parseFloat(inputValue); if (!isNaN(val)) { setValue(val); - onChange(val * unitFactorFromSeconds(unit)); + onChange(val * unitFactorFromSeconds(useUnit)); setValueString(val.toString()); } else { setValueString(""); @@ -116,7 +119,7 @@ export default function TimeDurationInput({ return (
- { handleValueChange(ev.currentTarget.value); @@ -133,12 +136,15 @@ export default function TimeDurationInput({ options={TIME_DURATION_UNITS.map((u) => ({ value: u, label: u }))} onChange={(newUnitIn) => { const newUnit = newUnitIn as (typeof TIME_DURATION_UNITS)[number]; - const convertedValue = - value * - (unitFactorFromSeconds(unit) / unitFactorFromSeconds(newUnit)); - setValue(convertedValue); - setValueString(convertedValue.toString()); + console.log({newUnit,value,unit}) + // const convertedValue = + // value * + // (unitFactorFromSeconds(unit) / unitFactorFromSeconds(newUnit)); + // setValue(convertedValue); + // setValueString(convertedValue.toString()); setUnit(newUnit); + handleValueChange(value.toString(),newUnit); + }} name={"Unit"} value={unit} diff --git a/frontend/src/routes/visual-editor/helper/box/FilterChooser.tsx b/frontend/src/routes/visual-editor/helper/box/FilterChooser.tsx index 9f2dc2d..a283c52 100644 --- a/frontend/src/routes/visual-editor/helper/box/FilterChooser.tsx +++ b/frontend/src/routes/visual-editor/helper/box/FilterChooser.tsx @@ -159,55 +159,55 @@ export default function FilterChooser({ } options={[ { - label: "Object associated with Event", + label: "E2O: Event-To-Object Relationship", value: "O2E", }, { - label: "Object associated with Object", + label: "O2O: Object-To-Object Relationship", value: "O2O", }, { - label: "Time between Events", + label: "TBE: Time between Events", value: "TimeBetweenEvents", }, + // { + // label: "Variables not equal", + // value: "NotEqual", + // }, { - label: "Variables not equal", - value: "NotEqual", - }, - { - label: "CEL Script (Basic Filter)", - value: "BasicFilterCEL", - }, - { - label: "Event Attribute Value", + label: "EAE/EAR: Event Attribute Value", value: "EventAttributeValueFilter", }, { - label: "Object Attribute Value", + label: "OAE/OAR: Object Attribute Value", value: "ObjectAttributeValueFilter", }, + { + label: "BasicCEL: Basic CEL Script", + value: "BasicFilterCEL", + }, ...(alertState.type !== "filter" || alertState.mode !== "edit" || alertState.wasSizeFilter ? [ { - label: "Number of Child Bindings", + label: "CBS: Child Bindings Set Size", value: "NumChilds", }, { - label: "Child Binding Sets Equal", + label: "CBE: Child Binding Sets Equal", value: "BindingSetEqual", }, { - label: "Child Binding Set Projects Equal", - value: "BindingSetProjectionEqual", + label: "CBPS: Projected Child Bindings Set Size", + value: "NumChildsProj", }, { - label: "Number of Projected Child Bindings", - value: "NumChildsProj", + label: "CBPE: Projected Child Binding Sets Equal", + value: "BindingSetProjectionEqual", }, { - label: "CEL Script (Advanced Filter/Constraint)", + label: "AdvCEL: Advanced CEL Script", value: "AdvancedCEL", }, ] @@ -215,10 +215,10 @@ export default function FilterChooser({ ...(alertState.type === "constraint" ? [ - { label: "Child Satisfied (SAT)", value: "SAT" }, - { label: "Child not Satisfied (NOT)", value: "NOT" }, - { label: "Logic AND", value: "AND" }, - { label: "Logic OR", value: "OR" }, + { label: "SAT: All Child Bindings Satisfied", value: "SAT" }, + { label: "NOT: Logic NOT", value: "NOT" }, + { label: "OR: Logic OR", value: "OR" }, + { label: "AND: Logic AND", value: "AND" }, ] : []), ]} diff --git a/frontend/src/routes/visual-editor/helper/box/FilterOrConstraintEditor.tsx b/frontend/src/routes/visual-editor/helper/box/FilterOrConstraintEditor.tsx index 62159d5..aadd16a 100644 --- a/frontend/src/routes/visual-editor/helper/box/FilterOrConstraintEditor.tsx +++ b/frontend/src/routes/visual-editor/helper/box/FilterOrConstraintEditor.tsx @@ -47,6 +47,16 @@ export default function FilterOrConstraintEditor< case "O2E": return ( <> + { + if (newV !== undefined) { + value.event = newV; + updateValue({ ...value }); + } + }} + /> - { - if (newV !== undefined) { - value.event = newV; - updateValue({ ...value }); - } - }} - /> - { if (newVal !== undefined && isFinite(newVal)) { @@ -230,7 +230,7 @@ export default function FilterOrConstraintEditor< } }} /> - { if (newVal !== undefined && isFinite(newVal)) { @@ -257,7 +257,7 @@ export default function FilterOrConstraintEditor< } }} /> - { @@ -271,7 +271,7 @@ export default function FilterOrConstraintEditor< }} /> - { @@ -1056,6 +1056,7 @@ function ChildSetSelector({ } }} name={"Child Set"} + title="Child Set" value={value ?? ""} /> ); @@ -1071,7 +1072,7 @@ function AttributeNameSelector({ availableAttributes: string[]; }) { return ( - ({ label: v, value: v, @@ -1122,6 +1123,7 @@ function AttributeValueFilterSelector({ } }} name={"Attribute Type"} + title="Attribute Type" value={value?.type ?? "String"} /> {value?.type === "Boolean" && ( @@ -1137,7 +1139,7 @@ function AttributeValueFilterSelector({ )} {(value?.type === "Float" || value?.type === "Integer") && (
- {"-"} -