diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/grid-filter.module.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/grid-filter.module.ts index 2bb50c9..5b0c59a 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/grid-filter.module.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/grid-filter.module.ts @@ -5,8 +5,8 @@ import { FormsModule } from '@angular/forms'; import { NumberFilterComponent } from './number-filter/number-filter.component'; import { DatetimeFilterComponent } from './datetime-filter/datetime-filter.component'; import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; - - +import { PopoverModule } from 'ngx-bootstrap/popover'; +import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; @@ -17,6 +17,8 @@ import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; CommonModule, FormsModule, BsDatepickerModule.forRoot(), + PopoverModule.forRoot(), + BsDropdownModule.forRoot() ], exports: [TextFilterComponent, NumberFilterComponent,DatetimeFilterComponent] }) diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/text-filter/text-filter.component.html b/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/text-filter/text-filter.component.html index 8fd50e4..1a3b870 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/text-filter/text-filter.component.html +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/text-filter/text-filter.component.html @@ -1,6 +1,57 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/text-filter/text-filter.component.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/text-filter/text-filter.component.ts index 5db9f84..643eb8f 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/text-filter/text-filter.component.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/grid-filter/text-filter/text-filter.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, Input, OnDestroy, Output,EventEmitter } from '@angular/core'; import { IDataSource, IQueryExecutionResult, IQueryExecutionGroupResult } from '@poweredsoft/data'; import { Subscription } from 'rxjs'; +import { IFilter, ISimpleFilter } from '../../models/IFilter'; @Component({ @@ -8,39 +9,35 @@ import { Subscription } from 'rxjs'; templateUrl: './text-filter.component.html', styleUrls: ['./text-filter.component.scss'] }) -export class TextFilterComponent implements OnInit, OnDestroy { +export class TextFilterComponent implements OnInit { @Input() dataSource : IDataSource; - @Output() filteredResults: EventEmitter = new EventEmitter(); - latestResult: IQueryExecutionResult & IQueryExecutionGroupResult; - - private _dataSubscription: Subscription; + @Output() onFilter: EventEmitter = new EventEmitter(); + title = 'Welcome word'; + content = 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus.'; + private _searchTerm: string; + filterType: string = 'Contains'; + filterValue: string = null; - get searchTerm(): string { - return this._searchTerm; + get filterTypes(){ + return ["contains","equals","startsWith"] } - set searchTerm(value: string) { - this._searchTerm = value; - //this.filteredResults.emit(this.dataFilter(value)); - } - - // dataFilter(searchString: string) { - // return this.latestResult.data.filter(x => - // x.name.toLowerCase().indexOf(searchString.toLowerCase()) !== -1); - // } - constructor() { } - ngOnDestroy(): void { - this._dataSubscription.unsubscribe(); - } + ngOnInit(): void { - this._dataSubscription = this.dataSource.data$.subscribe(newData => { - this.latestResult = newData; - }); + } + applyFilter(){ + this.onFilter.emit({ + path: "name", + value: this.filterValue, + type: this.filterType, + and: true + }); + } } diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/models/IFilter.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/models/IFilter.ts new file mode 100644 index 0000000..53534fc --- /dev/null +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/models/IFilter.ts @@ -0,0 +1,9 @@ +export interface IFilter { + type: string; + and?: boolean; +} + +export interface ISimpleFilter extends IFilter { + path: string; + value: any; +} \ No newline at end of file diff --git a/projects/poweredsoft/ngx-cdk-ui/src/lib/data-grid/data-grid/data-grid.component.html b/projects/poweredsoft/ngx-cdk-ui/src/lib/data-grid/data-grid/data-grid.component.html index 3748a69..4dec174 100644 --- a/projects/poweredsoft/ngx-cdk-ui/src/lib/data-grid/data-grid/data-grid.component.html +++ b/projects/poweredsoft/ngx-cdk-ui/src/lib/data-grid/data-grid/data-grid.component.html @@ -5,9 +5,6 @@ - - - @@ -16,6 +13,9 @@ + + + diff --git a/src/app/grid-filter-demo/grid-filter-demo/grid-filter-demo.component.html b/src/app/grid-filter-demo/grid-filter-demo/grid-filter-demo.component.html index 7b0595a..5d9b044 100644 --- a/src/app/grid-filter-demo/grid-filter-demo/grid-filter-demo.component.html +++ b/src/app/grid-filter-demo/grid-filter-demo/grid-filter-demo.component.html @@ -1,6 +1,6 @@

grid-filter-demo works!

- + @@ -10,11 +10,12 @@ [dataSource]="merchantDataSource" command="addMerchant" [template]="theModal">Create Record - +
ID
{{model.id}}
+ diff --git a/src/app/grid-filter-demo/grid-filter-demo/grid-filter-demo.component.ts b/src/app/grid-filter-demo/grid-filter-demo/grid-filter-demo.component.ts index 01fdc7c..a232ed8 100644 --- a/src/app/grid-filter-demo/grid-filter-demo/grid-filter-demo.component.ts +++ b/src/app/grid-filter-demo/grid-filter-demo/grid-filter-demo.component.ts @@ -20,6 +20,7 @@ export class GridFilterDemoComponent implements OnInit { pages:any; filteredResults:any; + somefilter:any; createDataSource(): IDataSource { return this.merchantService.createDataSource(); @@ -28,9 +29,12 @@ export class GridFilterDemoComponent implements OnInit { ngOnInit() { this.merchantDataSource.refresh(); + } - test(){ - console.log(this.filteredResults); + filterMerchants(event){ + this.somefilter = event; + this.merchantDataSource.filters[0]=this.somefilter; + this.merchantDataSource.refresh(); } }