CheckListTemplateHeader klónozása

This commit is contained in:
2025-05-07 13:05:28 +02:00
parent 9ffbcd87f2
commit 272bd1a3fd
9 changed files with 160 additions and 7 deletions
@@ -301,6 +301,28 @@ namespace WorkFlowCheck.API.Controllers
return retVal; return retVal;
} }
[HttpGet("CloneCheckListTemplateHeader/{id}")]
public async Task<ApiResponseDTO<bool>> CloneCheckListTemplateHeader(int id)
{
var retVal = new ApiResponseDTO<bool>()
{
IsSuccess = true,
};
var result = await _checkListService.CloneCheckListTemplateHeaderAsync(id);
if (result != null)
{
retVal.IsSuccess = true;
retVal.Data = result;
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
return retVal;
}
[HttpGet("GetCheckListTemplateRow/{id}")] [HttpGet("GetCheckListTemplateRow/{id}")]
public async Task<ApiResponseDTO<CheckListTemplateRowDTO>> GetCheckListTemplateRow(int id) public async Task<ApiResponseDTO<CheckListTemplateRowDTO>> GetCheckListTemplateRow(int id)
@@ -493,6 +493,52 @@ namespace WorkFlowCheck.BL.Services
{ {
return await DeleteEntityByIdAsync<CheckListTemplateHeader>(id); return await DeleteEntityByIdAsync<CheckListTemplateHeader>(id);
} }
public async Task<bool> CloneCheckListTemplateHeaderAsync(int id)
{
var retVal = false;
try
{
var checkListTemplateHeader = await _dbContext.CheckListTemplateHeaders
.Include(i => i.CheckListTemplateRows)
.Where(w => w.Id == id).FirstOrDefaultAsync();
if (checkListTemplateHeader != null)
{
var newCheckListTemplateHeader = new CheckListTemplateHeader()
{
CheckListTemplateRows = new List<CheckListTemplateRow>(),
Description = checkListTemplateHeader.Description,
IsDeleted = false,
NumberGenerator1Id = checkListTemplateHeader.NumberGenerator1Id,
NumberGenerator2Id = checkListTemplateHeader.NumberGenerator2Id,
ShortName = $"{checkListTemplateHeader.ShortName} (másolat)",
};
foreach (var checkListTemplateRow in checkListTemplateHeader.CheckListTemplateRows)
{
var newCheckListTemplateRow = new CheckListTemplateRow()
{
AnswerType = checkListTemplateRow.AnswerType,
CheckListTemplateHeader = newCheckListTemplateHeader,
CheckPointId = checkListTemplateRow.CheckPointId,
EquipmentId = checkListTemplateRow.EquipmentId,
IsDeleted = false,
OperationDescription = checkListTemplateRow.OperationDescription,
RowIndex = checkListTemplateRow.RowIndex,
};
newCheckListTemplateHeader.CheckListTemplateRows.Add(newCheckListTemplateRow);
}
_dbContext.CheckListTemplateHeaders.Add(newCheckListTemplateHeader);
await _dbContext.SaveChangesAsync();
}
}
catch (Exception ex)
{
retVal = false;
Log.ForContext("TAG", "BusinessFlow").Error(ex.Message);
}
return retVal;
}
public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id) public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id)
{ {
var retVal = new CheckListTemplateRowDTO(); var retVal = new CheckListTemplateRowDTO();
@@ -20,6 +20,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync(); Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
Task<CheckListTemplateHeaderDTO> UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO); Task<CheckListTemplateHeaderDTO> UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
Task<bool> DeleteCheckListTemplateHeaderAsync(int id); Task<bool> DeleteCheckListTemplateHeaderAsync(int id);
Task<bool> CloneCheckListTemplateHeaderAsync(int id);
Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id); Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id);
Task<bool> DeleteCheckListTemplateRowAsync(int id); Task<bool> DeleteCheckListTemplateRowAsync(int id);
Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO); Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO);
@@ -7,7 +7,7 @@ namespace WorkFlowCheck.Web.Helpers
public static class SystemHelper public static class SystemHelper
{ {
public static string DatabaseName = ""; public static string DatabaseName = "";
public static string ProgramVersion = "v1.1.019"; public static string ProgramVersion = "v1.1.021";
public async static Task GetAPIInfoAsync(IConfiguration configuration) public async static Task GetAPIInfoAsync(IConfiguration configuration)
{ {
@@ -47,7 +47,7 @@
{ data: "shortName" }, { data: "shortName" },
{ data: "description" }, { data: "description" },
{ data: null, render: function (data, type, row) { { data: null, render: function (data, type, row) {
return renderActionButtons(row.id); return renderActionButtonsforCheckListTemplateHeader(row.id);
}} }}
], ],
columnDefs: [ columnDefs: [
@@ -68,16 +68,59 @@
$('#newCheckListTemplateHeaderBtn').on('click', function () $('#newCheckListTemplateHeaderBtn').on('click', function ()
{ {
console.log('New button clicked!"');
window.location.href = `@Url.Page("./CheckListTemplateHeaderEditPage")?id=0`; window.location.href = `@Url.Page("./CheckListTemplateHeaderEditPage")?id=0`;
}); });
$('#tbCheckListTemplateHeadersPage').on('click', '.edit-btn', function () $('#tbCheckListTemplateHeadersPage').on('click', '.edit-btn', function ()
{ {
const row = table.row($(this).closest('tr')).data(); const row = table.row($(this).closest('tr')).data();
window.location.href = `@Url.Page("./CheckListTemplateHeaderEditPage")?id=${row.id}`; window.location.href = `@Url.Page("./CheckListTemplateHeaderEditPage")?id=${row.id}`;
}); });
$('#tbCheckListTemplateHeadersPage').on('click', '.clone-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
const url = './CheckListTemplateHeaderPage?handler=CloneCheckListTemplateHeader';
showConfirmModal({
title: 'Klónozás megerősítése',
message: 'Biztosan klónozni szeretnéd ezt az elemet?',
okText: 'Klónozás',
cancelText: 'Mégsem'
}).then(function (result) {
if (result === 'ok') {
$.ajax({
url: url,
type: 'GET',
data: { id: row.id },
success: function (data) {
if (data) {
showMessageModal({
title: 'Információ',
message: 'A klónozás sikerült!',
okText: 'Értettem'
});
table.ajax.reload();
} else {
showMessageModal({
title: 'Hiba!',
message: 'A klónozás NEM sikerült!',
okText: 'Értettem'
});
}
},
error: function (xhr, status, error) {
showMessageModal({
title: 'Hiba!',
message: 'A klónozás NEM sikerült!',
okText: 'Értettem'
});
}
});
}
});
});
$('#tbCheckListTemplateHeadersPage').on('click', '.delete-btn', function () $('#tbCheckListTemplateHeadersPage').on('click', '.delete-btn', function ()
{ {
const row = table.row($(this).closest('tr')).data(); const row = table.row($(this).closest('tr')).data();
@@ -27,5 +27,10 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
var isSuccess = await _checkListService.DeleteCheckListTemplateHeader(id); var isSuccess = await _checkListService.DeleteCheckListTemplateHeader(id);
return new JsonResult(new { result = isSuccess }); return new JsonResult(new { result = isSuccess });
} }
public async Task<JsonResult> OnGetCloneCheckListTemplateHeader(int id)
{
var isSuccess = await _checkListService.CloneCheckListTemplateHeader(id);
return new JsonResult(new { result = isSuccess });
}
} }
} }
@@ -264,6 +264,27 @@ namespace WorkFlowCheck.Web.Services
} }
return retVal; return retVal;
} }
public async Task<bool> CloneCheckListTemplateHeader(int id)
{
string endpoint = $"{_httpClient.BaseAddress}api/CheckList/CloneCheckListTemplateHeader/{id}";
var retVal = false;
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<bool>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id) public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id)
@@ -19,9 +19,11 @@ namespace WorkFlowCheck.Web.Services.Interfaces
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync(); Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO); Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
Task<bool> DeleteCheckListTemplateHeader(int id); Task<bool> DeleteCheckListTemplateHeader(int id);
Task<bool> CloneCheckListTemplateHeader(int id);
Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id); Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id);
Task<bool> DeleteCheckListTemplateRow(int id); Task<bool> DeleteCheckListTemplateRow(int id);
Task<ApiResponseDTO<CheckListTemplateRowDTO>> UpdateCheckListTemplateRow(CheckListTemplateRowDTO checkListTemplateRowDTO); Task<ApiResponseDTO<CheckListTemplateRowDTO>> UpdateCheckListTemplateRow(CheckListTemplateRowDTO checkListTemplateRowDTO);
+13
View File
@@ -232,6 +232,19 @@ function renderActionButtonsforCheckListHeader(data, rowId) {
//</button>`; //</button>`;
} }
function renderActionButtonsforCheckListTemplateHeader(rowId) {
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>
<button class="btn btn-primary clone-btn btn-sm" data-id="${rowId}">
<i class="bi bi bi-copy"></i>
</button>
`;
}
function renderCheckStatus(data) { function renderCheckStatus(data) {
//Open = 0, //Open = 0,