diff --git a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html index 6c46275cc..d2d5ca4c6 100644 --- a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html +++ b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html @@ -108,6 +108,10 @@ + @if (expression.negatable) { + + + }
@for (element of expression.value; track element.id; let i = $index) { diff --git a/src-ui/src/app/data/custom-field-query.ts b/src-ui/src/app/data/custom-field-query.ts index ab801d85e..70fc4f374 100644 --- a/src-ui/src/app/data/custom-field-query.ts +++ b/src-ui/src/app/data/custom-field-query.ts @@ -268,8 +268,6 @@ export class CustomFieldQueryExpression extends CustomFieldQueryElement { super(CustomFieldQueryElementType.Expression) let values ;[this._operator, values] = expressionArray - console.log(values) - if (!values || values.length === 0) { this._value = [] } else if (values?.length > 0 && values[0] instanceof Array) { @@ -291,7 +289,12 @@ export class CustomFieldQueryExpression extends CustomFieldQueryElement { } }) } else { - this._value = [new CustomFieldQueryExpression(values as any)] + const expression = new CustomFieldQueryExpression(values as any) + expression.depth = this.depth + 1 + expression.changed.subscribe(() => { + this.changed.next(this) + }) + this._value = [expression] } } @@ -299,6 +302,13 @@ export class CustomFieldQueryExpression extends CustomFieldQueryElement { let value if (this._value instanceof Array) { value = this._value.map((atom) => atom.serialize()) + // If the expression is negated it should have only one child which is an expression + if ( + this._operator === CustomFieldQueryLogicalOperator.Not && + value.length === 1 + ) { + value = value[0] + } } else { value = value.serialize() } @@ -328,4 +338,12 @@ export class CustomFieldQueryExpression extends CustomFieldQueryElement { this.changed.next(this) }) } + + public get negatable(): boolean { + return ( + this.value.length === 1 && + (this.value[0] as CustomFieldQueryElement).type === + CustomFieldQueryElementType.Expression + ) + } }