sorting & filtering 1st version done
This commit is contained in:
+57
-1
@@ -1 +1,57 @@
|
||||
<p>number-filter works!</p>
|
||||
<ng-template #popTemplate>
|
||||
<select class="custom-select" title="Choose one of the following..." [(ngModel)]="filterType">
|
||||
<option *ngFor="let filter of filterTypes">{{filter}}</option>
|
||||
</select>
|
||||
|
||||
<input type="text" class="form-control" placeholder="column value" aria-label="Username"
|
||||
aria-describedby="basic-addon1" [(ngModel)]="filterValue">
|
||||
<button class="btn btn-primary" (click)="applyFilter()">Filter</button>
|
||||
</ng-template>
|
||||
|
||||
|
||||
<button [popover]="popTemplate" popoverTitle="Template ref content inside" [outsideClick]="true" >
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
|
||||
y="0px" viewBox="0 0 477.875 477.875" style="enable-background:new 0 0 477.875 477.875;" xml:space="preserve"
|
||||
width="13px" height="13px">
|
||||
<g>
|
||||
<g>
|
||||
<path d="M460.804,0H17.071C7.645,0,0.004,7.641,0.004,17.067V102.4c0.001,4.836,2.054,9.445,5.649,12.681l165.018,148.514V460.8
|
||||
c-0.004,9.426,7.633,17.07,17.059,17.075c2.651,0.001,5.266-0.615,7.637-1.8l102.4-51.2c5.786-2.891,9.441-8.806,9.438-15.275
|
||||
V263.595l165.018-148.48c3.604-3.243,5.658-7.866,5.649-12.715V17.067C477.871,7.641,470.23,0,460.804,0z M443.737,94.805
|
||||
L278.72,243.285c-3.604,3.243-5.657,7.866-5.649,12.715v143.053l-68.267,34.133V256c-0.001-4.836-2.054-9.445-5.649-12.68
|
||||
L34.137,94.805V34.133h409.6V94.805z" />
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
</button>{{columnName}}
|
||||
+26
-4
@@ -1,4 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { IDataSource,IFilter } from '@poweredsoft/data';
|
||||
import { ISimpleFilter } from '../../models/IFilter';
|
||||
|
||||
@Component({
|
||||
selector: 'psbx-number-filter',
|
||||
@@ -6,10 +8,30 @@ import { Component, OnInit } from '@angular/core';
|
||||
styleUrls: ['./number-filter.component.scss']
|
||||
})
|
||||
export class NumberFilterComponent implements OnInit {
|
||||
@Input() dataSource : IDataSource<any>;
|
||||
@Output() onFilter: EventEmitter<IFilter> = new EventEmitter();
|
||||
@Input() columnName:string;
|
||||
|
||||
filterType: string = 'Contains';
|
||||
filterValue: string = null;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
get filterTypes(){
|
||||
return ["contains","equals","startsWith","GreaterThan","LessThan"]
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
}
|
||||
|
||||
applyFilter(){
|
||||
this.onFilter.emit(<ISimpleFilter>{
|
||||
path: this.columnName,
|
||||
value: this.filterValue,
|
||||
type: this.filterType,
|
||||
and: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+18
-9
@@ -1,15 +1,24 @@
|
||||
<ng-template #popTemplate>
|
||||
<select class="custom-select" title="Choose one of the following..." [(ngModel)]="filterType">
|
||||
<option *ngFor="let filter of filterTypes">{{filter}}</option>
|
||||
</select>
|
||||
|
||||
<input type="text" class="form-control" placeholder="column value" aria-label="Username"
|
||||
<div class="container" >
|
||||
<div class="row">
|
||||
<select class="custom-select" title="Choose one of the following..." [(ngModel)]="filterType">
|
||||
<option *ngFor="let filter of filterTypes">{{filter}}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row mt-1 mb-1">
|
||||
<input type="text" class="form-control" placeholder="column value" aria-label="Username"
|
||||
aria-describedby="basic-addon1" [(ngModel)]="filterValue">
|
||||
<button class="btn btn-primary" (click)="applyFilter()">Filter</button>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary mr-1" (click)="applyFilter()">Filter</button>
|
||||
<button type="button" class="btn btn-warning" (click)="pop.hide()">
|
||||
Hide
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
|
||||
<span [popover]="popTemplate" popoverTitle="Template ref content inside">
|
||||
<button [popover]="popTemplate" [outsideClick]="true" #pop="bs-popover">
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
|
||||
y="0px" viewBox="0 0 477.875 477.875" style="enable-background:new 0 0 477.875 477.875;" xml:space="preserve"
|
||||
width="13px" height="13px">
|
||||
@@ -54,4 +63,4 @@
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
</span>
|
||||
</button>
|
||||
+34
-19
@@ -1,7 +1,6 @@
|
||||
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';
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { IDataSource} from '@poweredsoft/data';
|
||||
import { ISimpleFilter } from '../../models/IFilter';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -12,18 +11,11 @@ import { IFilter, ISimpleFilter } from '../../models/IFilter';
|
||||
export class TextFilterComponent implements OnInit {
|
||||
|
||||
@Input() dataSource : IDataSource<any>;
|
||||
@Output() onFilter: EventEmitter<IFilter> = new EventEmitter();
|
||||
title = 'Welcome word';
|
||||
content = 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus.';
|
||||
|
||||
private _searchTerm: string;
|
||||
@Input() path:string;
|
||||
|
||||
filterType: string = 'Contains';
|
||||
filterValue: string = null;
|
||||
|
||||
get filterTypes(){
|
||||
return ["contains","equals","startsWith"]
|
||||
}
|
||||
filterTypes = ['contains', 'equal', 'startsWith','endsWith'];
|
||||
|
||||
constructor() { }
|
||||
|
||||
@@ -32,12 +24,35 @@ export class TextFilterComponent implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
clearFilter() {
|
||||
const existingFilter = this.dataSource.filters.find(t => (t as ISimpleFilter).path == this.path) as ISimpleFilter;
|
||||
if (existingFilter) {
|
||||
this.dataSource.query({
|
||||
page: 1,
|
||||
filters: this.dataSource.filters.filter(t => t != existingFilter)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
applyFilter(){
|
||||
this.onFilter.emit(<ISimpleFilter>{
|
||||
path: "name",
|
||||
value: this.filterValue,
|
||||
type: this.filterType,
|
||||
and: true
|
||||
});
|
||||
|
||||
const filters = this.dataSource.filters;
|
||||
const existingFilter = filters.find(t => (t as ISimpleFilter).path == this.path) as ISimpleFilter;
|
||||
if (existingFilter) {
|
||||
existingFilter.type = this.filterType;
|
||||
existingFilter.value = this.filterValue;
|
||||
} else {
|
||||
filters.push(<ISimpleFilter>{
|
||||
and: true,
|
||||
type: this.filterType,
|
||||
path: this.path,
|
||||
value: this.filterValue
|
||||
})
|
||||
}
|
||||
|
||||
this.dataSource.query({
|
||||
filters: filters,
|
||||
page: 1
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { GridSortingComponent } from './grid-sorting/grid-sorting.component';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [GridSortingComponent],
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
exports:[GridSortingComponent]
|
||||
})
|
||||
export class GridSortingModule { }
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<div>
|
||||
<span class="caret dropdown-toggle" [class.not-sorting-state]="!isAscending" (click)="ascending()"></span>
|
||||
<span class="caret dropdown-toggle sort-asc" [class.not-sorting-state]="!isDescending" style="transform: rotate(180deg)" (click)="descending()"></span>
|
||||
</div>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
:host span.dropdown-toggle.sort-asc{
|
||||
transform: rotate(180deg);
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
:host span{
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
:host .not-sorting-state{
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
:host .not-sorting-state:hover{
|
||||
opacity: 1;
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { IDataSource } from '@poweredsoft/data';
|
||||
|
||||
@Component({
|
||||
selector: 'psbx-grid-sorting',
|
||||
templateUrl: './grid-sorting.component.html',
|
||||
styleUrls: ['./grid-sorting.component.scss']
|
||||
})
|
||||
export class GridSortingComponent implements OnInit {
|
||||
|
||||
@Input() dataSource : IDataSource<any>;
|
||||
@Input() path:string;
|
||||
isAscending:boolean;
|
||||
isDescending:boolean;
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
ascending(){
|
||||
this.isAscending = true;
|
||||
console.log("ascending result...")
|
||||
const existingSort = this.dataSource.sorts.find(t => t.path == this.path);
|
||||
if (existingSort){
|
||||
existingSort.ascending = true;
|
||||
}else{
|
||||
this.dataSource.sorts.push({
|
||||
path: this.path,
|
||||
ascending:true
|
||||
})
|
||||
}
|
||||
|
||||
this.dataSource.query({
|
||||
sorts: this.dataSource.sorts,
|
||||
page: 1
|
||||
})
|
||||
this.isDescending = false;
|
||||
}
|
||||
|
||||
descending(){
|
||||
this.isDescending = true;
|
||||
console.log("descending result...")
|
||||
const existingSort = this.dataSource.sorts.find(t => t.path == this.path);
|
||||
if (existingSort){
|
||||
existingSort.ascending = false;
|
||||
}else{
|
||||
this.dataSource.sorts.push({
|
||||
path: this.path,
|
||||
ascending:false
|
||||
})
|
||||
}
|
||||
|
||||
this.dataSource.query({
|
||||
sorts: this.dataSource.sorts,
|
||||
page: 1
|
||||
})
|
||||
this.isAscending = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,4 +16,6 @@ export * from './lib/spinner/spinner/spinner.component';
|
||||
export * from './lib/grid-filter/grid-filter.module';
|
||||
export * from './lib/grid-filter/text-filter/text-filter.component';
|
||||
export * from './lib/grid-filter/number-filter/number-filter.component';
|
||||
export * from './lib/grid-filter/datetime-filter/datetime-filter.component';
|
||||
export * from './lib/grid-filter/datetime-filter/datetime-filter.component';
|
||||
export * from './lib/grid-sorting/grid-sorting.module';
|
||||
export * from './lib/grid-sorting/grid-sorting/grid-sorting.component';
|
||||
Reference in New Issue
Block a user