HRM-10/db/Script/MenuIcon_DB_Changes.sql
Mohaimen Hasan 838b8d4480 first commit
2026-11-03 13:06:00 +06:00

48 lines
2.2 KiB
Transact-SQL

/* ============================================================================
Dynamic menu icons
----------------------------------------------------------------------------
Adds an Icon column to dbo.RolePermission so a menu's icon can be changed by
re-uploading Menu.xml (Authentication > Configuration > Menu) instead of a
backend code change + redeploy.
Flow:
1. Menu.xml now carries a menuIcon="..." attribute on every <Menu> node.
2. Uploading it (FileManagerController.uploadConfigurationfile) stores
every XML attribute, including menuIcon, as rows in
dbo.ConfigurationAttribute (SystemConfigurationService.Save).
3. SystemConfigarationDA.UpdateRolePermission then copies name/link/icon
from those attribute rows onto the matching dbo.RolePermission rows
(matched by PermissionCode).
4. RoleService.GetRolePermissionbyUserID reads RolePermission.Icon and
uses it as each menu node's icon, falling back to the old hardcoded
WebMenuStyle icon only if a row has none.
Run order: just this script, once, before re-uploading an icon-bearing
Menu.xml. It is guarded, so it is safe to re-run.
============================================================================ */
IF NOT EXISTS (SELECT 1 FROM sys.columns
WHERE object_id = OBJECT_ID('dbo.RolePermission')
AND name = 'Icon')
BEGIN
ALTER TABLE dbo.RolePermission ADD Icon NVARCHAR(100) NULL;
END;
GO
/* ----------------------------------------------------------------------------
MANUAL STEP - stored procedure (not version-controlled in this repo):
RoleService.GetRolePermissionbyUserID calls dbo.SP_GetUserRolePermission
(via RoleDA.GetRolePermissionByUserID(tc, userID, employeeID)) to read
RolePermission for the logged-in user's menu tree. If that procedure
selects an explicit column list rather than "r.*", add r.Icon to it,
e.g.:
SELECT r.RolePermissionID, r.RoleID, r.PermissionCode, r.Name,
r.Link, r.Icon, r.Status, ...
FROM RolePermission r ...
If it already does "SELECT r.*", no change is needed - the new column
flows through automatically.
---------------------------------------------------------------------------- */