User továbbgondolása

This commit is contained in:
2025-03-17 12:10:41 +01:00
parent 0e06382eee
commit 8c1e60889d
11 changed files with 306 additions and 44 deletions
@@ -1,4 +1,99 @@
@page
@model WorkFlowCheck.Web.Pages.UserAndRole.UserPageModel
@{
ViewData["Title"] = "Felhasználók";
}
<h1>@ViewData["Title"]</h1>
<div class="card shadow p-4">
<div class="d-flex justify-content-end">
<button id="newUserBtn" class="btn btn-primary float-right new-btn">Új elem hozzáadása</button>
</div>
<table id="tbUsersPage" class="table table-bordered table-hover table-sm" style="width:100%">
<thead class="table-primary">
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>User Name</th>
<th>E-mail</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tfoot class="table-light">
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>User Name</th>
<th>E-mail</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
@section Scripts {
<script>
const table = new DataTable('#tbUsersPage', {
ajax: {
url: "@Url.Page("./UserPage", "LoadUsers")",
type: "GET",
dataSrc : "data"
},
columns: [
{ data: "id" },
{ data: "firstName" },
{ data: "lastName" },
{ data: "userName" },
{ data: "email" },
{ data: null, render: function (data, type, row) {
return `<button class="btn btn-primary edit-btn" data-id="${row.id}">Módosítás</button>
<button class="btn btn-danger delete-btn" data-id="${row.id}">Törlés</button>
`;
}}
],
columnDefs: [
{
"targets": 0,
"visible": false
},
{
"targets": 5,
"className": "text-center",
"width": "15%"
}
],
processing:true
});
$('#newUserBtn').on('click', function ()
{
console.log('New button clicked!"');
window.location.href = `@Url.Page("./UserEditPage")?id=0`;
});
$('#tbUsersPage').on('click', '.edit-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
window.location.href = `@Url.Page("./UserEditPage")?id=${row.id}`;
});
$('#tbUsersPage').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?',
okText: 'Törlés',
cancelText: 'Mégsem'
}).then(function(result) {
if(result === 'ok') {
console.log('Törlés végrehajtva');
}
});
});
</script>
}