messageModal,confirmModal stb beállítva és működik is.
This commit is contained in:
@@ -101,7 +101,16 @@
|
|||||||
$('#tbCheckPointsEditPage').on('click', '.delete-btn', function ()
|
$('#tbCheckPointsEditPage').on('click', '.delete-btn', function ()
|
||||||
{
|
{
|
||||||
const row = table.row($(this).closest('tr')).data();
|
const row = table.row($(this).closest('tr')).data();
|
||||||
|
showConfirmModal({
|
||||||
|
title: 'Törlés megerősítése',
|
||||||
|
message: 'Biztosan törölni szeretnéd ezt az elemet?',
|
||||||
|
okText: 'Törlés',
|
||||||
|
cancelText: 'Mégsem'
|
||||||
|
}).then(function(result) {
|
||||||
|
if(result === 'ok') {
|
||||||
|
console.log('Törlés végrehajtva');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
$("#saveCheckPoint").click(function () {
|
$("#saveCheckPoint").click(function () {
|
||||||
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||||
@@ -116,14 +125,20 @@
|
|||||||
},
|
},
|
||||||
data: JSON.stringify(formData.CheckPoint),
|
data: JSON.stringify(formData.CheckPoint),
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
// Sikeres válasz esetén
|
showMessageModal({
|
||||||
alert("Sikeres mentés!");
|
title: 'Figyelmem!',
|
||||||
// opcionálisan pl. form reset, redirect stb.
|
message: 'Sikeres mentés.',
|
||||||
|
okText: 'Értettem'
|
||||||
|
});
|
||||||
},
|
},
|
||||||
error: function (xhr, status, error) {
|
error: function (xhr, status, error) {
|
||||||
// Hiba esetén
|
// Hiba esetén
|
||||||
console.error("Hiba: ", error);
|
console.error("Hiba: ", error);
|
||||||
alert("Mentés nem sikerült.");
|
showMessageModal({
|
||||||
|
title: 'Hiba!',
|
||||||
|
message: 'A mentés NEM sikerült!',
|
||||||
|
okText: 'Értettem'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,17 @@
|
|||||||
$('#tbCheckPointsPage').on('click', '.delete-btn', function ()
|
$('#tbCheckPointsPage').on('click', '.delete-btn', function ()
|
||||||
{
|
{
|
||||||
const row = table.row($(this).closest('tr')).data();
|
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?',
|
||||||
|
okText: 'Törlés',
|
||||||
|
cancelText: 'Mégsem'
|
||||||
|
}).then(function(result) {
|
||||||
|
if(result === 'ok') {
|
||||||
|
console.log('Törlés végrehajtva');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
@@ -71,6 +71,43 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Confirm Modal -->
|
||||||
|
<div class="modal fade" id="confirmModal" tabindex="-1" aria-labelledby="confirmModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="confirmModalLabel">Megerősítés</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Bezárás"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="confirmModalBody">
|
||||||
|
Biztos vagy benne?
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" id="confirmModalCancelBtn" data-bs-dismiss="modal">Mégsem</button>
|
||||||
|
<button type="button" class="btn btn-primary" id="confirmModalOkBtn">Igen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Message Modal -->
|
||||||
|
<div class="modal fade" id="messageModal" tabindex="-1" aria-labelledby="messageModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="messageModalLabel">Üzenet</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Bezárás"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="messageModalBody">
|
||||||
|
Ez egy információs üzenet.
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" id="messageModalOkBtn" data-bs-dismiss="modal">OK</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<footer class="border-top footer text-muted">
|
<footer class="border-top footer text-muted">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
© @DateTime.Now.Year - Workflow Check App - <a asp-area="" asp-page="/Privacy">Privacy</a>
|
© @DateTime.Now.Year - Workflow Check App - <a asp-area="" asp-page="/Privacy">Privacy</a>
|
||||||
|
|||||||
@@ -29,3 +29,68 @@ function getFormAsNestedObject(formSelector) {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showConfirmModal(options) {
|
||||||
|
return new Promise(function (resolve) {
|
||||||
|
// Alapértelmezett értékek
|
||||||
|
var defaults = {
|
||||||
|
title: 'Megerősítés',
|
||||||
|
message: 'Biztos vagy benne?',
|
||||||
|
okText: 'Igen',
|
||||||
|
cancelText: 'Mégsem'
|
||||||
|
};
|
||||||
|
|
||||||
|
// Opciók összeolvasztása
|
||||||
|
var settings = $.extend({}, defaults, options);
|
||||||
|
|
||||||
|
// Beállítások betöltése a modalba
|
||||||
|
$('#confirmModalLabel').text(settings.title);
|
||||||
|
$('#confirmModalBody').html(settings.message);
|
||||||
|
$('#confirmModalOkBtn').text(settings.okText);
|
||||||
|
$('#confirmModalCancelBtn').text(settings.cancelText);
|
||||||
|
|
||||||
|
// Események letisztítása
|
||||||
|
$('#confirmModalOkBtn').off('click');
|
||||||
|
$('#confirmModalCancelBtn').off('click');
|
||||||
|
|
||||||
|
// OK gomb esemény
|
||||||
|
$('#confirmModalOkBtn').on('click', function () {
|
||||||
|
$('#confirmModal').modal('hide');
|
||||||
|
resolve('ok');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Cancel gomb esemény
|
||||||
|
$('#confirmModalCancelBtn').on('click', function () {
|
||||||
|
resolve('cancel');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Modal megjelenítése
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('confirmModal'), {
|
||||||
|
backdrop: 'static',
|
||||||
|
keyboard: false
|
||||||
|
});
|
||||||
|
modal.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function showMessageModal(options) {
|
||||||
|
// Alapértelmezett értékek
|
||||||
|
var defaults = {
|
||||||
|
title: 'Üzenet',
|
||||||
|
message: 'Ez egy információs üzenet.',
|
||||||
|
okText: 'OK'
|
||||||
|
};
|
||||||
|
|
||||||
|
var settings = $.extend({}, defaults, options);
|
||||||
|
|
||||||
|
// Tartalom beállítása
|
||||||
|
$('#messageModalLabel').text(settings.title);
|
||||||
|
$('#messageModalBody').html(settings.message);
|
||||||
|
$('#messageModalOkBtn').text(settings.okText);
|
||||||
|
|
||||||
|
// Modal megnyitása
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('messageModal'), {
|
||||||
|
backdrop: 'static',
|
||||||
|
keyboard: false
|
||||||
|
});
|
||||||
|
modal.show();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user