mirror of https://github.com/abpframework/abp.git
6 changed files with 37 additions and 18 deletions
@ -1,12 +0,0 @@ |
|||
import { Directive, ElementRef, Input, Optional, Self } from '@angular/core'; |
|||
import { Table } from 'primeng/table'; |
|||
|
|||
@Directive({ |
|||
selector: '[abpSort]', |
|||
}) |
|||
export class SortDirective { |
|||
constructor(private elementRef: ElementRef, @Optional() @Self() table: Table) { |
|||
console.warn(elementRef); |
|||
setInterval(() => console.warn(table.value), 1000); |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
import { Directive, Input, Optional, Self, SimpleChanges, OnChanges } from '@angular/core'; |
|||
import { Table } from 'primeng/table'; |
|||
import { SortPipe, SortOrder } from '../pipes/sort.pipe'; |
|||
|
|||
export interface TableSortOptions { |
|||
key: string; |
|||
order: SortOrder; |
|||
} |
|||
|
|||
@Directive({ |
|||
selector: '[abpTableSort]', |
|||
providers: [SortPipe], |
|||
}) |
|||
export class TableSortDirective implements OnChanges { |
|||
@Input() |
|||
abpTableSort: TableSortOptions; |
|||
|
|||
@Input() |
|||
value: any[] = []; |
|||
|
|||
constructor(@Optional() @Self() private table: Table, private sortPipe: SortPipe) {} |
|||
|
|||
ngOnChanges({ value, abpTableSort }: SimpleChanges) { |
|||
if (value || abpTableSort) { |
|||
this.abpTableSort = this.abpTableSort || ({} as TableSortOptions); |
|||
this.table.value = this.sortPipe.transform(this.value, this.abpTableSort.order, this.abpTableSort.key); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue