Browse Source

feature(identity): add sorting to identity module routes

pull/1767/head
TheDiaval 7 years ago
parent
commit
82614986e0
  1. 18
      npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html
  2. 6
      npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts
  3. 20
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.html
  4. 6
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

18
npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html

@ -30,18 +30,30 @@
[rows]="10" [rows]="10"
[totalRecords]="totalCount$ | async" [totalRecords]="totalCount$ | async"
[loading]="loading" [loading]="loading"
[resizableColumns]="true"
[scrollable]="true"
(onLazyLoad)="onPageChange($event)" (onLazyLoad)="onPageChange($event)"
> >
<ng-template pTemplate="header"> <ng-template pTemplate="colgroup">
<colgroup>
<col *ngFor="let width of [65, 200]" [ngStyle]="{ 'width.px': width }" />
</colgroup>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr> <tr>
<th>{{ 'AbpIdentity::Actions' | abpLocalization }}</th> <th>{{ 'AbpIdentity::Actions' | abpLocalization }}</th>
<th>{{ 'AbpIdentity::RoleName' | abpLocalization }}</th> <th pResizableColumn (click)="changeSortOrder()">
{{ 'AbpIdentity::RoleName' | abpLocalization }}
<span class="float-right"
><i [ngClass]="['fa', sortOrder === 'desc' ? 'fa-sort-desc' : 'fa-sort-asc']"></i
></span>
</th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template pTemplate="body" let-data> <ng-template pTemplate="body" let-data>
<tr> <tr>
<td> <td>
<div ngbDropdown class="d-inline-block"> <div ngbDropdown container="body" class="d-inline-block">
<button <button
class="btn btn-primary btn-sm dropdown-toggle" class="btn btn-primary btn-sm dropdown-toggle"
data-toggle="dropdown" data-toggle="dropdown"

6
npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts

@ -38,6 +38,8 @@ export class RolesComponent {
modalBusy: boolean = false; modalBusy: boolean = false;
sortOrder: string = 'asc';
@ViewChild('modalContent', { static: false }) @ViewChild('modalContent', { static: false })
modalContent: TemplateRef<any>; modalContent: TemplateRef<any>;
@ -121,4 +123,8 @@ export class RolesComponent {
.pipe(finalize(() => (this.loading = false))) .pipe(finalize(() => (this.loading = false)))
.subscribe(); .subscribe();
} }
changeSortOrder() {
this.sortOrder = this.sortOrder.toLowerCase() === 'asc' ? 'desc' : 'asc';
}
} }

20
npm/ng-packs/packages/identity/src/lib/components/users/users.component.html

@ -36,20 +36,32 @@
[rows]="10" [rows]="10"
[totalRecords]="totalCount$ | async" [totalRecords]="totalCount$ | async"
[loading]="loading" [loading]="loading"
[resizableColumns]="true"
[scrollable]="true"
(onLazyLoad)="onPageChange($event)" (onLazyLoad)="onPageChange($event)"
> >
<ng-template pTemplate="colgroup">
<colgroup>
<col *ngFor="let width of [80, 200, 200, 200]" [ngStyle]="{ 'width.px': width }" />
</colgroup>
</ng-template>
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th>{{ 'AbpIdentity::Actions' | abpLocalization }}</th> <th>{{ 'AbpIdentity::Actions' | abpLocalization }}</th>
<th>{{ 'AbpIdentity::UserName' | abpLocalization }}</th> <th pResizableColumn (click)="changeSortOrder()">
<th>{{ 'AbpIdentity::EmailAddress' | abpLocalization }}</th> {{ 'AbpIdentity::UserName' | abpLocalization }}
<th>{{ 'AbpIdentity::PhoneNumber' | abpLocalization }}</th> <span class="float-right"
><i [ngClass]="['fa', sortOrder === 'desc' ? 'fa-sort-desc' : 'fa-sort-asc']"></i
></span>
</th>
<th pResizableColumn>{{ 'AbpIdentity::EmailAddress' | abpLocalization }}</th>
<th pResizableColumn>{{ 'AbpIdentity::PhoneNumber' | abpLocalization }}</th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template pTemplate="body" let-data> <ng-template pTemplate="body" let-data>
<tr> <tr>
<td> <td>
<div ngbDropdown class="d-inline-block"> <div ngbDropdown container="body" class="d-inline-block">
<button <button
class="btn btn-primary btn-sm dropdown-toggle" class="btn btn-primary btn-sm dropdown-toggle"
data-toggle="dropdown" data-toggle="dropdown"

6
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

@ -52,6 +52,8 @@ export class UsersComponent {
modalBusy: boolean = false; modalBusy: boolean = false;
sortOrder: string = 'asc';
trackByFn: TrackByFunction<AbstractControl> = (index, item) => Object.keys(item)[0] || index; trackByFn: TrackByFunction<AbstractControl> = (index, item) => Object.keys(item)[0] || index;
get roleGroups(): FormGroup[] { get roleGroups(): FormGroup[] {
@ -169,4 +171,8 @@ export class UsersComponent {
.pipe(finalize(() => (this.loading = false))) .pipe(finalize(() => (this.loading = false)))
.subscribe(); .subscribe();
} }
changeSortOrder() {
this.sortOrder = this.sortOrder.toLowerCase() === 'asc' ? 'desc' : 'asc';
}
} }

Loading…
Cancel
Save