Initial commit

This commit is contained in:
2026-04-23 21:38:24 -04:00
commit 63e12a9636
1762 changed files with 1672620 additions and 0 deletions
@@ -0,0 +1,283 @@
@model PowderCoating.Application.DTOs.User.UpdateCompanyUserDto
@{
ViewData["Title"] = "Edit User";
ViewData["PageIcon"] = "bi-person-gear";
ViewData["PageHelpTitle"] = "Edit User";
ViewData["PageHelpContent"] = "Update this user's account details, role, and permissions. Unchecking User Active prevents the user from logging in without deleting their account or history. Changing the email here also changes their login username — notify them so they can log in with the new address.";
}
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-10">
<div class="d-flex justify-content-end mb-4">
@if (!string.IsNullOrEmpty(ViewBag.ReturnUrl))
{
<a href="@ViewBag.ReturnUrl" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-1"></i>Back
</a>
}
else
{
<a asp-action="Index" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-1"></i>Back to List
</a>
}
</div>
<div class="card shadow-sm">
<div class="card-body">
<form asp-action="Edit" method="post">
<input type="hidden" asp-for="Id" />
<partial name="_ValidationSummary" />
<div class="d-flex align-items-center gap-2 mb-3 pb-2 border-bottom">
<h5 class="card-title mb-0">Basic Information</h5>
<a tabindex="0" class="help-icon" role="button"
data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="focus"
data-bs-title="Basic Information"
data-bs-content="Email is this user's login username — changing it here means they must use the new address to log in. User Active controls whether the account can sign in; deactivating preserves all data without deleting the account. To reset a password, the user can use Forgot Password on the login page, or a SuperAdmin can set one directly.">
<i class="bi bi-question-circle"></i>
</a>
</div>
<div class="row g-3 mb-4">
<div class="col-md-6">
<label asp-for="FirstName" class="form-label">First Name *</label>
<input asp-for="FirstName" class="form-control" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="col-md-6">
<label asp-for="LastName" class="form-label">Last Name *</label>
<input asp-for="LastName" class="form-control" />
<span asp-validation-for="LastName" class="text-danger"></span>
</div>
<div class="col-md-6">
<label asp-for="Email" class="form-label">Email *</label>
<input asp-for="Email" class="form-control" type="email" />
<span asp-validation-for="Email" class="text-danger"></span>
<small class="form-text text-muted">This is also the user's login address.</small>
</div>
<div class="col-md-6">
<label asp-for="EmployeeNumber" class="form-label">Employee Number</label>
<input asp-for="EmployeeNumber" class="form-control" />
<span asp-validation-for="EmployeeNumber" class="text-danger"></span>
</div>
<div class="col-md-6">
<label asp-for="Phone" class="form-label">Phone</label>
<input asp-for="Phone" class="form-control" />
<span asp-validation-for="Phone" class="text-danger"></span>
</div>
<div class="col-md-6">
<div class="form-check form-switch mt-4">
<input asp-for="IsActive" class="form-check-input" />
<label asp-for="IsActive" class="form-check-label">User Active</label>
</div>
</div>
</div>
<div class="d-flex align-items-center gap-2 mb-3 pb-2 border-bottom">
<h5 class="card-title mb-0">Role &amp; Department</h5>
<a tabindex="0" class="help-icon" role="button"
data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="focus"
data-bs-title="Role &amp; Department"
data-bs-content="Changing the Role updates the user's base access level immediately on save. Termination Date is informational — to actually prevent login, also uncheck User Active above. Department and Position appear on the user's profile card and in the Manage Users list.">
<i class="bi bi-question-circle"></i>
</a>
</div>
<div class="row g-3 mb-4">
<div class="col-md-4">
<label asp-for="CompanyRole" class="form-label">Role *</label>
<select asp-for="CompanyRole" class="form-select">
<option value="Viewer">Viewer (Read-only)</option>
<option value="Worker">Worker</option>
<option value="Manager">Manager</option>
<option value="CompanyAdmin">Company Admin</option>
</select>
<span asp-validation-for="CompanyRole" class="text-danger"></span>
</div>
<div class="col-md-4">
<label asp-for="Department" class="form-label">Department</label>
<input asp-for="Department" class="form-control" />
<span asp-validation-for="Department" class="text-danger"></span>
</div>
<div class="col-md-4">
<label asp-for="Position" class="form-label">Position</label>
<input asp-for="Position" class="form-control" />
<span asp-validation-for="Position" class="text-danger"></span>
</div>
<div class="col-md-6">
<label asp-for="HireDate" class="form-label">Hire Date</label>
<input asp-for="HireDate" class="form-control" type="date" />
<span asp-validation-for="HireDate" class="text-danger"></span>
</div>
<div class="col-md-6">
<label asp-for="TerminationDate" class="form-label">Termination Date</label>
<input asp-for="TerminationDate" class="form-control" type="date" />
<span asp-validation-for="TerminationDate" class="text-danger"></span>
</div>
</div>
<div class="d-flex align-items-center gap-2 mb-3 pb-2 border-bottom">
<h5 class="card-title mb-0">Permissions</h5>
<a tabindex="0" class="help-icon" role="button"
data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="focus"
data-bs-title="Permissions"
data-bs-content="Fine-grained permissions let you grant specific capabilities beyond what the Role provides. Company Admin automatically receives all permissions and the checkboxes will be locked. SuperAdmins can override individual permissions regardless of role. Changes take effect immediately on save.">
<i class="bi bi-question-circle"></i>
</a>
</div>
<div id="companyAdminAlert" class="alert alert-info" style="display: none;">
<i class="bi bi-info-circle me-2"></i>
<strong>Company Admins automatically have all permissions.</strong> These checkboxes are disabled because Company Admins always have full access to all features.
</div>
<div class="row g-3 mb-4">
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanManageJobs" class="form-check-input permission-checkbox" />
<label asp-for="CanManageJobs" class="form-check-label">Can Manage Jobs</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanManageInventory" class="form-check-input permission-checkbox" />
<label asp-for="CanManageInventory" class="form-check-label">Can Manage Inventory</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanManageCustomers" class="form-check-input permission-checkbox" />
<label asp-for="CanManageCustomers" class="form-check-label">Can Manage Customers</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanCreateQuotes" class="form-check-input permission-checkbox" />
<label asp-for="CanCreateQuotes" class="form-check-label">Can Create Quotes</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanApproveQuotes" class="form-check-input permission-checkbox" />
<label asp-for="CanApproveQuotes" class="form-check-label">Can Approve Quotes</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanManageCalendar" class="form-check-input permission-checkbox" />
<label asp-for="CanManageCalendar" class="form-check-label">Can Manage Calendar</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanViewCalendar" class="form-check-input permission-checkbox" />
<label asp-for="CanViewCalendar" class="form-check-label">Can View Calendar</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanManageProducts" class="form-check-input permission-checkbox" />
<label asp-for="CanManageProducts" class="form-check-label">Can Manage Products</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanViewProducts" class="form-check-input permission-checkbox" />
<label asp-for="CanViewProducts" class="form-check-label">Can View Products</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanManageEquipment" class="form-check-input permission-checkbox" />
<label asp-for="CanManageEquipment" class="form-check-label">Can Manage Equipment</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanManageVendors" class="form-check-input permission-checkbox" />
<label asp-for="CanManageVendors" class="form-check-label">Can Manage Vendors</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanManageMaintenance" class="form-check-input permission-checkbox" />
<label asp-for="CanManageMaintenance" class="form-check-label">Can Manage Maintenance</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanManageInvoices" class="form-check-input permission-checkbox" />
<label asp-for="CanManageInvoices" class="form-check-label">Can Manage Invoices</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input asp-for="CanViewReports" class="form-check-input permission-checkbox" />
<label asp-for="CanViewReports" class="form-check-label">Can View Reports</label>
</div>
</div>
</div>
<div class="d-flex gap-2 justify-content-end">
@if (!string.IsNullOrEmpty(ViewBag.ReturnUrl))
{
<input type="hidden" name="returnUrl" value="@ViewBag.ReturnUrl" />
<a href="@ViewBag.ReturnUrl" class="btn btn-secondary">Cancel</a>
}
else
{
<a asp-action="Index" class="btn btn-secondary">Cancel</a>
}
<button type="submit" class="btn btn-primary">
<i class="bi bi-save me-1"></i>Save Changes
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@section Scripts {
@{
await Html.RenderPartialAsync("_ValidationScriptsPartial");
}
<script>
document.addEventListener('DOMContentLoaded', function() {
const roleSelect = document.getElementById('CompanyRole');
const permissionCheckboxes = document.querySelectorAll('.permission-checkbox');
const adminAlert = document.getElementById('companyAdminAlert');
const isSuperAdmin = @((ViewBag.IsSuperAdmin as bool? ?? false) ? "true" : "false");
function updatePermissionState() {
const isCompanyAdmin = roleSelect.value === 'CompanyAdmin';
if (isSuperAdmin) {
// SuperAdmins can always edit individual permissions
adminAlert.style.display = 'none';
permissionCheckboxes.forEach(checkbox => { checkbox.disabled = false; });
return;
}
// Show/hide alert
adminAlert.style.display = isCompanyAdmin ? 'block' : 'none';
// Check all and disable if Company Admin, otherwise enable
permissionCheckboxes.forEach(checkbox => {
if (isCompanyAdmin) {
checkbox.checked = true;
checkbox.disabled = true;
} else {
checkbox.disabled = false;
}
});
}
// Run on page load
updatePermissionState();
// Run when role changes
roleSelect.addEventListener('change', updatePermissionState);
});
</script>
}