From 31b395d961128c56798681d2fc46577e557bc320 Mon Sep 17 00:00:00 2001
From: Leonardo <leomilho@gmail.com>
Date: Fri, 19 Jul 2024 17:09:59 +0200
Subject: [PATCH] feat((qb): is empty added

---
 libs/shared/lib/querybuilder/model/logic/general.ts   |  4 +++-
 .../lib/querybuilder/model/logic/stringFilters.tsx    | 11 +++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/libs/shared/lib/querybuilder/model/logic/general.ts b/libs/shared/lib/querybuilder/model/logic/general.ts
index e0dee2de5..063bb32cd 100644
--- a/libs/shared/lib/querybuilder/model/logic/general.ts
+++ b/libs/shared/lib/querybuilder/model/logic/general.ts
@@ -47,6 +47,7 @@ export enum StringFilterTypes {
   EQUAL = '==',
   NOT_EQUAL = '!=',
   LIKE = 'Like',
+  EMPTY = 'IsEmpty',
   // NOT_LIKE = 'Not Like',
   // IN = 'In',
   // NOT_IN = 'Not In',
@@ -108,7 +109,8 @@ export type LowerStatement = ['Lower', AnyStatement];
 export type UpperStatement = ['Upper', AnyStatement];
 export type SubstringStatement = ['Substring', AnyStatement, AnyStatement, AnyStatement];
 export type TrimStatement = ['Trim', AnyStatement];
-export type AllStringStatement = ConcatStatement | LowerStatement | UpperStatement | SubstringStatement | TrimStatement;
+export type EmptyStatement = [StringFilterTypes.EMPTY, AnyStatement];
+export type AllStringStatement = ConcatStatement | LowerStatement | UpperStatement | SubstringStatement | TrimStatement | EmptyStatement;
 
 // Dates
 export type DateStatement = ['Date', AnyStatement];
diff --git a/libs/shared/lib/querybuilder/model/logic/stringFilters.tsx b/libs/shared/lib/querybuilder/model/logic/stringFilters.tsx
index 3012370e7..c0cc1e6c6 100644
--- a/libs/shared/lib/querybuilder/model/logic/stringFilters.tsx
+++ b/libs/shared/lib/querybuilder/model/logic/stringFilters.tsx
@@ -54,6 +54,17 @@ export const StringFilters: Record<StringFilterTypes, GeneralDescription<StringF
     output: { name: StringFilterTypes.LIKE, type: 'bool' },
     logic: [StringFilterTypes.LIKE, '@i', '@1'],
   },
+  [StringFilterTypes.EMPTY]: {
+    key: 'stringFilterEmpty',
+    name: 'Is Empty',
+    type: StringFilterTypes.EMPTY,
+    description: 'Equal to an empty string or a NULL value',
+    input: { name: 'Value', type: 'string', default: '' },
+    numExtraInputs: 0,
+    inputs: [],
+    output: { name: StringFilterTypes.EMPTY, type: 'bool' },
+    logic: [StringFilterTypes.EMPTY, '@i'],
+  },
 };
 
 /** All available functions in the function bar. */
-- 
GitLab