HU a datatables-hez
This commit is contained in:
@@ -38,7 +38,10 @@ namespace WorkFlowCheck.BL.Services
|
||||
|
||||
try
|
||||
{
|
||||
var user = await _dbContext.Users.Where(w => w.Id == Id).FirstOrDefaultAsync();
|
||||
var user = await _dbContext.Users
|
||||
.Include(i => i.UserRoles)
|
||||
.ThenInclude(i => i.Role)
|
||||
.Where(w => w.Id == Id).FirstOrDefaultAsync();
|
||||
if (user != null)
|
||||
{
|
||||
retVal = _mapper.Map<UserDTO>(user);
|
||||
|
||||
@@ -32,10 +32,12 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div class="card shadow p-4">
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-primary float-right">Új elem hozzáadása</button>
|
||||
<button 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>
|
||||
<table id="tbCheckPointsEditPage" class="table table-bordered table-hover table-sm" style="width:100%">
|
||||
<thead class="table-primary">
|
||||
@@ -89,7 +91,8 @@
|
||||
}
|
||||
],
|
||||
|
||||
processing:true
|
||||
processing:true,
|
||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||
});
|
||||
|
||||
$('#tbCheckPointsEditPage').on('click', '.edit-btn', function ()
|
||||
|
||||
@@ -59,7 +59,8 @@
|
||||
}
|
||||
],
|
||||
|
||||
processing:true
|
||||
processing:true,
|
||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||
});
|
||||
|
||||
$('#tbCheckPointsPage').on('click', '.edit-btn', function ()
|
||||
|
||||
@@ -54,7 +54,8 @@
|
||||
}
|
||||
],
|
||||
|
||||
processing:true
|
||||
processing:true,
|
||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||
});
|
||||
|
||||
$('#tbEquipmentsPage').on('click', '.edit-btn', function ()
|
||||
|
||||
@@ -54,7 +54,8 @@
|
||||
}
|
||||
],
|
||||
|
||||
processing:true
|
||||
processing:true,
|
||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||
});
|
||||
|
||||
$('#tbLocationsPage').on('click', '.edit-btn', function ()
|
||||
|
||||
@@ -56,7 +56,8 @@
|
||||
}
|
||||
],
|
||||
|
||||
processing:true
|
||||
processing:true,
|
||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||
});
|
||||
|
||||
$('#newRoleBtn').on('click', function ()
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
@{
|
||||
ViewData["Title"] = "Ellenőrzési pont";
|
||||
var UserId = Model.UserDTO.Id;
|
||||
var url = Url.Page("./UserEditPage", "LoadRoles", new { id = UserId });
|
||||
var urlPost = Url.Page("./UserEditPage", "Save");
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<input type="hidden" id="UserEditUrl" value="@url" />
|
||||
<input type="hidden" id="UserEditPostUrl" value="@urlPost" />
|
||||
|
||||
<div class="card shadow p-4">
|
||||
@@ -52,10 +54,49 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<br></br>
|
||||
<div class="card shadow p-4">
|
||||
<table id="tbUserPage" class="table table-bordered table-hover table-sm" style="width:100%">
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Role Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot class="table-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Role Name</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
@section Scripts {
|
||||
<script>
|
||||
|
||||
console.log($('#UserEditUrl').val());
|
||||
|
||||
const table = new DataTable('#tbUserPage', {
|
||||
ajax: {
|
||||
url: $('#UserEditUrl').val(),
|
||||
type: "GET",
|
||||
dataSrc : "data"
|
||||
},
|
||||
columns: [
|
||||
{ data: "id" },
|
||||
{ data: "roleName" }
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
"targets": 0,
|
||||
"visible": false
|
||||
}
|
||||
],
|
||||
|
||||
processing:true,
|
||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||
});
|
||||
|
||||
$("#saveUser").click(function () {
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||
var formData = getFormAsNestedObject('#UserForm');
|
||||
@@ -98,7 +139,7 @@
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
const $form = $("#userForm");
|
||||
const $form = $("#UserForm");
|
||||
|
||||
$form.validate({
|
||||
errorClass: "text-danger small",
|
||||
|
||||
@@ -46,5 +46,10 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole
|
||||
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
public async Task<JsonResult> OnGetLoadRoles(int id)
|
||||
{
|
||||
UserDTO = await _userService.GetUser(id);
|
||||
return new JsonResult(new { data = UserDTO.RoleDTO });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
<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>
|
||||
<button id="newUserBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új felhasználó">
|
||||
<i class="bi bi-plus-square"></i>
|
||||
</button>
|
||||
</div>
|
||||
<table id="tbUsersPage" class="table table-bordered table-hover table-sm" style="width:100%">
|
||||
<thead class="table-primary">
|
||||
@@ -63,7 +65,8 @@
|
||||
}
|
||||
],
|
||||
|
||||
processing:true
|
||||
processing:true,
|
||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||
});
|
||||
|
||||
$('#newUserBtn').on('click', function ()
|
||||
|
||||
@@ -59,7 +59,8 @@
|
||||
}
|
||||
],
|
||||
|
||||
processing:true
|
||||
processing:true,
|
||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||
});
|
||||
|
||||
$('#newUserRoleBtn').on('click', function ()
|
||||
|
||||
Reference in New Issue
Block a user