This commit is contained in:
Mohaimen Hasan 2026-11-09 15:57:13 +06:00
parent ae428ff452
commit 1895b2faa7
4 changed files with 81 additions and 0 deletions

View File

@ -98,6 +98,12 @@
}
</ul>
</li>
<!-- li items float right, so this one (last in DOM) sits LEFT of the Pending Jobs icon -->
@if (payrollTypeName) {
<li class="topbar-payroll-type-item">
<span class="topbar-payroll-type" kendoTooltip title="Current payroll type">{{payrollTypeName}}</span>
</li>
}
</ul>
<a class="layout-menus">
@if (apiService.menuItems !== null) {

View File

@ -409,3 +409,27 @@
border-left: 1px solid $topbar-accent-purple-light;
margin-left: 12px;
}
// Current payroll type label (admin logins), left of the Pending Jobs icon.
// Sits on the dark admin topbar, so it uses the same white as .topbar-icon.
.topbar-payroll-type-item {
display: flex;
align-items: center;
height: 36px;
}
.topbar-payroll-type {
display: inline-block;
max-width: 260px;
padding: 4px 12px;
border: 1px solid rgba($color-white, 0.35);
border-radius: 999px;
background: rgba($color-white, 0.12);
color: $color-white;
font-size: 13px;
font-weight: 600;
line-height: 18px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: default;
}

View File

@ -54,6 +54,13 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy {
private notifPanelWasOpen = false;
private subscriptions: Subscription[] = [];
// Current payroll type's description, shown left of the Pending Jobs icon for admin
// (EnumUserType.User) logins only. Re-read whenever the stored token changes
// (login, user switch, payroll-type switch, logout).
payrollTypeName: string = '';
private payrollTypeToken: string | null | undefined = undefined;
private payrollTypeSub: Subscription | null = null;
isScrolled: boolean = false;
@HostListener('window:scroll', [])
onWindowScroll() {
@ -159,6 +166,46 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy {
this.onNotificationPanelClosed();
}
this.notifPanelWasOpen = isOpen;
this.syncPayrollTypeName();
}
/**
* Shows the current payroll type's description for admin logins. Cheap on every
* change-detection pass: it only does work when the token in localStorage changed.
* The name comes from the server (GetPayrollTypeByLoginID), so it is the payroll
* type the API actually scopes data by.
*/
private syncPayrollTypeName(): void {
const token = localStorage.getItem('token');
if (token === this.payrollTypeToken) {
return;
}
this.payrollTypeToken = token;
if (this.payrollTypeSub) {
this.payrollTypeSub.unsubscribe();
this.payrollTypeSub = null;
}
let user: any = null;
try {
user = token ? new JwtHelperService().decodeToken(token) : null;
} catch {
user = null;
}
if (!user || user.UserType != EnumUserType.User || !user.PayrollTypeID) {
this.payrollTypeName = '';
return;
}
this.payrollTypeSub = this.authService.GetPayrollTypeByLoginID().subscribe({
next: (payrollType) => {
this.payrollTypeName = payrollType?.description ?? '';
},
error: () => {
this.payrollTypeName = '';
},
});
}
/**
@ -176,6 +223,9 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy {
ngOnDestroy(): void {
this.subscriptions.forEach(s => s.unsubscribe());
if (this.payrollTypeSub) {
this.payrollTypeSub.unsubscribe();
}
}
loadBookmark() {

View File

@ -54,6 +54,7 @@ export class DiscontinueEmployeeDetailsComponent implements OnInit {
this.notificationService.showWarning('From Date cannot be after To Date.', 'Warning');
return;
}
debugger;
this.grid.load({ fromDate: this.fromDate, toDate: this.toDate });
}