Bootstrap Icon hozzáadása
This commit is contained in:
@@ -1,4 +1,91 @@
|
||||
@page
|
||||
@model WorkFlowCheck.Web.Pages.UserAndRole.RoleEditPageModel
|
||||
@using Microsoft.AspNetCore.Antiforgery
|
||||
@inject IAntiforgery Antiforgery
|
||||
@{
|
||||
ViewData["Title"] = "Ellenőrzési pont";
|
||||
var RoleId = Model.RoleDTO.Id;
|
||||
var urlPost = Url.Page("./RoleEditPage", "Save");
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<input type="hidden" id="RoleEditPostUrl" value="@urlPost" />
|
||||
|
||||
<div class="card shadow p-4">
|
||||
<form method="post" id="RoleForm">
|
||||
<meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" />
|
||||
<input type="hidden" asp-for="RoleDTO.Id" />
|
||||
<div class="mb-3">
|
||||
<label asp-for="RoleDTO.RoleName"></label>
|
||||
<input asp-for="RoleDTO.RoleName" class="form-control" />
|
||||
<span asp-validation-for="RoleDTO.RoleName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3 d-flex justify-content-between">
|
||||
<button type="button" id="saveRole" class="btn btn-primary">Mentés</button>
|
||||
<button type="button" class="btn btn-secondary" onclick="history.back()">Mégsem</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
|
||||
$("#saveRole").click(function () {
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||
var formData = getFormAsNestedObject('#RoleForm');
|
||||
const $form = $('#RoleForm');
|
||||
|
||||
formData.RoleDTO.RoleDTO=[];
|
||||
|
||||
if ($form.valid())
|
||||
{
|
||||
$.ajax({
|
||||
url: $('#RoleEditPostUrl').val(),
|
||||
type: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': csrfToken,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify(formData.Role),
|
||||
success: function (response) {
|
||||
showMessageModal({
|
||||
title: 'Figyelmem!',
|
||||
message: 'Sikeres mentés.',
|
||||
okText: 'Értettem'
|
||||
});
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
// Hiba esetén
|
||||
console.error("Hiba: ", error);
|
||||
showMessageModal({
|
||||
title: 'Hiba!',
|
||||
message: 'A mentés NEM sikerült!',
|
||||
okText: 'Értettem'
|
||||
});
|
||||
}
|
||||
});
|
||||
} else
|
||||
{
|
||||
$form[0].reportValidity();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
const $form = $("#RoleForm");
|
||||
|
||||
$form.validate({
|
||||
errorClass: "text-danger small",
|
||||
errorPlacement: function (error, element) {
|
||||
error.appendTo(element.parent());
|
||||
}
|
||||
});
|
||||
|
||||
// $form.on("submit", function (e) {
|
||||
// if (!$form.valid()) {
|
||||
// e.preventDefault(); // Ne küldje be, ha van hiba
|
||||
// }
|
||||
// });
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
@@ -1,12 +1,49 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Serilog;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Pages.UserAndRole
|
||||
{
|
||||
public class RoleEditPageModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
[BindProperty]
|
||||
public RoleDTO RoleDTO { get; set; }
|
||||
|
||||
public RoleEditPageModel(ILogger<IndexModel> logger, IUserService userService)
|
||||
{
|
||||
_userService = userService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task OnGet(int id)
|
||||
{
|
||||
RoleDTO = await _userService.GetRole(id);
|
||||
}
|
||||
public async Task<IActionResult> OnPostSave([FromBody] RoleDTO roleDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _userService.UpdateRole(roleDTO);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return new JsonResult(new { success = true });
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
<div class="card shadow p-4">
|
||||
<div class="d-flex justify-content-end">
|
||||
<button id="newRoleBtn" class="btn btn-primary float-right new-btn">Új elem hozzáadása</button>
|
||||
<button id="newRoleBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új szabály">
|
||||
<i class="bi bi-plus-square"></i>
|
||||
</button>
|
||||
</div>
|
||||
<table id="tbRolesPage" class="table table-bordered table-hover table-sm" style="width:100%">
|
||||
<thead class="table-primary">
|
||||
@@ -39,9 +41,7 @@
|
||||
{ data: "id" },
|
||||
{ data: "roleName" },
|
||||
{ data: null, render: function (data, type, row) {
|
||||
return `<button class="btn btn-primary edit-btn" data-id="${row.id}">Módosítás</button>
|
||||
<button class="btn btn-danger delete-btn" data-id="${row.id}">Törlés</button>
|
||||
`;
|
||||
return renderActionButtons(row.id);
|
||||
}}
|
||||
],
|
||||
columnDefs: [
|
||||
@@ -52,7 +52,7 @@
|
||||
{
|
||||
"targets": 2,
|
||||
"className": "text-center",
|
||||
"width": "15%"
|
||||
"width": "10%"
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
@inject IAntiforgery Antiforgery
|
||||
@{
|
||||
ViewData["Title"] = "Ellenőrzési pont";
|
||||
var UserId = Model.User.Id;
|
||||
var UserId = Model.UserDTO.Id;
|
||||
var urlPost = Url.Page("./UserEditPage", "Save");
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@@ -14,37 +14,37 @@
|
||||
<div class="card shadow p-4">
|
||||
<form method="post" id="UserForm">
|
||||
<meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" />
|
||||
<input type="hidden" asp-for="User.Id" />
|
||||
<input type="hidden" asp-for="User.Password" value="" />
|
||||
<input type="hidden" asp-for="User.JwtToken" value="" />
|
||||
<input type="hidden" asp-for="User.RoleDTO" value="" />
|
||||
<input type="hidden" asp-for="UserDTO.Id" />
|
||||
<input type="hidden" asp-for="UserDTO.Password" value="" />
|
||||
<input type="hidden" asp-for="UserDTO.JwtToken" value="" />
|
||||
<input type="hidden" asp-for="UserDTO.RoleDTO" value="" />
|
||||
<div class="mb-3">
|
||||
<label asp-for="User.UserName"></label>
|
||||
<input asp-for="User.UserName" class="form-control" />
|
||||
<span asp-validation-for="User.UserName" class="text-danger"></span>
|
||||
<label asp-for="UserDTO.UserName"></label>
|
||||
<input asp-for="UserDTO.UserName" class="form-control" />
|
||||
<span asp-validation-for="UserDTO.UserName" class="text-danger"></span>
|
||||
</div>
|
||||
@if (Model.User.Id == 0)
|
||||
@if (Model.UserDTO.Id == 0)
|
||||
{
|
||||
<div class="mb-3">
|
||||
<label asp-for="User.Password"></label>
|
||||
<input asp-for="User.Password" class="form-control" type="password" />
|
||||
<span asp-validation-for="User.Password" class="text-danger"></span>
|
||||
<label asp-for="UserDTO.Password"></label>
|
||||
<input asp-for="UserDTO.Password" class="form-control" type="password" />
|
||||
<span asp-validation-for="UserDTO.Password" class="text-danger"></span>
|
||||
</div>
|
||||
}
|
||||
<div class="mb-3">
|
||||
<label asp-for="User.Email"></label>
|
||||
<input asp-for="User.Email" class="form-control" />
|
||||
<span asp-validation-for="User.Email" class="text-danger"></span>
|
||||
<label asp-for="UserDTO.Email"></label>
|
||||
<input asp-for="UserDTO.Email" class="form-control" />
|
||||
<span asp-validation-for="UserDTO.Email" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label asp-for="User.FirstName"></label>
|
||||
<input asp-for="User.FirstName" class="form-control" />
|
||||
<span asp-validation-for="User.FirstName" class="text-danger"></span>
|
||||
<label asp-for="UserDTO.FirstName"></label>
|
||||
<input asp-for="UserDTO.FirstName" class="form-control" />
|
||||
<span asp-validation-for="UserDTO.FirstName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label asp-for="User.LastName"></label>
|
||||
<input asp-for="User.LastName" class="form-control" />
|
||||
<span asp-validation-for="User.LastName" class="text-danger"></span>
|
||||
<label asp-for="UserDTO.LastName"></label>
|
||||
<input asp-for="UserDTO.LastName" class="form-control" />
|
||||
<span asp-validation-for="UserDTO.LastName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3 d-flex justify-content-between">
|
||||
<button type="button" id="saveUser" class="btn btn-primary">Mentés</button>
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole
|
||||
private readonly IUserService _userService;
|
||||
|
||||
[BindProperty]
|
||||
public UserDTO User { get; set; }
|
||||
public UserDTO UserDTO { get; set; }
|
||||
|
||||
public UserEditPageModel(ILogger<IndexModel> logger, IUserService userService)
|
||||
{
|
||||
@@ -23,7 +23,7 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole
|
||||
|
||||
public async Task OnGet(int id)
|
||||
{
|
||||
User = await _userService.GetUser(id);
|
||||
UserDTO = await _userService.GetUser(id);
|
||||
}
|
||||
public async Task<IActionResult> OnPostSave([FromBody] UserDTO userDTO)
|
||||
{
|
||||
|
||||
@@ -48,9 +48,7 @@
|
||||
{ data: "userName" },
|
||||
{ data: "email" },
|
||||
{ data: null, render: function (data, type, row) {
|
||||
return `<button class="btn btn-primary edit-btn" data-id="${row.id}">Módosítás</button>
|
||||
<button class="btn btn-danger delete-btn" data-id="${row.id}">Törlés</button>
|
||||
`;
|
||||
return renderActionButtons(row.id);
|
||||
}}
|
||||
],
|
||||
columnDefs: [
|
||||
@@ -61,7 +59,7 @@
|
||||
{
|
||||
"targets": 5,
|
||||
"className": "text-center",
|
||||
"width": "15%"
|
||||
"width": "10%"
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user