67 lines
2.3 KiB
Plaintext
67 lines
2.3 KiB
Plaintext
@page
|
|
@model WorkFlowCheck.Web.Pages.BaseStock.Locations.LocationEditPageModel
|
|
@using Microsoft.AspNetCore.Antiforgery
|
|
@inject IAntiforgery Antiforgery
|
|
@{
|
|
ViewData["Title"] = "Lokáció";
|
|
var LocationId = Model.LocationDTO.Id;
|
|
var urlPost = Url.Page("./LocationEditPage", "Save");
|
|
}
|
|
<h1>@ViewData["Title"]</h1>
|
|
|
|
<input type="hidden" id="LocationEditPostUrl" value="@urlPost" />
|
|
|
|
<div class="card shadow p-4">
|
|
<form method="post" id="LocationForm">
|
|
<meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" />
|
|
<input type="hidden" asp-for="LocationDTO.Id" />
|
|
<div class="mb-3">
|
|
<label asp-for="LocationDTO.FullName"></label>
|
|
<input asp-for="LocationDTO.FullName" class="form-control" />
|
|
<span asp-validation-for="LocationDTO.FullName" class="text-danger"></span>
|
|
</div>
|
|
<hr class="mt-4 mb-3 border-secondary">
|
|
<div class="mb-3 d-flex justify-content-between">
|
|
<button type="button" id="saveLocation" 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>
|
|
|
|
$("#saveLocation").click(function () {
|
|
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
|
var formData = getFormAsNestedObject('#LocationForm');
|
|
const $form = $('#LocationForm');
|
|
|
|
if ($form.valid())
|
|
{
|
|
saveEntity(csrfToken, formData.LocationDTO, $('#LocationEditPostUrl').val());
|
|
} else
|
|
{
|
|
$form[0].reportValidity();
|
|
}
|
|
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
const $form = $("#LocationForm");
|
|
|
|
$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>
|
|
}
|