theme handling

This commit is contained in:
Mohaimen Hasan 2026-11-23 11:22:47 +06:00
parent 2e43ccb973
commit 3766ac10b0
10 changed files with 181 additions and 28 deletions

View File

@ -61,7 +61,7 @@ export class AppMainComponent {
}
if(user.UserType === "2"){
this.apiService.isSelService = true;
this.apiService.menuItems = this._auth.getUserMenu();
this.apiService.menuItems = this.liftUnlabelledRootMenus(this._auth.getUserMenu());
}
if(this.apiService.isSelService === true){
this.staticMenuDesktopInactive = true;
@ -74,6 +74,20 @@ export class AppMainComponent {
}
}
}
// The server can send a top-level node with no label whose children are real top-level menus
// (e.g. "Dashboard"). Show those children in the topbar directly instead of under an empty parent.
liftUnlabelledRootMenus(menuItems: any[]): any[] {
const result: any[] = [];
(menuItems || []).forEach(item => {
const hasLabel = item.label && String(item.label).trim() !== '';
if (!hasLabel && item.items && item.items.length > 0) {
result.push(...item.items);
} else if (hasLabel) {
result.push(item);
}
});
return result;
}
ProcessSelfServiceMenu(menuItems : any){
if(menuItems && menuItems.length > 0){
menuItems.forEach(item => {

View File

@ -8,6 +8,7 @@ import {AppMainComponent} from './app.main.component';
import {RolePermission} from './_models/Authentication/role';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { JwtHelperService } from '@auth0/angular-jwt';
@Component({
/* tslint:disable:component-selector */
selector: '[app-menuitem]',
@ -119,9 +120,36 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
key: string;
// SuperUser (UserType "0") only: every parent menu starts expanded and stays expanded when a
// child or another menu is clicked or the page changes; only clicking the parent itself toggles it.
private static superUserFlag: boolean | null = null;
private static superUserToken: string | null = null;
private static isSuperUser(): boolean {
const token = localStorage.getItem('token');
if (token !== AppMenuitemComponent.superUserToken) {
AppMenuitemComponent.superUserToken = token;
let userType: any = null;
try {
userType = token ? new JwtHelperService().decodeToken(token)?.UserType : null;
} catch (e) {
userType = null;
}
AppMenuitemComponent.superUserFlag = String(userType) === '0';
}
return AppMenuitemComponent.superUserFlag === true;
}
private get keepOpen(): boolean {
return !!(this.item && this.item.items) && AppMenuitemComponent.isSuperUser();
}
constructor(public appMain: AppMainComponent, public router: Router,
private cd: ChangeDetectorRef, private menuService: MenuService) {
this.menuSourceSubscription = this.menuService.menuSource$.subscribe(key => {
if (this.keepOpen) {
return;
}
// deactivate current active menu
if (this.active && this.key !== key && key.indexOf(this.key) !== 0) {
this.active = false;
@ -129,12 +157,17 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
});
this.menuResetSubscription = this.menuService.resetSource$.subscribe(() => {
if (this.keepOpen) {
return;
}
this.active = false;
});
this.router.events.pipe(filter(event => event instanceof NavigationEnd))
.subscribe(params => {
if (this.keepOpen) {
return;
}
if (this.appMain.isHorizontal()) {
this.active = false;
@ -166,7 +199,9 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
}
ngOnInit() {
if (!this.appMain.isHorizontal() && this.item.routerLink) {
if (this.keepOpen) {
this.active = true;
} else if (!this.appMain.isHorizontal() && this.item.routerLink) {
this.updateActiveStateFromRoute();
}

View File

@ -146,7 +146,7 @@
@if (sub.items?.length) {
<div class="ss-submenu-item ss-submenu-item--parent"
[class.ss-submenu-item--open]="activeSubMenu === sub.menuKey"
(mouseenter)="openSubMenu(sub.menuKey)"
(mouseenter)="openSubMenu(sub.menuKey, $event)"
(mouseleave)="closeSubMenu()">
<span class="ss-submenu-link">
@if (sub.icon) {
@ -161,7 +161,7 @@
</span>
@if (activeSubMenu === sub.menuKey) {
<div class="ss-submenu ss-submenu--nested"
>
[class.ss-submenu--up]="subMenuOpenUp">
@for (child of sub.items; track child) {
<a class="ss-submenu-link"
[routerLink]="child.routerLink"

View File

@ -116,11 +116,15 @@
position: absolute;
top: calc(100% + 8px);
left: 0;
border: 1px solid $topbar-border-menu !important;
// Solid white panel + palette-dark top edge and shadow, so the dropdown stands out from the
// pale page/cards behind it (all colours come from the palette).
border: 1px solid var(--gh-bo2) !important;
border-top: 3px solid var(--gh-sb) !important;
width: 300px;
background: linear-gradient(160deg, $topbar-gradient-start 0%, $topbar-gradient-end 100%);
background: var(--gh-tb);
border-radius: 14px;
box-shadow: 0 8px 32px color-mix(in srgb, $brand-primary-dark 15%, transparent);
box-shadow: 0 14px 36px color-mix(in srgb, var(--gh-sb) 28%, transparent),
0 3px 8px color-mix(in srgb, var(--gh-sb) 14%, transparent);
padding: 6px;
margin: 0;
z-index: 2000;
@ -146,10 +150,10 @@
white-space: nowrap;
width: 100%;
&:hover { background: color-mix(in srgb, $topbar-accent-purple 10%, transparent); color: $topbar-text-dark; }
&:hover { background: var(--gh-sel); color: var(--gh-ht); }
}
.ss-submenu-item--open > .ss-submenu-link {
background: color-mix(in srgb, $topbar-accent-purple 10%, transparent); color: $topbar-navy;
background: var(--gh-sel); color: var(--gh-sb);
}
.ss-submenu-divider {
height: 1px; margin: 4px 8px;
@ -176,6 +180,20 @@
top: -6px;
width: 290px;
z-index: 2001;
// Never taller than the screen: if it fits neither below nor above, it scrolls inside itself
max-height: calc(100vh - 24px);
overflow-y: auto;
scrollbar-width: thin;
}
// Not enough room below: grow upward from the parent item instead
.ss-submenu--nested.ss-submenu--up {
top: auto;
bottom: -6px;
animation: ssDropUp 0.14s ease;
}
@keyframes ssDropUp {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
.ss-topbar-right {
display: flex; align-items: center; gap: 2px; flex-shrink: 0;
@ -209,7 +227,12 @@
.ss-dd {
position: absolute; top: calc(100% + 8px); right: 0; left: auto;
background: $color-white; border-radius: 14px;
box-shadow: 0 8px 32px color-mix(in srgb, $color-black 13%, transparent);
// Same panel look as the menu dropdown: palette border, dark top edge and a stronger shadow,
// so bookmark / pending approval / notification / user lists stand out from the cards behind.
border: 1px solid var(--gh-bo2);
border-top: 3px solid var(--gh-sb);
box-shadow: 0 14px 36px color-mix(in srgb, var(--gh-sb) 28%, transparent),
0 3px 8px color-mix(in srgb, var(--gh-sb) 14%, transparent);
list-style: none; margin: 0; padding: 0;
z-index: 2000; animation: ssDropIn 0.14s ease;
overflow: hidden;
@ -233,7 +256,7 @@
display: flex; align-items: flex-start; gap: 10px;
padding: 10px 16px; border-bottom: 1px solid $topbar-border-dd-item;
transition: background 0.12s;
&:hover { background: $topbar-bg-hover-dd-item; }
&:hover { background: var(--gh-sel); }
&--new { background: $topbar-bg-dd-item-new; }
&:last-child { border-bottom: none; }
}
@ -266,7 +289,7 @@
display: flex; align-items: center; gap: 10px;
padding: 9px 16px; color: $topbar-text-slate; text-decoration: none;
font-size: 13px; cursor: pointer; transition: background 0.12s;
&:hover { background: $topbar-bg-hover-dd-action; color: $topbar-text-dark; }
&:hover { background: var(--gh-sel); color: $topbar-text-dark; }
i { font-size: 13px; color: $gray-500; }
}
.ss-hamburger { display: none; }
@ -443,10 +466,13 @@
.layout-topbar .topbar-menu > li.user-profile > ul {
width: auto !important; // template has an inline width:250px
min-width: 210px;
border: none;
// same panel as .ss-dd: palette border, dark top edge, stronger shadow
border: 1px solid var(--gh-bo2);
border-top: 3px solid var(--gh-sb);
border-radius: 14px !important; // template has an inline border-radius:20px
background: $color-white;
box-shadow: 0 8px 32px color-mix(in srgb, $color-black 13%, transparent);
box-shadow: 0 14px 36px color-mix(in srgb, var(--gh-sb) 28%, transparent),
0 3px 8px color-mix(in srgb, var(--gh-sb) 14%, transparent);
padding: 0;
overflow: hidden;
animation: ssDropIn 0.14s ease;
@ -478,14 +504,15 @@
}
&:hover {
background: $topbar-bg-hover-dd-action;
background: var(--gh-sel);
color: $topbar-text-dark;
}
}
// First row is the signed-in user's name: the ESS header row
// First row is the signed-in user's name: the ESS header row, centred
> li:first-child > a {
justify-content: space-between;
justify-content: center;
font-weight: 600;
padding: 13px 16px 9px;
border-bottom: 1px solid $topbar-border-faint;
color: $topbar-text-charcoal;
@ -501,5 +528,9 @@
color: $topbar-text-charcoal;
}
}
// the theme's generic row hover must not light up the name row
> li:first-child:hover {
background: transparent;
}
}
}

View File

@ -44,6 +44,7 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy {
menuItems: any[] = [];
activeMenu: string | null = null;
activeSubMenu: string | null = null;
subMenuOpenUp = false;
mobileMenuOpen = false;
mobOpenSection: string | null = null;
mobOpenSubSection: string | null = null;
@ -549,9 +550,29 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy {
this.activeMenu = menuKey;
this.activeSubMenu = null;
}
openSubMenu(menuKey: string) {
openSubMenu(menuKey: string, event?: Event) {
clearTimeout(this.closeTimer);
if (this.activeSubMenu === menuKey) {
return;
}
this.activeSubMenu = menuKey;
this.subMenuOpenUp = false;
// Once the nested menu is rendered, open it upward if it would run past the bottom of the screen
// and there is more room above (it scrolls inside itself if it fits neither way).
const host = event?.currentTarget as HTMLElement | null;
if (host) {
setTimeout(() => {
const nested = host.querySelector('.ss-submenu--nested') as HTMLElement | null;
if (!nested || this.activeSubMenu !== menuKey) {
return;
}
const menuRect = nested.getBoundingClientRect();
const hostRect = host.getBoundingClientRect();
const spaceBelow = window.innerHeight - hostRect.top;
const spaceAbove = hostRect.bottom;
this.subMenuOpenUp = menuRect.bottom > window.innerHeight - 8 && spaceAbove > spaceBelow;
});
}
}
closeSubMenu() {

View File

@ -91,12 +91,14 @@
<!-- Same look as the Role page's last column: one button per action. Which actions a row gets
is still decided by actionsFor() (dataItem.actions), and a click still runs onRowAction(). -->
<kendo-grid-column title="Actions" [width]="180" [filterable]="false" [sortable]="false">
<kendo-grid-column title="Actions" [width]="240" [filterable]="false" [sortable]="false">
<ng-template kendoGridCellTemplate let-dataItem>
@for (a of dataItem.actions; track a.action) {
<button class="k-button k-primary ul-row-action" kendoButton [svgIcon]="a.svgIcon"
(click)="onRowAction(a, dataItem)">{{ a.text }}</button>
}
<div class="ul-row-actions">
@for (a of dataItem.actions; track a.action) {
<button class="k-button k-primary ul-row-action" kendoButton [svgIcon]="a.svgIcon"
(click)="onRowAction(a, dataItem)">{{ a.text }}</button>
}
</div>
</ng-template>
</kendo-grid-column>

View File

@ -136,6 +136,29 @@
.ul-row-action + .ul-row-action {
margin-left: 6px;
}
// Buttons always show their whole label: they never shrink, and if the column is too narrow
// the next button moves to a new line instead of the text being cut to "…".
.ul-row-actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
// spacing comes from the gap here, so a wrapped button starts flush left
.ul-row-action + .ul-row-action {
margin-left: 0;
}
}
.ul-row-action {
flex-shrink: 0;
max-width: none;
white-space: nowrap;
::ng-deep .k-button-text {
overflow: visible;
text-overflow: clip;
}
}
.ul-login {
font-weight: 600;

View File

@ -20,16 +20,16 @@
<span class="profile-empno">{{employee?.employeeNo}}</span>
</div>
<div class="profile-actions profile-actions--desktop">
<button kendoTooltip class="action-btn btn-edit" kendoButton title="Edit Profile" [routerLink]="'/ess/self-profile'">
<button kendoTooltip class="action-btn btn-edit" kendoButton title="Edit Profile" [routerLink]="'/ess/self-profile'" style="width:30px !important;height:30px !important;min-width:30px !important;min-height:30px !important;padding:0 !important;border-radius:50% !important;">
<i class="pi pi-user-edit"></i>
</button>
@if (!apiService.isSSO) {
<button kendoTooltip class="action-btn btn-key" kendoButton title="Change Password" [routerLink]="'/authentication/change-password'">
<button kendoTooltip class="action-btn btn-key" kendoButton title="Change Password" [routerLink]="'/authentication/change-password'" style="width:30px !important;height:30px !important;min-width:30px !important;min-height:30px !important;padding:0 !important;border-radius:50% !important;">
<i class="pi pi-key"></i>
</button>
}
@if (switchUserId != undefined) {
<button kendoTooltip class="action-btn btn-switch" kendoButton title="Switch to Admin" (click)="switchUser()">
<button kendoTooltip class="action-btn btn-switch" kendoButton title="Switch to Admin" (click)="switchUser()" style="width:30px !important;height:30px !important;min-width:30px !important;min-height:30px !important;padding:0 !important;border-radius:50% !important;">
<i class="pi pi-sort-alt" style="transform:rotate(90deg)"></i>
</button>
}

View File

@ -1398,4 +1398,15 @@
}
.clickable {
cursor: pointer !important;
}
}
// Edit Profile / Change Password / Switch: always a perfect circle (Kendo button padding no longer stretches them)
.profile-actions--desktop .action-btn {
box-sizing: border-box !important;
padding: 0 !important;
min-width: 30px !important;
min-height: 30px !important;
aspect-ratio: 1 / 1;
line-height: 1 !important;
border-radius: 50% !important;
}

View File

@ -137,6 +137,22 @@ body .layout-wrapper .layout-topbar .topbar-menu > li > a .topbar-badge {
body .layout-wrapper .layout-topbar .topbar-menu > li > ul {
border-color: var(--gh-bo);
}
// Desktop: same panel look as the self-service dropdowns (solid panel, palette border, dark top
// edge, stronger shadow) so user / bookmark / pending-job lists stand out from the page behind.
// Below 897px Babylon shows these lists inline inside the topbar, so they stay flat there.
@media screen and (min-width: 897px) {
body .layout-wrapper .layout-topbar .topbar-menu > li > ul {
background-color: var(--gh-tb);
border: 1px solid var(--gh-bo2);
border-top: 3px solid var(--gh-sb);
box-shadow: 0 14px 36px color-mix(in srgb, var(--gh-sb) 28%, transparent),
0 3px 8px color-mix(in srgb, var(--gh-sb) 14%, transparent);
}
// Rows without their own link hover (pending jobs) get the same palette hover
body .layout-wrapper .layout-topbar .topbar-menu > li > ul > li:hover {
background-color: var(--gh-sel);
}
}
body .layout-wrapper .layout-topbar .topbar-menu > li > ul a:hover {
background-color: var(--gh-sel);
}