Jó kis javítás, fejlesztés TESZT-hez

This commit is contained in:
2025-03-31 19:31:22 +02:00
parent a7e913b3ee
commit 61dd5bc9a1
18 changed files with 299 additions and 88 deletions
@@ -4,7 +4,7 @@
@inject IAntiforgery Antiforgery
@{
ViewData["Title"] = "Ellenőrzési pont";
var checkpointId = Model.CheckPoint.Id;
var checkpointId = Model.CheckPointDTO.Id;
var url = Url.Page("./CheckPointEditPage", "LoadCheckListTemplateRows", new { id = checkpointId });
var urlPost = Url.Page("./CheckPointEditPage", "Save");
}
@@ -16,21 +16,21 @@
<div class="card shadow p-4">
<form method="post" id="checkPointForm">
<meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" />
<input type="hidden" asp-for="CheckPoint.Id" />
<input type="hidden" asp-for="CheckPointDTO.Id" />
<div class="mb-3">
<label asp-for="CheckPoint.ShortName"></label>
<input asp-for="CheckPoint.ShortName" class="form-control" />
<span asp-validation-for="CheckPoint.ShortName" class="text-danger"></span>
<label asp-for="CheckPointDTO.ShortName"></label>
<input asp-for="CheckPointDTO.ShortName" class="form-control" />
<span asp-validation-for="CheckPointDTO.ShortName" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="CheckPoint.Code"></label>
<input asp-for="CheckPoint.Code" class="form-control" />
<span asp-validation-for="CheckPoint.Code" class="text-danger"></span>
<label asp-for="CheckPointDTO.Code"></label>
<input asp-for="CheckPointDTO.Code" class="form-control" />
<span asp-validation-for="CheckPointDTO.Code" class="text-danger"></span>
</div>
<div class="col-md-3">
<label asp-for="CheckPoint.IsEnabled"></label>
<input type="checkbox" asp-for="CheckPoint.IsEnabled" class="form-check-input" />
<span asp-validation-for="CheckPoint.IsEnabled" class="text-danger"></span>
<label asp-for="CheckPointDTO.IsEnabled"></label>
<input type="checkbox" asp-for="CheckPointDTO.IsEnabled" class="form-check-input" />
<span asp-validation-for="CheckPointDTO.IsEnabled" class="text-danger"></span>
</div>
<div class="mb-3">
<button type="button" id="saveCheckPoint" class="btn btn-primary">Mentés</button>
@@ -66,27 +66,7 @@
</tfoot>
</table>
</div>
<style>
.box {
display: inline-block;
width: 25px;
height: 25px;
margin: 1px;
text-align: center;
line-height: 25px;
font-size: 15px;
border: 1px solid black;
border-radius: 3px;
}
.yellow-box {
background-color: yellow;
}
.red-box {
background-color: red;
}
</style>
@section Scripts {
<script>
@@ -101,28 +81,12 @@
{ data: "rowIndex" },
{ data: "operationDescription" },
{
data: "answerType",
searchable: false,
sortable: false,
render: function ( data, type, row ) {
if (data === 'SI-N') {
return '<div class="text-center"><div class="box yellow-box">I</div><div class="box">N</div></div>';
}
if (data === 'I-SN') {
return '<div class="text-center"><div class="box">I</div><div class="box yellow-box">N</div></div>';
}
if (data === 'PI-N') {
return '<div class="text-center"><div class="box red-box">I</div><div class="box">N</div></div>';
}
if (data === 'I-PN') {
return '<div class="text-center"><div class="box">I</div><div class="box red-box">N</div></div>';
}
if (data==='P'){
return '<div class="text-center"><i class="fas fa-camera fa-2x"></i></div>';
}
return data;
}
data: "answerType",
searchable: false,
sortable: false,
render: function ( data, type, row ) {
return renderAnswerType(data);
}
},
{ data: null, render: function (data, type, row) {
return renderActionButtons(row.id);
@@ -169,6 +133,9 @@
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
var formData = getFormAsNestedObject('#checkPointForm');
formData.CheckPointDTO.CheckListTemplateRowDTO = [];
formData.CheckPointDTO.IsEnabled = $('#CheckPointDTO_IsEnabled').is(':checked');
$.ajax({
url: $('#checkPointEditPostUrl').val(),
type: 'POST',
@@ -176,13 +143,24 @@
'X-CSRF-TOKEN': csrfToken,
'Content-Type': 'application/json'
},
data: JSON.stringify(formData.CheckPoint),
data: JSON.stringify(formData.CheckPointDTO),
success: function (response) {
showMessageModal({
title: 'Figyelmem!',
message: 'Sikeres mentés.',
okText: 'Értettem'
});
if (response.success)
{
showMessageModal({
title: 'Figyelmem!',
message: 'Sikeres mentés.',
okText: 'Értettem'
});
}
else
{
showMessageModal({
title: 'Figyelmem, HIBA!',
message: 'Sikertelen mentés.',
okText: 'Értettem'
});
}
},
error: function (xhr, status, error) {
// Hiba esetén
@@ -15,7 +15,7 @@ namespace WorkFlowCheck.Web.Pages.BaseStock.CheckPoints
private readonly IBaseStockService _baseStockService;
[BindProperty]
public CheckPointDTO CheckPoint { get; set; }
public CheckPointDTO CheckPointDTO { get; set; }
public CheckPointEditPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService)
{
@@ -24,13 +24,13 @@ namespace WorkFlowCheck.Web.Pages.BaseStock.CheckPoints
}
public async Task OnGet(int id)
{
CheckPoint = await _baseStockService.GetCheckPoint(id);
CheckPointDTO = await _baseStockService.GetCheckPoint(id);
}
public async Task<JsonResult> OnGetLoadCheckListTemplateRows(int id)
{
CheckPoint = await _baseStockService.GetCheckPoint(id);
return new JsonResult(new { data = CheckPoint.CheckListTemplateRowDTO });
CheckPointDTO = await _baseStockService.GetCheckPoint(id);
return new JsonResult(new { data = CheckPointDTO.CheckListTemplateRowDTO });
}
public async Task<IActionResult> OnPostSave([FromBody] CheckPointDTO checkPointDTO)
@@ -9,7 +9,7 @@
<div class="card shadow p-4">
<div class="d-flex justify-content-end">
<button class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új elem hozzáadása">
<button id="newCheckPointBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új elem hozzáadása">
<i class="bi bi-plus-square"></i>
</button>
</div>
@@ -75,7 +75,13 @@
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#newCheckPointBtn').on('click', function ()
{
console.log('New button clicked!"');
window.location.href = `@Url.Page("./CheckPointEditPage")?id=0`;
});
$('#tbCheckPointsPage').on('click', '.edit-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
@@ -22,6 +22,23 @@
<input asp-for="CheckListTemplateHeaderDTO.ShortName" class="form-control" />
<span asp-validation-for="CheckListTemplateHeaderDTO.ShortName" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="CheckListTemplateHeaderDTO.Description" class="form-label"></label>
<textarea asp-for="CheckListTemplateHeaderDTO.Description" class="form-control" rows="3"></textarea>
<span asp-validation-for="CheckListTemplateHeaderDTO.Description" class="text-danger"></span>
</div>
<div class="mb-3 row">
<div class="col-md-6">
<label asp-for="CheckListTemplateHeaderDTO.NumberGenerator1Id"></label>
<select asp-for="CheckListTemplateHeaderDTO.NumberGenerator1Id" class="form-control" asp-items="Model.Numbergenerators"></select>
<span asp-validation-for="CheckListTemplateHeaderDTO.NumberGenerator1Id" class="text-danger"></span>
</div>
<div class="col-md-6">
<label asp-for="CheckListTemplateHeaderDTO.NumberGenerator2Id"></label>
<select asp-for="CheckListTemplateHeaderDTO.NumberGenerator2Id" class="form-control" asp-items="Model.Numbergenerators"></select>
<span asp-validation-for="CheckListTemplateHeaderDTO.NumberGenerator2" class="text-danger"></span>
</div>
</div>
<div class="mb-3 d-flex justify-content-between">
<button type="button" id="saveCheckListTemplateHeader" class="btn btn-primary">Mentés</button>
<button type="button" class="btn btn-secondary" onclick="history.back()">Mégsem</button>
@@ -71,7 +88,14 @@
{ data: "rowIndex" },
{ data: "checkPointDTO.shortName" },
{ data: "operationDescription" },
{ data: "answerType" },
{
data: "answerType",
searchable: false,
sortable: false,
render: function ( data, type, row ) {
return renderAnswerType(data);
}
},
{ data: null, render: function (data, type, row) {
return renderActionButtons(row.id);
}}
@@ -124,8 +148,10 @@
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
var formData = getFormAsNestedObject('#CheckListTemplateHeaderForm');
const $form = $('#CheckListTemplateHeaderForm');
formData.CheckListTemplateHeaderDTO.CheckListTemplateRowDTO=[];
formData.CheckListTemplateHeader.RoleDTO=[];
console.log(formData.CheckListTemplateHeaderDTO);
if ($form.valid())
{
@@ -136,13 +162,24 @@
'X-CSRF-TOKEN': csrfToken,
'Content-Type': 'application/json'
},
data: JSON.stringify(formData.CheckListTemplateHeader),
data: JSON.stringify(formData.CheckListTemplateHeaderDTO),
success: function (response) {
showMessageModal({
title: 'Figyelmem!',
message: 'Sikeres mentés.',
okText: 'Értettem'
});
if (response.success)
{
showMessageModal({
title: 'Figyelmem!',
message: 'Sikeres mentés.',
okText: 'Értettem'
});
}
else
{
showMessageModal({
title: 'Figyelmem, HIBA!',
message: 'Sikertelen mentés.',
okText: 'Értettem'
});
}
},
error: function (xhr, status, error) {
// Hiba esetén
@@ -1,6 +1,9 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Serilog;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services;
using WorkFlowCheck.Web.Services.Interfaces;
namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
@@ -9,18 +12,23 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
{
private readonly ILogger<IndexModel> _logger;
private readonly ICheckListService _checkListService;
private readonly IBaseStockService _baseStockService;
[BindProperty]
public CheckListTemplateHeaderDTO CheckListTemplateHeaderDTO { get; set; }
[BindProperty]
public List<SelectListItem> Numbergenerators { get; set; }
public CheckListTemplateHeaderEditPageModel(ILogger<IndexModel> logger, ICheckListService checkListService)
public CheckListTemplateHeaderEditPageModel(ILogger<IndexModel> logger, ICheckListService checkListService, IBaseStockService baseStockService)
{
_logger = logger;
_checkListService = checkListService;
_baseStockService = baseStockService;
}
public async Task OnGet(int id)
{
await InitSelectItems();
CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id);
}
public async Task<JsonResult> OnGetLoadCheckListTemplateRows(int id)
@@ -28,5 +36,40 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id);
return new JsonResult(new { data = CheckListTemplateHeaderDTO.CheckListTemplateRowDTO });
}
public async Task<IActionResult> OnPostSave([FromBody] CheckListTemplateHeaderDTO checkListTemplateHeaderDTO)
{
try
{
var result = await _checkListService.UpdateCheckListTemplateHeader(checkListTemplateHeaderDTO);
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 });
}
private async Task InitSelectItems()
{
var numbergenerators = await _baseStockService.GetNumbergenerators();
this.Numbergenerators = new List<SelectListItem>();
foreach (var numbergenerator in numbergenerators)
{
this.Numbergenerators.Add(new SelectListItem()
{
Value = numbergenerator.Id.ToString(),
Text = $"{numbergenerator.ShortName} -> [{numbergenerator.Sample}]"
});
}
}
}
}
@@ -64,7 +64,7 @@
},
data: JSON.stringify(formData.RoleCheckPointDTO),
success: function (response) {
// console.log(response);
if (response.success)
{
showMessageModal({
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Microsoft.AspNetCore.Mvc.Rendering;
using Newtonsoft.Json;
using Serilog;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services.Interfaces;
@@ -229,5 +230,27 @@ namespace WorkFlowCheck.Web.Services
}
}
public async Task<List<NumberGeneratorTemplateDTO>> GetNumbergenerators()
{
string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetAllNumbergenerators";
var retVal = new List<NumberGeneratorTemplateDTO>();
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<NumberGeneratorTemplateDTO>>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
}
}
@@ -103,7 +103,34 @@ namespace WorkFlowCheck.Web.Services
}
return retVal;
}
public async Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO) => throw new NotImplementedException();
public async Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO)
{
try
{
string endpoint = $"{_httpClient.BaseAddress}api/CheckList/UpdateCheckListTemplateHeader";
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, checkListTemplateHeaderDTO))
{
httpResponseMessage.EnsureSuccessStatusCode();
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
var response = JsonConvert.DeserializeObject<ApiResponseDTO<CheckListTemplateHeaderDTO>>(jsonString);
return response ?? new ApiResponseDTO<CheckListTemplateHeaderDTO>
{
IsSuccess = false,
};
}
}
catch (Exception ex)
{
// Hiba visszaadása
return new ApiResponseDTO<CheckListTemplateHeaderDTO>
{
IsSuccess = false
};
}
}
public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id)
{
@@ -1,4 +1,5 @@
using WorkFlowCheck.Common.DTO;
using Microsoft.AspNetCore.Mvc.Rendering;
using WorkFlowCheck.Common.DTO;
namespace WorkFlowCheck.Web.Services.Interfaces
{
@@ -17,5 +18,7 @@ namespace WorkFlowCheck.Web.Services.Interfaces
Task<LocationDTO> GetLocation(int id);
Task<List<LocationDTO>> GetAllLocations();
Task<ApiResponseDTO<LocationDTO>> UpdateLocation(LocationDTO LocationDTO);
Task<List<NumberGeneratorTemplateDTO>> GetNumbergenerators();
}
}
@@ -24,3 +24,23 @@ body {
.no-click {
pointer-events: none;
}
.box {
display: inline-block;
width: 25px;
height: 25px;
margin: 1px;
text-align: center;
line-height: 25px;
font-size: 15px;
border: 1px solid black;
border-radius: 3px;
}
.yellow-box {
background-color: yellow;
}
.red-box {
background-color: red;
}
+21
View File
@@ -171,3 +171,24 @@ function renderCheckBox(data) {
}
return data;
}
function renderAnswerType(data) {
if (data === 'SI-N') {
return '<div class="text-center"><div class="box yellow-box">I</div><div class="box">N</div></div>';
}
if (data === 'I-SN') {
return '<div class="text-center"><div class="box">I</div><div class="box yellow-box">N</div></div>';
}
if (data === 'PI-N') {
return '<div class="text-center"><div class="box red-box">I</div><div class="box">N</div></div>';
}
if (data === 'I-PN') {
return '<div class="text-center"><div class="box">I</div><div class="box red-box">N</div></div>';
}
if (data === 'P') {
return '<div class="text-center"><i class="fas fa-camera fa-2x"></i></div>';
}
if (data === 'V') {
return '<div class="text-center"><span class="border border-dark rounded p-1">0,00</span></div>';
}
return data;
}