Blokkolás, feloldás

This commit is contained in:
2025-04-08 14:59:35 +02:00
parent cdaceb1961
commit b5d4a163fd
22 changed files with 3576 additions and 77 deletions
@@ -1,5 +1,7 @@
@page
@model WorkFlowCheck.Web.Pages.CheckList.CheckListHeader.CheckListHeaderPageModel
@using WorkFlowCheck.Common.Helper
@using WorkFlowCheck.Common.DTO
@{
ViewData["Title"] = "Ellenőrzések";
}
@@ -15,26 +17,28 @@
<thead class="table-primary">
<tr>
<th>ID</th>
<th>Status</th>
<th>IsEditable</th>
<th>DocumentNumber</th>
<th>DateExecution</th>
<th>ShortName</th>
<th>Description</th>
<th>User</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.CheckStatus), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.IsEditable), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.DocumentNumber), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.DateExecution), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.ShortName), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.Description), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.UserId), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.AcceptUserId), typeof(CheckListHeaderDTO))</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tfoot class="table-light">
<tr>
<th>ID</th>
<th>Status</th>
<th>IsEditable</th>
<th>DocumentNumber</th>
<th>DateExecution</th>
<th>ShortName</th>
<th>Description</th>
<th>User</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.CheckStatus), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.IsEditable), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.DocumentNumber), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.DateExecution), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.ShortName), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.Description), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.UserId), typeof(CheckListHeaderDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(CheckListHeaderDTO.AcceptUserId), typeof(CheckListHeaderDTO))</th>
<th class="text-center">Action</th>
</tr>
</tfoot>
@@ -80,6 +84,7 @@
{ data: "shortName" },
{ data: "description" },
{ data: "userDTO.userName" },
{ data: "acceptUserDTO.userName" },
{ data: "checkStatus", render: function (data, type, row) {
return renderActionButtonsforCheckListHeader(data, row.id);
}}
@@ -90,7 +95,7 @@
"visible": false
},
{
"targets": 8,
"targets": 9,
"className": "text-center",
"width": "10%"
}
@@ -118,11 +123,54 @@
window.location.href = `@Url.Page("./CheckListHeaderPage")?handler=CreatePDF&id=${row.id}`;
});
$('#tbCheckListHeadersPage').on('click', '.accept-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
const url = `@Url.Page("./CheckListHeaderPage")?handler=Accept&id=${row.id}`
showConfirmModal({
title: 'Jóváhagyás megerősítése',
message: 'Biztosan jóváhagyod a folyamatot?',
okText: 'Jóváhagyás',
cancelText: 'Mégsem'
}).then(function(result){
if(result === 'ok'){
$.ajax({
url: url,
type: 'GET',
success: function(data) {
if (data) {
showMessageModal({
title: 'Információ',
message: 'A jóváhagyás sikerült!',
okText: 'Értettem'
});
table.ajax.reload();
} else {
showMessageModal({
title: 'Hiba!',
message: 'A jóváhagyás NEM sikerült!',
okText: 'Értettem'
});
}
},
error: function(xhr, status, error) {
showMessageModal({
title: 'Hiba!',
message: 'A jóváhagyás NEM sikerült!',
okText: 'Értettem'
});
}
});
}
});
});
$('#tbCheckListHeadersPage').on('click', '.delete-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
console.log(row);
showConfirmModal({
title: 'Törlés megerősítése',
message: 'Biztosan törölni szeretnéd ezt az elemet?',
@@ -5,7 +5,7 @@ using System.ComponentModel.DataAnnotations;
using System.Reflection;
using WorkFlowCheck.Common.Enums;
using WorkFlowCheck.Web.Services.Interfaces;
using System.Security.Claims;
namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
{
public class CheckListHeaderPageModel : PageModel
@@ -54,5 +54,47 @@ namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
return new JsonResult(new { success = false });
}
}
public async Task<IActionResult> OnGetAccept(int id)
{
var userid = User.FindFirstValue(ClaimTypes.NameIdentifier);
var response = await _checkListService.AcceptCheckListHeader(id, int.Parse(userid));
if (response.IsSuccess)
{
return new JsonResult(new { success = response.Data });
}
else
{
return new JsonResult(new { success = false });
}
}
public async Task<IActionResult> OnGetBlock(int id)
{
var userid = User.FindFirstValue(ClaimTypes.NameIdentifier);
var response = await _checkListService.AcceptCheckListHeader(id, int.Parse(userid));
if (response.IsSuccess)
{
return new JsonResult(new { success = response.Data });
}
else
{
return new JsonResult(new { success = false });
}
}
public async Task<IActionResult> OnGetUnBlock(int id)
{
var userid = User.FindFirstValue(ClaimTypes.NameIdentifier);
var response = await _checkListService.AcceptCheckListHeader(id, int.Parse(userid));
if (response.IsSuccess)
{
return new JsonResult(new { success = response.Data });
}
else
{
return new JsonResult(new { success = false });
}
}
}
}
@@ -60,6 +60,70 @@ namespace WorkFlowCheck.Web.Services
}
public async Task<ApiResponseDTO<CheckListHeaderDTO>> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO) => throw new NotImplementedException();
public async Task<ApiResponseDTO<bool>> AcceptCheckListHeader(int id, int userid)
{
var retVal = new ApiResponseDTO<bool>();
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/AcceptCheckListHeader/{id}/{userid}";
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<bool>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<ApiResponseDTO<bool>> BlockCheckListHeader(int id, int userid)
{
var retVal = new ApiResponseDTO<bool>();
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/BlockCheckListHeader/{id}/{userid}";
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<bool>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<ApiResponseDTO<bool>> UnBlockCheckListHeader(int id, int userid)
{
var retVal = new ApiResponseDTO<bool>();
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/UnBlockCheckListHeader/{id}/{userid}";
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<bool>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<ApiResponseDTO<byte[]>> CreatePDF(int id)
{
var retVal = new ApiResponseDTO<byte[]>();
@@ -9,17 +9,24 @@ namespace WorkFlowCheck.Web.Services.Interfaces
Task<List<CheckListHeaderDTO>> GetAllCheckListHeaderAsync();
Task<ApiResponseDTO<CheckListHeaderDTO>> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO);
Task<ApiResponseDTO<byte[]>> CreatePDF(int id);
Task<ApiResponseDTO<bool>> AcceptCheckListHeader(int id, int userid);
Task<ApiResponseDTO<bool>> BlockCheckListHeader(int id, int userid);
Task<ApiResponseDTO<bool>> UnBlockCheckListHeader(int id, int userid);
Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeader(int id);
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id);
Task<ApiResponseDTO<CheckListTemplateRowDTO>> UpdateCheckListTemplateRow(CheckListTemplateRowDTO checkListTemplateRowDTO);
Task<CheckListRowDTO> GetCheckListRow(int id);
Task<ApiResponseDTO<CheckListRowDTO>> UpdateCheckListRow(CheckListRowDTO checkListRowDTO);
List<SelectListItem> GetCheckStatus();
}
+24 -5
View File
@@ -111,20 +111,39 @@ function renderActionButtonsforCheckListHeader(data, rowId) {
<button class="btn btn-primary edit-btn btn-sm" data-id="${rowId}">
<i class="bi bi-pencil-fill"></i>
</button>
<button class="btn btn-secondary pdf-btn btn-sm" data-id="${rowId}">
<button class="btn btn-warning accept-btn btn-sm" data-id="${rowId}">
<i class="bi bi-save2"></i>
</button>
<button class="btn btn-danger pdf-btn btn-sm" data-id="${rowId}">
<i class="bi bi-file-earmark-pdf-fill"></i>
</button>`;
}
else {
if (data === 2) {
return `
<button class="btn btn-primary edit-btn btn-sm" data-id="${rowId}">
<i class="bi bi-pencil-fill"></i>
</button>
<button class="btn btn-danger delete-btn btn-sm" data-id="${rowId}">
<i class="bi bi-trash-fill"></i>
<button class="btn btn-success unblock-btn btn-sm" data-id="${rowId}">
<i class="bi bi-arrow-clockwise"></i>
</button>`;
}
if (data === 5) {
return `
<button class="btn btn-danger pdf-btn btn-sm" data-id="${rowId}">
<i class="bi bi-file-earmark-pdf-fill"></i>
</button>`;
}
if (data === 3) {
return ``;
}
return `
<button class="btn btn-primary edit-btn btn-sm" data-id="${rowId}">
<i class="bi bi-pencil-fill"></i>
</button>`;
//<button class="btn btn-danger delete-btn btn-sm" data-id="${rowId}">
// <i class="bi bi-trash-fill"></i>
//</button>`;
}
function renderCheckStatus(data) {