Smart rules: Change operator to `OR` by default (#7)

This commit is contained in:
Víctor Falcón 2025-12-03 10:16:29 +01:00 committed by GitHub
parent 79180b1024
commit 4b11843916
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View File

@ -42,7 +42,7 @@ export function CreateAutomationRuleDialog({
const [priority, setPriority] = useState('10');
const [ruleStructure, setRuleStructure] = useState<RuleStructure>({
groups: [createEmptyGroup()],
groupOperator: 'and',
groupOperator: 'or',
});
const [categoryId, setCategoryId] = useState<string>('');
const [note, setNote] = useState('');

View File

@ -218,11 +218,11 @@ export function parseJsonLogic(jsonLogic: JsonLogicRule): RuleStructure {
groups: [
{
id: crypto.randomUUID(),
operator: 'and',
operator: 'or',
conditions: [],
},
],
groupOperator: 'and',
groupOperator: 'or',
};
if (!jsonLogic || Object.keys(jsonLogic).length === 0) {
@ -310,7 +310,7 @@ export function parseJsonLogic(jsonLogic: JsonLogicRule): RuleStructure {
: defaultStructure.groups[0].conditions,
},
],
groupOperator: 'and',
groupOperator: 'or',
};
}
}
@ -321,11 +321,11 @@ export function parseJsonLogic(jsonLogic: JsonLogicRule): RuleStructure {
groups: [
{
id: crypto.randomUUID(),
operator: 'and',
operator: 'or',
conditions: [parsed],
},
],
groupOperator: 'and',
groupOperator: 'or',
};
}
@ -344,7 +344,7 @@ export function createEmptyCondition(): Condition {
export function createEmptyGroup(): ConditionGroup {
return {
id: crypto.randomUUID(),
operator: 'and',
operator: 'or',
conditions: [createEmptyCondition()],
};
}