Role Permission
This commit is contained in:
parent
1853718cbd
commit
182effa8b5
|
|
@ -15,6 +15,98 @@
|
|||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
/* Toolbar, same layout as the User page: search + counts on the left, Export + Add on the right */
|
||||
.rl-grid .rl-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.rl-grid .rl-toolbar__filters,
|
||||
.rl-grid .rl-toolbar__actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.rl-grid .rl-search {
|
||||
width: 240px;
|
||||
}
|
||||
/* Count chips (display only) */
|
||||
.rl-grid .rl-chips {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.rl-grid .rl-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
height: 30px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid #E3E3EC;
|
||||
border-radius: 999px;
|
||||
background: #FFFFFF;
|
||||
color: #424242;
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s, border-color 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.rl-grid .rl-chip:hover {
|
||||
border-color: #52527A;
|
||||
}
|
||||
|
||||
.rl-grid .rl-chip:focus-visible {
|
||||
outline: 2px solid #52527A;
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
.rl-grid .rl-chip.is-selected {
|
||||
background: #52527A;
|
||||
border-color: #52527A;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.rl-grid .rl-chip.is-selected .rl-chip__count {
|
||||
background: rgba(255, 255, 255, 0.22);
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.rl-grid .rl-chip__count {
|
||||
min-width: 20px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
background: #F1F1F1;
|
||||
color: #666666;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.rl-grid .rl-chip--pending:not(.is-selected) .rl-chip__count {
|
||||
background: #FFF2DB;
|
||||
color: #8A5300;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.rl-grid .rl-toolbar__actions {
|
||||
width: 100%;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.rl-grid .rl-search {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Status badge */
|
||||
.rl-grid .rl-badge {
|
||||
display: inline-flex;
|
||||
|
|
|
|||
|
|
@ -12,10 +12,35 @@
|
|||
[columnMenu]="{ filter: true }"
|
||||
(add)="addHandler()">
|
||||
<ng-template kendoGridToolbarTemplate>
|
||||
<button themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['plus']" kendoGridAddCommand>Add new</button>
|
||||
<input placeholder="Search in all columns..." kendoTextBox (input)="onFilter($event.target.value)" />
|
||||
<button kendoGridExcelCommand type="button" [svgIcon]="apiService.KendoSVGIcon['fileExcel']" style="float:right;">Export to Excel</button>
|
||||
<button kendoGridPDFCommand [svgIcon]="apiService.KendoSVGIcon['filePdf']" style="float:right;">Export to PDF</button>
|
||||
<div class="rl-toolbar">
|
||||
<div class="rl-toolbar__filters">
|
||||
<input placeholder="Search in all columns..." kendoTextBox class="rl-search" (input)="onFilter($event.target.value)" />
|
||||
|
||||
<!-- Status chips (same as the User page): count, and click to filter the grid -->
|
||||
<div class="rl-chips" role="group" aria-label="Filter by status">
|
||||
<button type="button" class="rl-chip" [class.is-selected]="statusFilter === 'all'" (click)="setStatusFilter('all')">
|
||||
All <span class="rl-chip__count">{{ roleCounts.all }}</span>
|
||||
</button>
|
||||
<button type="button" class="rl-chip" [class.is-selected]="statusFilter === 'active'" (click)="setStatusFilter('active')">
|
||||
Active <span class="rl-chip__count">{{ roleCounts.active }}</span>
|
||||
</button>
|
||||
<button type="button" class="rl-chip rl-chip--pending" [class.is-selected]="statusFilter === 'pending'" (click)="setStatusFilter('pending')">
|
||||
Pending approval <span class="rl-chip__count">{{ roleCounts.pending }}</span>
|
||||
</button>
|
||||
<button type="button" class="rl-chip" [class.is-selected]="statusFilter === 'inactive'" (click)="setStatusFilter('inactive')">
|
||||
Inactive <span class="rl-chip__count">{{ roleCounts.inactive }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rl-toolbar__actions">
|
||||
<button kendoGridExcelCommand type="button" fillMode="outline"
|
||||
[svgIcon]="apiService.KendoSVGIcon['fileExcel']">Export to Excel</button>
|
||||
<button kendoGridPDFCommand type="button" fillMode="outline"
|
||||
[svgIcon]="apiService.KendoSVGIcon['filePdf']">Export to PDF</button>
|
||||
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['plus']" (click)="addHandler()">Add new</button>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
<kendo-grid-column field="code" title="Code">
|
||||
</kendo-grid-column>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import {Component, OnInit, ViewChild, ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
|
||||
import {process, State} from '@progress/kendo-data-query';
|
||||
import {DataBindingDirective, GridComponent} from '@progress/kendo-angular-grid';
|
||||
import {ExcelExportData} from '@progress/kendo-angular-excel-export';
|
||||
import {Router} from '@angular/router';
|
||||
import {ExcelExportData} from '@progress/kendo-angular-excel-export';import {Router} from '@angular/router';
|
||||
import {AuthService} from '../../../_services/auth/auth.service';
|
||||
import {Role} from '../../../_models/Authentication/role';
|
||||
import { HRMNotificationService } from '../../../app.notification.service';
|
||||
|
|
@ -39,6 +38,29 @@ export class RolePermissionListComponent implements OnInit {
|
|||
roles: Role[];
|
||||
selectedRole: Role;
|
||||
viewMode: number =1; //1 new, 2 edit ,3 approve
|
||||
|
||||
/** Status chip group of a role: New / Edited / Deleted not yet approved count as Pending. */
|
||||
statusGroup(r: Role): 'active' | 'pending' | 'inactive' {
|
||||
if (r.roleStatus == EnumAuthStatus.Active || r.roleStatus == EnumAuthStatus.Approved) {
|
||||
return 'active';
|
||||
}
|
||||
if (r.roleStatus == EnumAuthStatus.New_Not_Yet_Approve
|
||||
|| r.roleStatus == EnumAuthStatus.Edited_Not_Yet_Approve
|
||||
|| r.roleStatus == EnumAuthStatus.Deleted_Not_Yet_Approve) {
|
||||
return 'pending';
|
||||
}
|
||||
return 'inactive';
|
||||
}
|
||||
|
||||
/** Toolbar chip counts (all roles, not narrowed by search or chip). */
|
||||
get roleCounts(): { all: number, active: number, pending: number, inactive: number } {
|
||||
const counts = { all: 0, active: 0, pending: 0, inactive: 0 };
|
||||
(this.roles ?? []).forEach(r => {
|
||||
counts.all++;
|
||||
counts[this.statusGroup(r)]++;
|
||||
});
|
||||
return counts;
|
||||
}
|
||||
constructor(public useService: AuthService,public apiService: ApiService,
|
||||
public router: Router, public utilityService: UntilityHandlerService, public apiservice: ApiService,
|
||||
public loadingPanel: loadingPanelService) {
|
||||
|
|
@ -160,13 +182,25 @@ export class RolePermissionListComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
/** Toolbar status chip: which group of roles the grid shows. */
|
||||
statusFilter: 'all' | 'active' | 'pending' | 'inactive' = 'all';
|
||||
|
||||
setStatusFilter(filter: 'all' | 'active' | 'pending' | 'inactive'): void {
|
||||
this.statusFilter = filter;
|
||||
this.refreshGridView();
|
||||
if (this.dataBinding) {
|
||||
this.dataBinding.skip = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private refreshGridView(): void {
|
||||
const base = (this.roles ?? []).filter(r => this.statusFilter === 'all' || this.statusGroup(r) === this.statusFilter);
|
||||
const term = this.searchText.trim();
|
||||
if (!term) {
|
||||
this.gridView = (this.roles ?? []).slice();
|
||||
this.gridView = base;
|
||||
return;
|
||||
}
|
||||
this.gridView = process(this.roles ?? [], {
|
||||
this.gridView = process(base, {
|
||||
filter: {
|
||||
logic: 'or',
|
||||
filters: [
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user