mirror of https://github.com/abpframework/abp.git
30 changed files with 206 additions and 87 deletions
@ -0,0 +1,12 @@ |
|||
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,3 @@ |
|||
<span class="float-right {{ iconClass }}"> |
|||
<i class="fa {{ icon }}"></i> |
|||
</span> |
|||
@ -0,0 +1,61 @@ |
|||
import { Component, EventEmitter, Input, Output } from '@angular/core'; |
|||
|
|||
@Component({ |
|||
selector: 'abp-sort-order-icon', |
|||
templateUrl: './sort-order-icon.component.html', |
|||
}) |
|||
export class SortOrderIconComponent { |
|||
private _order: string; |
|||
private _selectedKey: string; |
|||
|
|||
@Input() |
|||
set selectedKey(value: string) { |
|||
this._selectedKey = value; |
|||
this.selectedKeyChange.emit(value); |
|||
} |
|||
get selectedKey(): string { |
|||
return this._selectedKey; |
|||
} |
|||
|
|||
@Output() readonly selectedKeyChange = new EventEmitter<string>(); |
|||
|
|||
@Input() |
|||
key: string; |
|||
|
|||
@Input() |
|||
set order(value: string) { |
|||
this._order = value; |
|||
this.orderChange.emit(value); |
|||
} |
|||
get order(): string { |
|||
return this._order; |
|||
} |
|||
|
|||
@Output() readonly orderChange = new EventEmitter<string>(); |
|||
|
|||
@Input() |
|||
iconClass: string; |
|||
|
|||
get icon(): string { |
|||
if (!this.selectedKey) return 'fa-sort'; |
|||
if (this.selectedKey === this.key) return `fa-sort-${this.order}`; |
|||
else return ''; |
|||
} |
|||
|
|||
sort(key: string) { |
|||
this.selectedKey = key; |
|||
switch (this.order) { |
|||
case '': |
|||
this.order = 'asc'; |
|||
break; |
|||
case 'asc': |
|||
this.order = 'desc'; |
|||
this.orderChange.emit('desc'); |
|||
break; |
|||
case 'desc': |
|||
this.order = ''; |
|||
this.selectedKey = ''; |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue