11import { Component , ViewChild , OnInit } from '@angular/core' ;
22import {
3- FilteringExpressionsTree , IgxStringFilteringOperand ,
3+ FilteringExpressionsTree ,
44 FilteringLogic ,
55 IgxQueryBuilderComponent ,
66 changei18n ,
77 IExpressionTree ,
88 IgxButtonDirective ,
99 IgxButtonGroupComponent ,
1010 IgxRippleDirective ,
11- IgxQueryBuilderHeaderComponent
11+ IgxQueryBuilderHeaderComponent ,
12+ IgxNumberFilteringOperand ,
13+ IgxStringFilteringOperand ,
14+ IgxBooleanFilteringOperand ,
15+ IgxDateFilteringOperand ,
16+ IgxTimeFilteringOperand ,
17+ IgxDateTimeFilteringOperand
1218} from 'igniteui-angular' ;
1319import { IgxResourceStringsFR } from 'igniteui-angular-i18n' ;
1420import { SizeSelectorComponent } from '../size-selector/size-selector.component' ;
@@ -32,103 +38,90 @@ export class QueryBuilderComponent implements OnInit {
3238 public searchValueTemplate : IgxQueryBuilderSearchValueTemplateDirective ;
3339
3440 public entities : Array < any > ;
35- public assaysFields : Array < any > ;
36- public compoundsFields : Array < any > ;
41+ public fieldsEntityA : Array < any > ;
42+ public fieldsEntityB : Array < any > ;
3743 public displayDensities ;
3844 public expressionTree : IExpressionTree ;
3945 public queryResult : string ;
4046
4147 public ngOnInit ( ) : void {
42- this . assaysFields = [
48+ this . fieldsEntityA = [
4349 { field : 'Id' , dataType : 'number' } ,
44- { field : 'CompoundId' , dataType : 'number' } ,
4550 { field : 'Name' , dataType : 'string' } ,
46- { field : 'EndpointName' , dataType : 'string' } ,
47- { field : 'EndpointValue' , dataType : 'string' } ,
48- { field : 'Date' , dataType : 'date' }
51+ { field : 'Validated' , dataType : 'boolean' } ,
52+ { field : 'Date created' , dataType : 'date' } ,
53+ { field : 'Time created' , dataType : 'time' } ,
54+ { field : 'DateTime created' , dataType : 'dateTime' }
4955 ] ;
50- this . compoundsFields = [
51- { field : 'Id' , dataType : 'number' } ,
52- { field : 'Structure' , dataType : 'string' } ,
53- { field : 'Date' , dataType : 'date' }
56+ this . fieldsEntityB = [
57+ { field : 'Number' , dataType : 'number' } ,
58+ { field : 'String' , dataType : 'string' } ,
59+ { field : 'Boolean' , dataType : 'boolean' } ,
60+ { field : 'Date' , dataType : 'date' } ,
61+ { field : 'Time' , dataType : 'time' } ,
62+ { field : 'DateTime' , dataType : 'dateTime' }
5463 ] ;
5564 this . entities = [
5665 {
57- name : 'Assays ' ,
58- fields : this . assaysFields
66+ name : 'Entity A ' ,
67+ fields : this . fieldsEntityA
5968 } ,
6069 {
61- name : 'Compounds ' ,
62- fields : this . compoundsFields
70+ name : 'Entity B ' ,
71+ fields : this . fieldsEntityB
6372 }
6473 ] ;
6574
66- const innerTree = new FilteringExpressionsTree ( FilteringLogic . And , undefined , 'Assays ' , [ 'Id ' ] ) ;
75+ const innerTree = new FilteringExpressionsTree ( FilteringLogic . And , undefined , 'Entity B ' , [ 'Number ' ] ) ;
6776 innerTree . filteringOperands . push ( {
68- fieldName : 'Name' ,
69- condition : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) ,
70- conditionName : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) . name ,
71- searchVal : 'Hepacity' ,
72- // ignoreCase: true
77+ fieldName : 'Number' ,
78+ condition : IgxNumberFilteringOperand . instance ( ) . condition ( 'equals' ) ,
79+ conditionName : IgxNumberFilteringOperand . instance ( ) . condition ( 'equals' ) . name ,
80+ searchVal : 123
7381 } ) ;
7482 innerTree . filteringOperands . push ( {
75- fieldName : 'EndpointName ' ,
83+ fieldName : 'String ' ,
7684 condition : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) ,
7785 conditionName : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) . name ,
78- searchVal : 'IC60' ,
79- // ignoreCase: true
86+ searchVal : 'abc'
8087 } ) ;
81-
82- const innerTree2 = new FilteringExpressionsTree ( FilteringLogic . And , undefined , 'Assays' , [ 'Name' ] ) ;
83- innerTree2 . filteringOperands . push ( {
84- fieldName : 'Name' ,
85- condition : IgxStringFilteringOperand . instance ( ) . condition ( 'null' ) ,
86- conditionName : IgxStringFilteringOperand . instance ( ) . condition ( 'null' ) . name ,
87- // ignoreCase: true
88+ innerTree . filteringOperands . push ( {
89+ fieldName : 'Boolean' ,
90+ condition : IgxBooleanFilteringOperand . instance ( ) . condition ( 'true' ) ,
91+ conditionName : IgxBooleanFilteringOperand . instance ( ) . condition ( 'true' ) . name
92+ } ) ;
93+ innerTree . filteringOperands . push ( {
94+ fieldName : 'Date' ,
95+ condition : IgxDateFilteringOperand . instance ( ) . condition ( 'before' ) ,
96+ conditionName : IgxDateFilteringOperand . instance ( ) . condition ( 'before' ) . name ,
97+ searchVal : new Date ( )
98+ } ) ;
99+ innerTree . filteringOperands . push ( {
100+ fieldName : 'Time' ,
101+ condition : IgxTimeFilteringOperand . instance ( ) . condition ( 'before' ) ,
102+ conditionName : IgxTimeFilteringOperand . instance ( ) . condition ( 'before' ) . name ,
103+ searchVal : new Date ( )
104+ } ) ;
105+ innerTree . filteringOperands . push ( {
106+ fieldName : 'DateTime' ,
107+ condition : IgxDateTimeFilteringOperand . instance ( ) . condition ( 'before' ) ,
108+ conditionName : IgxDateTimeFilteringOperand . instance ( ) . condition ( 'before' ) . name ,
109+ searchVal : new Date ( )
88110 } ) ;
89111
90- const tree = new FilteringExpressionsTree ( FilteringLogic . And , undefined , 'Compounds ' , [ '*' ] ) ;
112+ const tree = new FilteringExpressionsTree ( FilteringLogic . And , undefined , 'Entity A ' , [ '*' ] ) ;
91113 tree . filteringOperands . push ( {
92114 fieldName : 'Id' ,
93115 condition : IgxStringFilteringOperand . instance ( ) . condition ( 'in' ) ,
94116 conditionName : IgxStringFilteringOperand . instance ( ) . condition ( 'in' ) . name ,
95117 searchTree : innerTree
96118 } ) ;
97119 tree . filteringOperands . push ( {
98- fieldName : 'Id' ,
99- condition : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) ,
100- conditionName : IgxStringFilteringOperand . instance ( ) . condition ( 'equals' ) . name ,
101- searchVal : '123' ,
102- ignoreCase : true
120+ fieldName : 'Validated' ,
121+ condition : IgxBooleanFilteringOperand . instance ( ) . condition ( 'true' ) ,
122+ conditionName : IgxBooleanFilteringOperand . instance ( ) . condition ( 'true' ) . name
103123 } ) ;
104124
105- // tree.filteringOperands.push({
106- // fieldName: 'Structure',
107- // condition: IgxStringFilteringOperand.instance().condition('in'),
108- // searchTree: innerTree2
109- // });
110-
111- // const orTree = new FilteringExpressionsTree(FilteringLogic.Or);
112- // orTree.filteringOperands.push({
113- // fieldName: 'ID',
114- // condition: IgxStringFilteringOperand.instance().condition('contains'),
115- // searchVal: 'b',
116- // ignoreCase: true
117- // });
118- // orTree.filteringOperands.push({
119- // fieldName: 'CompanyName',
120- // condition: IgxStringFilteringOperand.instance().condition('contains'),
121- // searchVal: 'c',
122- // ignoreCase: true
123- // });
124- // tree.filteringOperands.push(orTree);
125- // tree.filteringOperands.push({
126- // fieldName: 'CompanyName',
127- // condition: IgxStringFilteringOperand.instance().condition('contains'),
128- // searchVal: 'd',
129- // ignoreCase: true
130- // });
131-
132125 this . expressionTree = tree ;
133126 // this.onChange();
134127 }
0 commit comments