first commit
This commit is contained in:
56
RS_system/Views/Rol/Create.cshtml
Normal file
56
RS_system/Views/Rol/Create.cshtml
Normal file
@@ -0,0 +1,56 @@
|
||||
@model Rs_system.Models.RolSistema
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Nuevo Rol";
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4 class="mb-1">Nuevo Rol</h4>
|
||||
<p class="text-muted mb-0">Crear un nuevo rol de usuario</p>
|
||||
</div>
|
||||
<a asp-action="Index" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left me-1"></i> Volver
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card-custom">
|
||||
<form asp-action="Create">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger mb-3"></div>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label asp-for="Codigo" class="form-label">Código del Rol</label>
|
||||
<input asp-for="Codigo" class="form-control" placeholder="Ej: ADMIN, OPERADOR" />
|
||||
<span asp-validation-for="Codigo" class="text-danger small"></span>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label asp-for="Nombre" class="form-label">Nombre</label>
|
||||
<input asp-for="Nombre" class="form-control" placeholder="Ej: Administrador" />
|
||||
<span asp-validation-for="Nombre" class="text-danger small"></span>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label asp-for="Descripcion" class="form-label">Descripción</label>
|
||||
<textarea asp-for="Descripcion" class="form-control" rows="3" placeholder="Describa las responsabilidades de este rol..."></textarea>
|
||||
<span asp-validation-for="Descripcion" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 text-end">
|
||||
<a asp-action="Index" class="btn btn-outline-secondary me-2">Cancelar</a>
|
||||
<button type="submit" class="btn btn-primary-custom px-4">
|
||||
<i class="bi bi-save me-2"></i> Guardar Rol
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
58
RS_system/Views/Rol/Edit.cshtml
Normal file
58
RS_system/Views/Rol/Edit.cshtml
Normal file
@@ -0,0 +1,58 @@
|
||||
@model Rs_system.Models.RolSistema
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Editar Rol";
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4 class="mb-1">Editar Rol</h4>
|
||||
<p class="text-muted mb-0">Modificar rol existente</p>
|
||||
</div>
|
||||
<a asp-action="Index" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left me-1"></i> Volver
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card-custom">
|
||||
<form asp-action="Edit">
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger mb-3"></div>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label asp-for="Codigo" class="form-label">Código del Rol</label>
|
||||
<input asp-for="Codigo" class="form-control" readonly />
|
||||
<span asp-validation-for="Codigo" class="text-danger small"></span>
|
||||
<div class="form-text">El código no se puede modificar.</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label asp-for="Nombre" class="form-label">Nombre</label>
|
||||
<input asp-for="Nombre" class="form-control" />
|
||||
<span asp-validation-for="Nombre" class="text-danger small"></span>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label asp-for="Descripcion" class="form-label">Descripción</label>
|
||||
<textarea asp-for="Descripcion" class="form-control" rows="3"></textarea>
|
||||
<span asp-validation-for="Descripcion" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 text-end">
|
||||
<a asp-action="Index" class="btn btn-outline-secondary me-2">Cancelar</a>
|
||||
<button type="submit" class="btn btn-primary-custom px-4">
|
||||
<i class="bi bi-save me-2"></i> Guardar Cambios
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
91
RS_system/Views/Rol/Index.cshtml
Normal file
91
RS_system/Views/Rol/Index.cshtml
Normal file
@@ -0,0 +1,91 @@
|
||||
@model IEnumerable<Rs_system.Models.RolSistema>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Gestión de Roles";
|
||||
}
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4 class="mb-1">Gestión de Roles</h4>
|
||||
<p class="text-muted mb-0">Administración de roles y permisos del sistema</p>
|
||||
</div>
|
||||
<a asp-action="Create" class="btn btn-primary-custom">
|
||||
<i class="bi bi-plus-lg me-1"></i> Nuevo Rol
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if (TempData["SuccessMessage"] != null)
|
||||
{
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<i class="bi bi-check-circle-fill me-2"></i> @TempData["SuccessMessage"]
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (TempData["ErrorMessage"] != null)
|
||||
{
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<i class="bi bi-exclamation-triangle-fill me-2"></i> @TempData["ErrorMessage"]
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="card-custom">
|
||||
<div class="table-responsive">
|
||||
<table class="table-custom">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Código</th>
|
||||
<th>Nombre</th>
|
||||
<th>Descripción</th>
|
||||
<th class="text-center">Permisos</th>
|
||||
<th class="text-center">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td class="font-monospace">@item.Codigo</td>
|
||||
<td class="fw-bold">@item.Nombre</td>
|
||||
<td class="text-muted small">@item.Descripcion</td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-secondary">@item.RolesPermisos.Count asignados</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a asp-action="Permissions" asp-route-id="@item.Id" class="btn btn-outline-info" title="Gestionar Permisos">
|
||||
<i class="bi bi-shield-check"></i>
|
||||
</a>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-outline-primary" title="Editar">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<button type="button" class="btn btn-outline-danger" title="Eliminar"
|
||||
onclick="confirmDelete(@item.Id, '@item.Nombre')">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="deleteForm" asp-action="Delete" method="post" style="display:none;">
|
||||
<input type="hidden" name="id" id="deleteId" />
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function confirmDelete(id, name) {
|
||||
if (confirm(`¿Está seguro de que desea eliminar el rol "${name}"?`)) {
|
||||
document.getElementById('deleteId').value = id;
|
||||
document.getElementById('deleteForm').submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
62
RS_system/Views/Rol/Permissions.cshtml
Normal file
62
RS_system/Views/Rol/Permissions.cshtml
Normal file
@@ -0,0 +1,62 @@
|
||||
@model IEnumerable<Rs_system.Models.Permiso>
|
||||
|
||||
@{
|
||||
var rol = ViewBag.Rol as Rs_system.Models.RolSistema;
|
||||
var assignedCodes = ViewBag.AssignedControllerCodes as List<string>;
|
||||
ViewData["Title"] = "Gestionar Acceso a Menú: " + rol?.Nombre;
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4 class="mb-1">Gestionar Acceso a Menú</h4>
|
||||
<p class="text-muted mb-0">Configurar permisos para: <strong>@rol?.Nombre</strong> (@rol?.Codigo)</p>
|
||||
</div>
|
||||
<a asp-action="Index" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left me-1"></i> Volver
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="card-custom">
|
||||
<p class="text-muted mb-4">Seleccione las opciones del menú que estarán disponibles para este rol.</p>
|
||||
|
||||
<form asp-action="UpdatePermissions" method="post">
|
||||
<input type="hidden" name="rolId" value="@rol?.Id" />
|
||||
|
||||
@{
|
||||
var groupedControllers = Model.GroupBy(c => c.Modulo);
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
@foreach (var group in groupedControllers)
|
||||
{
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card h-100 border-light shadow-sm">
|
||||
<div class="card-header bg-light py-2">
|
||||
<h6 class="mb-0 fw-bold text-primary">@group.Key</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@foreach (var controller in group)
|
||||
{
|
||||
<div class="form-check mb-2">
|
||||
<input class="form-check-input" type="checkbox" name="selectedControllers"
|
||||
value="@controller.Codigo" id="ctrl_@controller.Codigo"
|
||||
@(assignedCodes != null && assignedCodes.Contains(controller.Codigo) ? "checked" : "")>
|
||||
<label class="form-check-label" for="ctrl_@controller.Codigo">
|
||||
<span class="fw-semibold">@controller.Nombre</span>
|
||||
</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="mt-4 text-end border-top pt-3">
|
||||
<a asp-action="Index" class="btn btn-outline-secondary me-2">Cancelar</a>
|
||||
<button type="submit" class="btn btn-primary-custom px-5">
|
||||
<i class="bi bi-check-all me-2"></i> Guardar Configuración
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user