Browse Source
Merge pull request #1875 from abpframework/refactor/sort
Refactor/sort
pull/1879/head
Mehmet Erim
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with
53 additions and
52 deletions
-
npm/ng-packs/packages/core/src/lib/core.module.ts
-
npm/ng-packs/packages/core/src/lib/directives/index.ts
-
npm/ng-packs/packages/core/src/lib/directives/sort.directive.ts
-
npm/ng-packs/packages/core/src/lib/directives/table-sort.directive.ts
-
npm/ng-packs/packages/core/src/lib/pipes/sort.pipe.ts
-
npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html
-
npm/ng-packs/packages/identity/src/lib/components/users/users.component.html
-
npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html
|
|
|
@ -27,7 +27,7 @@ import { getInitialData, localeInitializer } from './utils/initial-utils'; |
|
|
|
import { ConfigPlugin, NGXS_CONFIG_PLUGIN_OPTIONS } from './plugins/config/config.plugin'; |
|
|
|
import { ForDirective } from './directives/for.directive'; |
|
|
|
import { AbstractNgModelComponent } from './abstracts/ng-model.component'; |
|
|
|
import { SortDirective } from './directives/sort.directive'; |
|
|
|
import { TableSortDirective } from './directives/table-sort.directive'; |
|
|
|
|
|
|
|
@NgModule({ |
|
|
|
imports: [ |
|
|
|
@ -47,7 +47,7 @@ import { SortDirective } from './directives/sort.directive'; |
|
|
|
EllipsisDirective, |
|
|
|
ForDirective, |
|
|
|
FormSubmitDirective, |
|
|
|
SortDirective, |
|
|
|
TableSortDirective, |
|
|
|
LocalizationPipe, |
|
|
|
SortPipe, |
|
|
|
PermissionDirective, |
|
|
|
@ -70,7 +70,7 @@ import { SortDirective } from './directives/sort.directive'; |
|
|
|
FormSubmitDirective, |
|
|
|
LocalizationPipe, |
|
|
|
SortPipe, |
|
|
|
SortDirective, |
|
|
|
TableSortDirective, |
|
|
|
PermissionDirective, |
|
|
|
VisibilityDirective, |
|
|
|
InputEventDebounceDirective, |
|
|
|
|
|
|
|
@ -3,4 +3,5 @@ export * from './ellipsis.directive'; |
|
|
|
export * from './for.directive'; |
|
|
|
export * from './form-submit.directive'; |
|
|
|
export * from './permission.directive'; |
|
|
|
export * from './table-sort.directive'; |
|
|
|
export * from './visibility.directive'; |
|
|
|
|
|
|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1,8 +1,9 @@ |
|
|
|
import { Pipe, PipeTransform } from '@angular/core'; |
|
|
|
import { Pipe, PipeTransform, Injectable } from '@angular/core'; |
|
|
|
import clone from 'just-clone'; |
|
|
|
|
|
|
|
export type SortOrder = 'asc' | 'desc'; |
|
|
|
|
|
|
|
@Injectable() |
|
|
|
@Pipe({ |
|
|
|
name: 'abpSort', |
|
|
|
}) |
|
|
|
|
|
|
|
@ -24,7 +24,8 @@ |
|
|
|
</div> |
|
|
|
<p-table |
|
|
|
*ngIf="[130, 200] as columnWidths" |
|
|
|
[value]="data$ | async | abpSort: sortOrder:sortKey" |
|
|
|
[value]="data$ | async" |
|
|
|
[abpTableSort]="{ key: sortKey, order: sortOrder }" |
|
|
|
[lazy]="true" |
|
|
|
[lazyLoadOnInit]="false" |
|
|
|
[paginator]="true" |
|
|
|
@ -129,8 +130,5 @@ |
|
|
|
</ng-template> |
|
|
|
</abp-modal> |
|
|
|
|
|
|
|
<abp-permission-management |
|
|
|
[(visible)]="visiblePermissions" |
|
|
|
providerName="Role" |
|
|
|
[providerKey]="providerKey" |
|
|
|
></abp-permission-management> |
|
|
|
<abp-permission-management [(visible)]="visiblePermissions" providerName="Role" [providerKey]="providerKey"> |
|
|
|
</abp-permission-management> |
|
|
|
|
|
|
|
@ -29,9 +29,9 @@ |
|
|
|
/></label> |
|
|
|
</div> |
|
|
|
<p-table |
|
|
|
abpSort |
|
|
|
*ngIf="[130, 200, 200, 200] as columnWidths" |
|
|
|
[value]="data$ | async | abpSort: sortOrder:sortKey" |
|
|
|
[value]="data$ | async" |
|
|
|
[abpTableSort]="{ key: sortKey, order: sortOrder }" |
|
|
|
[lazy]="true" |
|
|
|
[lazyLoadOnInit]="false" |
|
|
|
[paginator]="true" |
|
|
|
@ -60,12 +60,8 @@ |
|
|
|
<th>{{ 'AbpIdentity::Actions' | abpLocalization }}</th> |
|
|
|
<th pResizableColumn (click)="sortOrderIcon.sort('userName')"> |
|
|
|
{{ 'AbpIdentity::UserName' | abpLocalization }} |
|
|
|
<abp-sort-order-icon |
|
|
|
#sortOrderIcon |
|
|
|
key="userName" |
|
|
|
[(selectedKey)]="sortKey" |
|
|
|
[(order)]="sortOrder" |
|
|
|
></abp-sort-order-icon> |
|
|
|
<abp-sort-order-icon #sortOrderIcon key="userName" [(selectedKey)]="sortKey" [(order)]="sortOrder"> |
|
|
|
</abp-sort-order-icon> |
|
|
|
</th> |
|
|
|
<th pResizableColumn (click)="sortOrderIcon.sort('email')"> |
|
|
|
{{ 'AbpIdentity::EmailAddress' | abpLocalization }} |
|
|
|
@ -73,11 +69,8 @@ |
|
|
|
</th> |
|
|
|
<th pResizableColumn (click)="sortOrderIcon.sort('phoneNumber')"> |
|
|
|
{{ 'AbpIdentity::PhoneNumber' | abpLocalization }} |
|
|
|
<abp-sort-order-icon |
|
|
|
key="phoneNumber" |
|
|
|
[(selectedKey)]="sortKey" |
|
|
|
[(order)]="sortOrder" |
|
|
|
></abp-sort-order-icon> |
|
|
|
<abp-sort-order-icon key="phoneNumber" [(selectedKey)]="sortKey" [(order)]="sortOrder"> |
|
|
|
</abp-sort-order-icon> |
|
|
|
</th> |
|
|
|
</tr> |
|
|
|
</ng-template> |
|
|
|
@ -223,8 +216,5 @@ |
|
|
|
</ng-template> |
|
|
|
</abp-modal> |
|
|
|
|
|
|
|
<abp-permission-management |
|
|
|
[(visible)]="visiblePermissions" |
|
|
|
providerName="User" |
|
|
|
[providerKey]="providerKey" |
|
|
|
></abp-permission-management> |
|
|
|
<abp-permission-management [(visible)]="visiblePermissions" providerName="User" [providerKey]="providerKey"> |
|
|
|
</abp-permission-management> |
|
|
|
|
|
|
|
@ -31,7 +31,8 @@ |
|
|
|
</div> |
|
|
|
<p-table |
|
|
|
*ngIf="[130, 200] as columnWidths" |
|
|
|
[value]="data$ | async | abpSort: sortOrder:sortKey" |
|
|
|
[value]="data$ | async" |
|
|
|
[abpTableSort]="{ key: sortKey, order: sortOrder }" |
|
|
|
[lazy]="true" |
|
|
|
[lazyLoadOnInit]="false" |
|
|
|
[paginator]="true" |
|
|
|
@ -60,12 +61,8 @@ |
|
|
|
<th>{{ 'AbpTenantManagement::Actions' | abpLocalization }}</th> |
|
|
|
<th pResizableColumn (click)="sortOrderIcon.sort('name')"> |
|
|
|
{{ 'AbpTenantManagement::TenantName' | abpLocalization }} |
|
|
|
<abp-sort-order-icon |
|
|
|
#sortOrderIcon |
|
|
|
key="name" |
|
|
|
[(selectedKey)]="sortKey" |
|
|
|
[(order)]="sortOrder" |
|
|
|
></abp-sort-order-icon> |
|
|
|
<abp-sort-order-icon #sortOrderIcon key="name" [(selectedKey)]="sortKey" [(order)]="sortOrder"> |
|
|
|
</abp-sort-order-icon> |
|
|
|
</th> |
|
|
|
</tr> |
|
|
|
</ng-template> |
|
|
|
@ -180,8 +177,5 @@ |
|
|
|
</form> |
|
|
|
</ng-template> |
|
|
|
|
|
|
|
<abp-feature-management |
|
|
|
[(visible)]="visibleFeatures" |
|
|
|
providerName="Tenant" |
|
|
|
[providerKey]="providerKey" |
|
|
|
></abp-feature-management> |
|
|
|
<abp-feature-management [(visible)]="visibleFeatures" providerName="Tenant" [providerKey]="providerKey"> |
|
|
|
</abp-feature-management> |
|
|
|
|