@apptimate/core-lib 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/constants/menus.ts +48 -29
package/package.json
CHANGED
package/src/constants/menus.ts
CHANGED
|
@@ -2,6 +2,7 @@ export interface SubMenuItem {
|
|
|
2
2
|
id: string;
|
|
3
3
|
label: string;
|
|
4
4
|
path: string;
|
|
5
|
+
permission?: string | null;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export interface SubMenuGroup {
|
|
@@ -122,39 +123,42 @@ export const MENU_ITEM_REGISTRY: RegistryItem[] = [
|
|
|
122
123
|
{ key: 'finance__party_statement', label: 'Party Statement', path: '/finance/reports/party-statement', module: 'Finance', defaultGroup: 'Reports', permission: null },
|
|
123
124
|
{ key: 'finance__payment_modes', label: 'Payment Modes', path: '/finance/payment-modes', module: 'Finance', defaultGroup: 'Settings', permission: null },
|
|
124
125
|
{ key: 'finance__bank_accounts', label: 'Bank Accounts', path: '/finance/bank-accounts', module: 'Finance', defaultGroup: 'Settings', permission: null },
|
|
126
|
+
{ key: 'finance__cheque_books', label: 'Cheque Books', path: '/finance/cheque-books', module: 'Finance', defaultGroup: 'Settings', permission: 'finance.cheque_book.view' },
|
|
127
|
+
{ key: 'finance__cheque_registry', label: 'Cheque Registry', path: '/finance/cheque-registry', module: 'Finance', defaultGroup: 'Transactions', permission: 'finance.cheque_book.view' },
|
|
125
128
|
{ key: 'finance__account_mappings', label: 'Account Mappings', path: '/finance/account-mappings', module: 'Finance', defaultGroup: 'Settings', permission: null },
|
|
126
129
|
{ key: 'finance__opening_balances', label: 'Opening Balances', path: '/finance/opening-balances', module: 'Finance', defaultGroup: 'Settings', permission: null },
|
|
127
130
|
{ key: 'finance__transaction_ledger', label: 'Transaction Ledger', path: '/finance/transactions', module: 'Finance', defaultGroup: 'Transactions', permission: null },
|
|
128
131
|
{ key: 'finance__bank_statements', label: 'Bank Statements', path: '/finance/bank-statements', module: 'Finance', defaultGroup: 'Reports', permission: null },
|
|
129
132
|
|
|
130
133
|
// ── Jewelry Module ──
|
|
131
|
-
{ key: 'jewelry__items', label: 'Jewelry Items', path: '/jewelry/items', module: 'Jewelry', defaultGroup: 'Catalog', permission:
|
|
132
|
-
|
|
133
|
-
{ key: 'jewelry__categories', label: 'Categories', path: '/jewelry/categories', module: 'Jewelry', defaultGroup: 'Catalog', permission:
|
|
134
|
-
{ key: 'jewelry__material_types', label: 'Material Types', path: '/jewelry/material-types', module: 'Jewelry', defaultGroup: 'Master Data', permission:
|
|
135
|
-
{ key: 'jewelry__purities', label: 'Purities', path: '/jewelry/purities', module: 'Jewelry', defaultGroup: 'Master Data', permission:
|
|
136
|
-
{ key: 'jewelry__metal_rates', label: 'Metal Rates', path: '/jewelry/metal-rates', module: 'Jewelry', defaultGroup: 'Master Data', permission:
|
|
137
|
-
{ key: 'jewelry__purchase_orders', label: 'Purchase Orders', path: '/jewelry/procurement/orders', module: 'Jewelry', defaultGroup: 'Procurement', permission:
|
|
138
|
-
{ key: 'jewelry__grn', label: 'Goods Receipt', path: '/jewelry/procurement/grn', module: 'Jewelry', defaultGroup: 'Procurement', permission:
|
|
139
|
-
{ key: 'jewelry__custom_orders', label: 'Custom Orders', path: '/jewelry/custom-orders', module: 'Jewelry', defaultGroup: 'Procurement', permission:
|
|
140
|
-
{ key: 'jewelry__service_orders', label: 'Service Orders', path: '/jewelry/service-orders', module: 'Jewelry', defaultGroup: 'Procurement', permission:
|
|
141
|
-
{ key: 'jewelry__opening_stock', label: 'Opening Stock', path: '/jewelry/procurement/opening_stock', module: 'Jewelry', defaultGroup: 'Procurement', permission:
|
|
142
|
-
{ key: 'jewelry__transformations', label: 'Transformations', path: '/jewelry/procurement/transformations', module: 'Jewelry', defaultGroup: 'Procurement', permission:
|
|
143
|
-
{ key: 'jewelry__old_gold_purchases', label: 'Old Material Purchases', path: '/jewelry/old-gold-purchases', module: 'Jewelry', defaultGroup: 'Buying', permission:
|
|
144
|
-
{ key: 'jewelry__sales', label: 'Sales', path: '/jewelry/sales', module: 'Jewelry', defaultGroup: 'Sales', permission:
|
|
145
|
-
{ key: 'jewelry__sales_returns', label: 'Sales Returns', path: '/jewelry/sales-returns', module: 'Jewelry', defaultGroup: 'Sales', permission:
|
|
146
|
-
|
|
147
|
-
{ key: 'jewelry__stock_balances', label: 'Stock Balances', path: '/jewelry/stock/balances', module: 'Jewelry', defaultGroup: 'Stock', permission:
|
|
148
|
-
{ key: 'jewelry__stock_movements', label: 'Stock Movements', path: '/jewelry/stock/movements', module: 'Jewelry', defaultGroup: 'Stock', permission:
|
|
149
|
-
{ key: 'jewelry__stock_transfers', label: 'Transfers', path: '/jewelry/stock-transfers', module: 'Jewelry', defaultGroup: 'Stock', permission:
|
|
150
|
-
{ key: 'jewelry__party_transactions', label: 'Party Transactions', path: '/jewelry/party-transactions', module: 'Jewelry', defaultGroup: 'Karigar', permission:
|
|
151
|
-
|
|
152
|
-
{ key: 'jewelry__karigar_making_charges', label: 'Making Charges', path: '/jewelry/karigar-making-charges', module: 'Jewelry', defaultGroup: 'Karigar', permission:
|
|
153
|
-
{ key: 'jewelry__party_metal_balances', label: 'Party Metal Balances', path: '/jewelry/party-metal-balances', module: 'Jewelry', defaultGroup: 'Karigar', permission:
|
|
154
|
-
{ key: 'jewelry__metal_settlements', label: 'Metal Settlements', path: '/jewelry/metal-settlements', module: 'Jewelry', defaultGroup: 'Karigar', permission:
|
|
155
|
-
{ key: 'jewelry__settings', label: 'Settings', path: '/jewelry/settings', module: 'Jewelry', defaultGroup: 'Configuration', permission:
|
|
156
|
-
{ key: 'jewelry__billing_templates', label: 'Billing Templates', path: '/jewelry/billing-templates', module: 'Jewelry', defaultGroup: 'Configuration', permission:
|
|
157
|
-
{ key: 'jewelry__reports', label: 'Reports & Dashboards', path: '/reports/jewelry', module: 'Jewelry', defaultGroup: 'Analytics', permission:
|
|
134
|
+
{ key: 'jewelry__items', label: 'Jewelry Items', path: '/jewelry/items', module: 'Jewelry', defaultGroup: 'Catalog', permission: 'jewelry.items.view' },
|
|
135
|
+
|
|
136
|
+
{ key: 'jewelry__categories', label: 'Categories', path: '/jewelry/categories', module: 'Jewelry', defaultGroup: 'Catalog', permission: 'jewelry.categories.view' },
|
|
137
|
+
{ key: 'jewelry__material_types', label: 'Material Types', path: '/jewelry/material-types', module: 'Jewelry', defaultGroup: 'Master Data', permission: 'jewelry.material_types.view' },
|
|
138
|
+
{ key: 'jewelry__purities', label: 'Purities', path: '/jewelry/purities', module: 'Jewelry', defaultGroup: 'Master Data', permission: 'jewelry.purities.view' },
|
|
139
|
+
{ key: 'jewelry__metal_rates', label: 'Metal Rates', path: '/jewelry/metal-rates', module: 'Jewelry', defaultGroup: 'Master Data', permission: 'jewelry.metal_rates.view' },
|
|
140
|
+
{ key: 'jewelry__purchase_orders', label: 'Purchase Orders', path: '/jewelry/procurement/orders', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.purchase_orders.view' },
|
|
141
|
+
{ key: 'jewelry__grn', label: 'Goods Receipt', path: '/jewelry/procurement/grn', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.grn.view' },
|
|
142
|
+
{ key: 'jewelry__custom_orders', label: 'Custom Orders', path: '/jewelry/custom-orders', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.custom_orders.view' },
|
|
143
|
+
{ key: 'jewelry__service_orders', label: 'Service Orders', path: '/jewelry/service-orders', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.services.view' },
|
|
144
|
+
{ key: 'jewelry__opening_stock', label: 'Opening Stock', path: '/jewelry/procurement/opening_stock', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.opening_stock.view' },
|
|
145
|
+
{ key: 'jewelry__transformations', label: 'Transformations', path: '/jewelry/procurement/transformations', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.transformations.view' },
|
|
146
|
+
{ key: 'jewelry__old_gold_purchases', label: 'Old Material Purchases', path: '/jewelry/old-gold-purchases', module: 'Jewelry', defaultGroup: 'Buying', permission: 'jewelry.old_gold_purchases.view' },
|
|
147
|
+
{ key: 'jewelry__sales', label: 'Sales', path: '/jewelry/sales', module: 'Jewelry', defaultGroup: 'Sales', permission: 'jewelry.sales.view' },
|
|
148
|
+
{ key: 'jewelry__sales_returns', label: 'Sales Returns', path: '/jewelry/sales-returns', module: 'Jewelry', defaultGroup: 'Sales', permission: 'jewelry.sale_returns.view' },
|
|
149
|
+
|
|
150
|
+
{ key: 'jewelry__stock_balances', label: 'Stock Balances', path: '/jewelry/stock/balances', module: 'Jewelry', defaultGroup: 'Stock', permission: 'jewelry.stock_balances.view' },
|
|
151
|
+
{ key: 'jewelry__stock_movements', label: 'Stock Movements', path: '/jewelry/stock/movements', module: 'Jewelry', defaultGroup: 'Stock', permission: 'jewelry.stock_movements.view' },
|
|
152
|
+
{ key: 'jewelry__stock_transfers', label: 'Transfers', path: '/jewelry/stock-transfers', module: 'Jewelry', defaultGroup: 'Stock', permission: 'jewelry.stock_transfers.view' },
|
|
153
|
+
{ key: 'jewelry__party_transactions', label: 'Party Transactions', path: '/jewelry/party-transactions', module: 'Jewelry', defaultGroup: 'Karigar', permission: 'jewelry.karigar_transactions.view' },
|
|
154
|
+
|
|
155
|
+
{ key: 'jewelry__karigar_making_charges', label: 'Making Charges', path: '/jewelry/karigar-making-charges', module: 'Jewelry', defaultGroup: 'Karigar', permission: 'jewelry.karigar_making_charges.view' },
|
|
156
|
+
{ key: 'jewelry__party_metal_balances', label: 'Party Metal Balances', path: '/jewelry/party-metal-balances', module: 'Jewelry', defaultGroup: 'Karigar', permission: 'jewelry.party_metal_balances.view' },
|
|
157
|
+
{ key: 'jewelry__metal_settlements', label: 'Metal Settlements', path: '/jewelry/metal-settlements', module: 'Jewelry', defaultGroup: 'Karigar', permission: 'metal_settlement.view' },
|
|
158
|
+
{ key: 'jewelry__settings', label: 'Settings', path: '/jewelry/settings', module: 'Jewelry', defaultGroup: 'Configuration', permission: 'jewelry.settings.view' },
|
|
159
|
+
{ key: 'jewelry__billing_templates', label: 'Billing Templates', path: '/jewelry/billing-templates', module: 'Jewelry', defaultGroup: 'Configuration', permission: 'jewelry.billing_templates.view' },
|
|
160
|
+
{ key: 'jewelry__reports', label: 'Reports & Dashboards', path: '/reports/jewelry', module: 'Jewelry', defaultGroup: 'Analytics', permission: 'jewelry.reports.view' },
|
|
161
|
+
|
|
158
162
|
|
|
159
163
|
// ── HR Module ──
|
|
160
164
|
{ key: 'hr__employees', label: 'Employees', path: '/hr/employees', module: 'HR', defaultGroup: 'Core', permission: null },
|
|
@@ -249,6 +253,7 @@ export function resolveRegistryKeys(items: SecondaryItemConfig[]): SubMenuGroup[
|
|
|
249
253
|
id: cfg.key,
|
|
250
254
|
label: cfg.label || reg.label,
|
|
251
255
|
path: reg.path,
|
|
256
|
+
permission: reg.permission,
|
|
252
257
|
});
|
|
253
258
|
}
|
|
254
259
|
|
|
@@ -328,10 +333,10 @@ export const MENU_PRESETS: MenuPreset[] = [
|
|
|
328
333
|
label: 'Finance',
|
|
329
334
|
iconName: 'Wallet',
|
|
330
335
|
secondaryItems: [
|
|
331
|
-
'finance__invoices', 'finance__payments', 'finance__direct_transactions', 'finance__transaction_ledger',
|
|
336
|
+
'finance__invoices', 'finance__payments', 'finance__cheque_registry', 'finance__direct_transactions', 'finance__transaction_ledger',
|
|
332
337
|
'finance__chart_of_accounts', 'finance__journal_entries', 'finance__fiscal_years',
|
|
333
338
|
'finance__trial_balance', 'finance__profit_loss', 'finance__balance_sheet', 'finance__account_ledger', 'finance__party_statement',
|
|
334
|
-
'finance__payment_modes', 'finance__bank_accounts', 'finance__bank_statements', 'finance__account_mappings', 'finance__opening_balances',
|
|
339
|
+
'finance__payment_modes', 'finance__bank_accounts', 'finance__cheque_books', 'finance__bank_statements', 'finance__account_mappings', 'finance__opening_balances',
|
|
335
340
|
],
|
|
336
341
|
},
|
|
337
342
|
{
|
|
@@ -421,3 +426,17 @@ export function buildMenusFromConfig(config: {
|
|
|
421
426
|
groups: resolveRegistryKeys(pm.secondaryItems),
|
|
422
427
|
}));
|
|
423
428
|
}
|
|
429
|
+
|
|
430
|
+
export function filterMenusByPermission(menus: MainMenuItem[], can: (code: string) => boolean): MainMenuItem[] {
|
|
431
|
+
return menus.map(mainMenu => {
|
|
432
|
+
const filteredGroups = mainMenu.groups.map(group => {
|
|
433
|
+
const filteredItems = group.items.filter(item => {
|
|
434
|
+
if (!item.permission) return true;
|
|
435
|
+
return can(item.permission);
|
|
436
|
+
});
|
|
437
|
+
return { ...group, items: filteredItems };
|
|
438
|
+
}).filter(group => group.items.length > 0);
|
|
439
|
+
|
|
440
|
+
return { ...mainMenu, groups: filteredGroups };
|
|
441
|
+
}).filter(mainMenu => mainMenu.groups.length > 0);
|
|
442
|
+
}
|