diff --git a/src/PowderCoating.Web/Views/CompanyUsers/Create.cshtml b/src/PowderCoating.Web/Views/CompanyUsers/Create.cshtml index f32a114..f21e1a9 100644 --- a/src/PowderCoating.Web/Views/CompanyUsers/Create.cshtml +++ b/src/PowderCoating.Web/Views/CompanyUsers/Create.cshtml @@ -119,90 +119,105 @@
+
Create, edit, and update job status; manage job items, worker assignments, and time entries
+
Add and adjust powder stock, record transactions, manage reorder levels
+
Create and edit customer records, pricing tiers, tax exemption, and credit limits
+
Build quotes with line items and AI photo quoting; convert accepted quotes to jobs
+
Accept or reject submitted quotes on behalf of the company
+
Create, edit, and delete oven schedule batches and calendar events
+
View the oven scheduler and job calendar (read-only, no editing)
+
Add and edit catalog items, service pricing, and pricing tier configurations
+
Browse the service catalog and inventory items (read-only, no editing)
+
Add and update equipment records, track status changes and operating costs
+
Add and edit vendor/supplier records, payment terms, and contact information
+
Schedule and record equipment maintenance tasks, assign technicians, log parts used
+
Create invoices, record payments, send to customers, issue voids and write-offs
+
Access financial and operational reports, analytics dashboards, and data exports
+
Enter and pay vendor bills, manage purchase orders and accounts payable
@@ -237,32 +252,33 @@ const permissionCheckboxes = document.querySelectorAll('.permission-checkbox'); const adminAlert = document.getElementById('companyAdminAlert'); - const accountantDefaults = ['CanManageInvoices', 'CanViewReports', 'CanManageVendors', 'CanManageBills', 'CanManageAccounting']; + const roleDefaults = { + 'Viewer': ['CanViewCalendar', 'CanViewProducts'], + 'Worker': ['CanManageJobs', 'CanViewCalendar', 'CanViewProducts'], + 'Accountant': ['CanManageInvoices', 'CanViewReports', 'CanManageVendors', 'CanManageBills', 'CanManageAccounting'], + 'Manager': ['CanManageJobs', 'CanManageInventory', 'CanManageCustomers', 'CanCreateQuotes', 'CanApproveQuotes', + 'CanManageCalendar', 'CanViewCalendar', 'CanManageProducts', 'CanViewProducts', + 'CanManageEquipment', 'CanManageVendors', 'CanManageMaintenance', 'CanManageInvoices', + 'CanViewReports', 'CanManageBills'] + }; function updatePermissionState() { const role = roleSelect.value; const isCompanyAdmin = role === 'CompanyAdmin'; - const isAccountant = role === 'Accountant'; - adminAlert.style.display = isCompanyAdmin ? 'block' : 'none'; - + const defaults = roleDefaults[role] || []; permissionCheckboxes.forEach(checkbox => { if (isCompanyAdmin) { checkbox.checked = true; checkbox.disabled = true; } else { checkbox.disabled = false; - if (isAccountant) { - checkbox.checked = accountantDefaults.includes(checkbox.id); - } + checkbox.checked = defaults.includes(checkbox.id); } }); } - // Run on page load updatePermissionState(); - - // Run when role changes roleSelect.addEventListener('change', updatePermissionState); }); diff --git a/src/PowderCoating.Web/Views/CompanyUsers/Edit.cshtml b/src/PowderCoating.Web/Views/CompanyUsers/Edit.cshtml index 19b695f..2fd3007 100644 --- a/src/PowderCoating.Web/Views/CompanyUsers/Edit.cshtml +++ b/src/PowderCoating.Web/Views/CompanyUsers/Edit.cshtml @@ -136,90 +136,105 @@
+
Create, edit, and update job status; manage job items, worker assignments, and time entries
+
Add and adjust powder stock, record transactions, manage reorder levels
+
Create and edit customer records, pricing tiers, tax exemption, and credit limits
+
Build quotes with line items and AI photo quoting; convert accepted quotes to jobs
+
Accept or reject submitted quotes on behalf of the company
+
Create, edit, and delete oven schedule batches and calendar events
+
View the oven scheduler and job calendar (read-only, no editing)
+
Add and edit catalog items, service pricing, and pricing tier configurations
+
Browse the service catalog and inventory items (read-only, no editing)
+
Add and update equipment records, track status changes and operating costs
+
Add and edit vendor/supplier records, payment terms, and contact information
+
Schedule and record equipment maintenance tasks, assign technicians, log parts used
+
Create invoices, record payments, send to customers, issue voids and write-offs
+
Access financial and operational reports, analytics dashboards, and data exports
+
Enter and pay vendor bills, manage purchase orders and accounts payable
@@ -263,39 +278,45 @@ const adminAlert = document.getElementById('companyAdminAlert'); const isSuperAdmin = @((ViewBag.IsSuperAdmin as bool? ?? false) ? "true" : "false"); - const accountantDefaults = ['CanManageInvoices', 'CanViewReports', 'CanManageVendors', 'CanManageBills', 'CanManageAccounting']; + const roleDefaults = { + 'Viewer': ['CanViewCalendar', 'CanViewProducts'], + 'Worker': ['CanManageJobs', 'CanViewCalendar', 'CanViewProducts'], + 'Accountant': ['CanManageInvoices', 'CanViewReports', 'CanManageVendors', 'CanManageBills', 'CanManageAccounting'], + 'Manager': ['CanManageJobs', 'CanManageInventory', 'CanManageCustomers', 'CanCreateQuotes', 'CanApproveQuotes', + 'CanManageCalendar', 'CanViewCalendar', 'CanManageProducts', 'CanViewProducts', + 'CanManageEquipment', 'CanManageVendors', 'CanManageMaintenance', 'CanManageInvoices', + 'CanViewReports', 'CanManageBills'] + }; - function updatePermissionState() { + // On page load: only lock CompanyAdmin; preserve saved permission values for other roles. + function initPermissionLock() { + if (isSuperAdmin) return; + const isCompanyAdmin = roleSelect.value === 'CompanyAdmin'; + adminAlert.style.display = isCompanyAdmin ? 'block' : 'none'; + if (isCompanyAdmin) { + permissionCheckboxes.forEach(cb => { cb.checked = true; cb.disabled = true; }); + } + } + + // On role change: apply role defaults so the admin gets a sensible starting point. + function applyRoleDefaults() { const role = roleSelect.value; const isCompanyAdmin = role === 'CompanyAdmin'; - const isAccountant = role === 'Accountant'; - - if (isSuperAdmin) { - adminAlert.style.display = 'none'; - permissionCheckboxes.forEach(checkbox => { checkbox.disabled = false; }); - return; - } - adminAlert.style.display = isCompanyAdmin ? 'block' : 'none'; - + const defaults = roleDefaults[role] || []; permissionCheckboxes.forEach(checkbox => { if (isCompanyAdmin) { checkbox.checked = true; checkbox.disabled = true; } else { checkbox.disabled = false; - if (isAccountant) { - checkbox.checked = accountantDefaults.includes(checkbox.id); - } + checkbox.checked = defaults.includes(checkbox.id); } }); } - // Run on page load - updatePermissionState(); - - // Run when role changes - roleSelect.addEventListener('change', updatePermissionState); + initPermissionLock(); + roleSelect.addEventListener('change', applyRoleDefaults); }); }