From 3c51ed8deb9b5b0143208c24162128e3250f8fe2 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:50:11 -0700 Subject: [PATCH] Not! --- ...ustom-fields-query-dropdown.component.html | 4 ++++ src-ui/src/app/data/custom-field-query.ts | 24 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) 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 + ) + } }