From 89cd8db0d9e6630327552ad0a6c013213a83e670 Mon Sep 17 00:00:00 2001 From: "INFRAGISTICS\\IPetrov" Date: Thu, 19 Sep 2024 15:33:58 +0300 Subject: [PATCH 1/4] refactor(query-builder-sample): update QB sample 1 with nested entities --- .../query-builder-sample-1.component.html | 2 +- .../query-builder-sample-1.component.ts | 116 +++++++++++------- 2 files changed, 76 insertions(+), 42 deletions(-) diff --git a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.html b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.html index 273aa278a..a18b54b25 100644 --- a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.html +++ b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.html @@ -1,6 +1,6 @@
diff --git a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts index d78fbe679..ba0edc5e6 100644 --- a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts +++ b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { FilteringExpressionsTree, FilteringLogic, IExpressionTree, IgxQueryBuilderComponent, IgxStringFilteringOperand } from 'igniteui-angular'; +import { FilteringExpressionsTree, FilteringLogic, IExpressionTree, IgxBooleanFilteringOperand, IgxDateFilteringOperand, IgxNumberFilteringOperand, IgxQueryBuilderComponent, IgxStringFilteringOperand } from 'igniteui-angular'; @Component({ selector: 'app-query-builder-sample-1', @@ -7,52 +7,86 @@ import { FilteringExpressionsTree, FilteringLogic, IExpressionTree, IgxQueryBuil templateUrl: 'query-builder-sample-1.component.html' }) export class QueryBuilderSample1Component implements OnInit { + public entities: Array; + public companiesFields: Array; + public ordersFields: Array; public expressionTree: IExpressionTree; - - public fields: any[] = [ - { field: 'ID', dataType: 'string' }, - { field: 'CompanyName', dataType: 'string' }, - { field: 'ContactName', dataType: 'string' }, - { field: 'Employees', dataType: 'number' }, - { field: 'ContactTitle', dataType: 'string' }, - { field: 'DateCreated', dataType: 'date' }, - { field: 'TimeCreated', dataType: 'time' }, - { field: 'Address', dataType: 'string' }, - { field: 'City', dataType: 'string' }, - { field: 'Region', dataType: 'string' }, - { field: 'PostalCode', dataType: 'string' }, - { field: 'Phone', dataType: 'string' }, - { field: 'Fax', dataType: 'string' }, - { field: 'Contract', dataType: 'boolean' } - ]; public ngOnInit(): void { - const tree = new FilteringExpressionsTree(FilteringLogic.And); - tree.filteringOperands.push({ - fieldName: 'ID', - condition: IgxStringFilteringOperand.instance().condition('contains'), - searchVal: 'a', - ignoreCase: true + this.companiesFields = [ + { field: "ID", dataType: "string" }, + { field: "CompanyName", dataType: "string" }, + { field: "ContactName", dataType: "string" }, + { field: "Employees", dataType: "number" }, + { field: "ContactTitle", dataType: "string" }, + { field: "DateCreated", dataType: "date" }, + { field: "TimeCreated", dataType: "time" }, + { field: "Address", dataType: "string" }, + { field: "City", dataType: "string" }, + { field: "Region", dataType: "string" }, + { field: "PostalCode", dataType: "string" }, + { field: "Phone", dataType: "string" }, + { field: "Fax", dataType: "string" }, + { field: "Contract", dataType: "boolean" }, + ]; + + this.ordersFields = [ + { field: "CompanyID", dataType: "string" }, + { field: "OrderID", dataType: "number" }, + { field: "EmployeeId", dataType: "number" }, + { field: "OrderDate", dataType: "date" }, + { field: "RequiredDate", dataType: "date" }, + { field: "ShippedDate", dataType: "date" }, + { field: "ShipVia", dataType: "number" }, + { field: "Freight", dataType: "number" }, + { field: "ShipName", dataType: "string" }, + { field: "ShipCity", dataType: "string" }, + { field: "ShipPostalCode", dataType: "string" }, + { field: "ShipCountry", dataType: "string" }, + { field: "Region", dataType: "string" }, + ]; + + this.entities = [ + { + name: "Companies", + fields: this.companiesFields, + }, + { + name: "Orders", + fields: this.ordersFields, + } + ]; + + const innerTree = new FilteringExpressionsTree(FilteringLogic.And, undefined, 'Companies', ['ID']); + innerTree.filteringOperands.push({ + fieldName: 'Employees', + condition: IgxNumberFilteringOperand.instance().condition('greaterThan'), + conditionName: 'greaterThan', + searchVal: 100, }); - const orTree = new FilteringExpressionsTree(FilteringLogic.Or); - orTree.filteringOperands.push({ - fieldName: 'ID', - condition: IgxStringFilteringOperand.instance().condition('contains'), - searchVal: 'b', - ignoreCase: true + innerTree.filteringOperands.push({ + fieldName: 'Contact', + condition: IgxBooleanFilteringOperand.instance().condition('true'), + conditionName: 'true', }); - orTree.filteringOperands.push({ - fieldName: 'CompanyName', - condition: IgxStringFilteringOperand.instance().condition('contains'), - searchVal: 'c', - ignoreCase: true + + const tree = new FilteringExpressionsTree(FilteringLogic.And, undefined, 'Orders', ['*']); + tree.filteringOperands.push({ + fieldName: 'CompanyID', + condition: IgxStringFilteringOperand.instance().condition('in'), + conditionName: 'in', + searchTree: innerTree + }); + tree.filteringOperands.push({ + fieldName: 'OrderDate', + condition: IgxDateFilteringOperand.instance().condition('before'), + conditionName: 'before', + searchVal: new Date('2024-01-01T00:00:00.000Z') }); - tree.filteringOperands.push(orTree); tree.filteringOperands.push({ - fieldName: 'CompanyName', - condition: IgxStringFilteringOperand.instance().condition('contains'), - searchVal: 'd', - ignoreCase: true + fieldName: 'ShippedDate', + condition: IgxDateFilteringOperand.instance().condition('null'), + conditionName: 'null' }); this.expressionTree = tree; @@ -61,4 +95,4 @@ export class QueryBuilderSample1Component implements OnInit { public printExpressionTree(tree: IExpressionTree) { return tree ? JSON.stringify(tree, null, 2) : 'Please add an expression!'; } -} +} \ No newline at end of file From 1e5e8d11da8de1aad56bdec15631cc066cf3775f Mon Sep 17 00:00:00 2001 From: "INFRAGISTICS\\IPetrov" Date: Wed, 25 Sep 2024 18:20:49 +0300 Subject: [PATCH 2/4] fix(query-builder-sample) removed lint errors --- .../query-builder-sample-1.component.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts index ba0edc5e6..6d260d819 100644 --- a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts +++ b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { FilteringExpressionsTree, FilteringLogic, IExpressionTree, IgxBooleanFilteringOperand, IgxDateFilteringOperand, IgxNumberFilteringOperand, IgxQueryBuilderComponent, IgxStringFilteringOperand } from 'igniteui-angular'; +import { FilteringExpressionsTree, FilteringLogic, IExpressionTree, IgxBooleanFilteringOperand, IgxDateFilteringOperand, IgxNumberFilteringOperand, IgxStringFilteringOperand } from 'igniteui-angular'; @Component({ selector: 'app-query-builder-sample-1', @@ -7,9 +7,9 @@ import { FilteringExpressionsTree, FilteringLogic, IExpressionTree, IgxBooleanFi templateUrl: 'query-builder-sample-1.component.html' }) export class QueryBuilderSample1Component implements OnInit { - public entities: Array; - public companiesFields: Array; - public ordersFields: Array; + public entities: any[]; + public companiesFields: any[]; + public ordersFields: any[]; public expressionTree: IExpressionTree; public ngOnInit(): void { @@ -27,7 +27,7 @@ export class QueryBuilderSample1Component implements OnInit { { field: "PostalCode", dataType: "string" }, { field: "Phone", dataType: "string" }, { field: "Fax", dataType: "string" }, - { field: "Contract", dataType: "boolean" }, + { field: "Contract", dataType: "boolean" } ]; this.ordersFields = [ @@ -43,17 +43,17 @@ export class QueryBuilderSample1Component implements OnInit { { field: "ShipCity", dataType: "string" }, { field: "ShipPostalCode", dataType: "string" }, { field: "ShipCountry", dataType: "string" }, - { field: "Region", dataType: "string" }, + { field: "Region", dataType: "string" } ]; this.entities = [ { name: "Companies", - fields: this.companiesFields, + fields: this.companiesFields }, { name: "Orders", - fields: this.ordersFields, + fields: this.ordersFields } ]; @@ -62,12 +62,12 @@ export class QueryBuilderSample1Component implements OnInit { fieldName: 'Employees', condition: IgxNumberFilteringOperand.instance().condition('greaterThan'), conditionName: 'greaterThan', - searchVal: 100, + searchVal: 100 }); innerTree.filteringOperands.push({ fieldName: 'Contact', condition: IgxBooleanFilteringOperand.instance().condition('true'), - conditionName: 'true', + conditionName: 'true' }); const tree = new FilteringExpressionsTree(FilteringLogic.And, undefined, 'Orders', ['*']); From d16668e59f1389662c8be1406f635bd4636bfcef Mon Sep 17 00:00:00 2001 From: "INFRAGISTICS\\IPetrov" Date: Fri, 27 Sep 2024 19:32:42 +0300 Subject: [PATCH 3/4] fix(query-builder): remove header template from main sample --- .../query-builder-sample-1.component.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.html b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.html index a18b54b25..233627c4c 100644 --- a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.html +++ b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.html @@ -2,8 +2,6 @@ - -
{{ printExpressionTree(queryBuilder.expressionTree) }}
From 8056601baec49af3c7b751ea1a1bdb8bbd9de095 Mon Sep 17 00:00:00 2001 From: teodosia Date: Fri, 4 Oct 2024 15:23:37 +0300 Subject: [PATCH 4/4] fix(query-builder): fix incorrect field name --- .../query-builder-sample-1.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts index 6d260d819..1cb2e592a 100644 --- a/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts +++ b/src/app/interactions/query-builder/query-builder-sample-1/query-builder-sample-1.component.ts @@ -65,7 +65,7 @@ export class QueryBuilderSample1Component implements OnInit { searchVal: 100 }); innerTree.filteringOperands.push({ - fieldName: 'Contact', + fieldName: 'Contract', condition: IgxBooleanFilteringOperand.instance().condition('true'), conditionName: 'true' }); @@ -95,4 +95,4 @@ export class QueryBuilderSample1Component implements OnInit { public printExpressionTree(tree: IExpressionTree) { return tree ? JSON.stringify(tree, null, 2) : 'Please add an expression!'; } -} \ No newline at end of file +}