[ACS-3586] ACA/Folder Rules: Adding a rule to a Folder seems to break the Folder Rules UI (#2663)

* [ACS-3586] ACA/Folder Rules: Adding a rule to a Folder seems to break the Folder Rules UI

* refactored condition statement

* linter

* parseSimpleCondition fn
This commit is contained in:
Nikita Maliarchuk 2022-09-23 10:29:46 +02:00 committed by GitHub
parent dc215dc034
commit 1f0d590a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,10 +175,21 @@ export class FolderRulesService {
inverted: obj.inverted ?? false,
booleanMode: obj.booleanMode ?? 'and',
compositeConditions: (obj.compositeConditions || []).map((condition) => this.formatCompositeCondition(condition)),
simpleConditions: (obj.simpleConditions || []).map((condition) => this.formatSimpleCondition(condition))
simpleConditions: this.parseSimpleCondition(obj.simpleConditions)
};
}
private parseSimpleCondition(arr) {
if (arr) {
if (arr.every((element) => element === null)) {
return [];
}
return arr.map((condition) => this.formatSimpleCondition(condition));
} else {
return [];
}
}
private formatSimpleCondition(obj): RuleSimpleCondition {
return {
field: obj.field || 'cm:name',