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>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user