✨ feat(ui): Perbaikan tampilan dan fungsionalitas halaman index untuk manajemen pengguna
- Memperbaiki fungsi export data pengguna dengan format yang lebih rapi - Update semua controller (Permissions, Positions, Roles, Users) untuk konsistensi response dan error handling - Tambahan fungsi `goPage(1)` pada event listener pencarian untuk langsung ke halaman pertama saat melakukan pencarian
This commit is contained in:
@@ -276,9 +276,7 @@
|
|||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
$search = $request->get('search');
|
$search = $request->get('search');
|
||||||
$query->where(function ($q) use ($search) {
|
$query->where('name', 'like', '%' . $search . '%');
|
||||||
$q->whereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search) . '%']);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply sorting if provided
|
// Apply sorting if provided
|
||||||
@@ -303,14 +301,11 @@
|
|||||||
// Get the filtered count of records
|
// Get the filtered count of records
|
||||||
$filteredRecords = $query->count();
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
|
||||||
// Get the data for the current page
|
// Get the data for the current page
|
||||||
$permissions = $query->get();
|
$data = $query->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($permission) {
|
||||||
$permissions = $permissions->map(function ($permission) {
|
|
||||||
$permission->roles = $permission->roles($permission);
|
$permission->roles = $permission->roles($permission);
|
||||||
|
|
||||||
return $permission;
|
return $permission;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -328,7 +323,7 @@
|
|||||||
'pageCount' => $pageCount,
|
'pageCount' => $pageCount,
|
||||||
'page' => $currentPage,
|
'page' => $currentPage,
|
||||||
'totalCount' => $totalRecords,
|
'totalCount' => $totalRecords,
|
||||||
'data' => $permissions,
|
'data' => $data,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -223,11 +223,7 @@
|
|||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
$search = $request->get('search');
|
$search = $request->get('search');
|
||||||
$query->where(function ($q) use ($search) {
|
$query->whereAny(['code', 'name', 'level'], 'like', '%' . $search . '%');
|
||||||
$q->whereRaw('LOWER(code) LIKE ?', ['%' . strtolower($search) . '%'])
|
|
||||||
->orWhereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search) . '%'])
|
|
||||||
->orWhereRaw('CAST(level AS TEXT) LIKE ?', ['%' . $search . '%']);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply sorting if provided
|
// Apply sorting if provided
|
||||||
@@ -253,7 +249,7 @@
|
|||||||
$filteredRecords = $query->count();
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
// Get the data for the current page
|
// Get the data for the current page
|
||||||
$positions = $query->get();
|
$data = $query->get();
|
||||||
|
|
||||||
// Calculate the page count
|
// Calculate the page count
|
||||||
$size = $request->get('size', 10); // Default to 10 if not set
|
$size = $request->get('size', 10); // Default to 10 if not set
|
||||||
@@ -270,7 +266,7 @@
|
|||||||
'pageCount' => $pageCount,
|
'pageCount' => $pageCount,
|
||||||
'page' => $currentPage,
|
'page' => $currentPage,
|
||||||
'totalCount' => $totalRecords,
|
'totalCount' => $totalRecords,
|
||||||
'data' => $positions,
|
'data' => $data,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,14 +273,17 @@
|
|||||||
// Retrieve data from the database
|
// Retrieve data from the database
|
||||||
$query = Role::query();
|
$query = Role::query();
|
||||||
|
|
||||||
|
if(!$this->user->hasRole('administrator')){
|
||||||
|
$query->where('name', '!=', 'administrator');
|
||||||
|
}
|
||||||
|
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
$search = $request->get('search');
|
$search = $request->get('search');
|
||||||
$query->where(function ($q) use ($search) {
|
$query->where(function ($q) use ($search) {
|
||||||
$q->whereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search) . '%'])
|
$q->where('name', 'like', '%' . $search . '%')
|
||||||
->orWhereHas('position', function ($query) use ($search) {
|
->orWhereHas('position', function ($query) use ($search) {
|
||||||
$query->whereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search) . '%'])
|
$query->whereAny(['name', 'level'], 'like','%'.$search.'%');
|
||||||
->orWhereRaw('CAST(level AS TEXT) LIKE ?', ['%' . $search . '%']);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -290,19 +293,17 @@
|
|||||||
$order = $request->get('sortOrder');
|
$order = $request->get('sortOrder');
|
||||||
$column = $request->get('sortField');
|
$column = $request->get('sortField');
|
||||||
|
|
||||||
// Handle sorting for position-related columns
|
|
||||||
if ($column === 'position_name') {
|
if ($column === 'position_name') {
|
||||||
$query->leftJoin('positions', 'roles.position_id', '=', 'positions.id')
|
$query->leftJoin('positions', 'roles.position_id', '=', 'positions.id')
|
||||||
->orderByRaw('LOWER(positions.name) ' . $order)
|
->orderBy('positions.name', $order)
|
||||||
->select('roles.*'); // Select only from roles table to avoid column conflicts
|
->select('roles.*'); // Select only from roles table to avoid column conflicts
|
||||||
} else if ($column === 'level') {
|
} else if ($column === 'level') {
|
||||||
$query->leftJoin('positions', 'roles.position_id', '=', 'positions.id')
|
$query->leftJoin('positions', 'roles.position_id', '=', 'positions.id')
|
||||||
->orderBy('positions.level', $order)
|
->orderBy('positions.level', $order)
|
||||||
->select('roles.*'); // Select only from roles table to avoid column conflicts
|
->select('roles.*'); // Select only from roles table to avoid column conflicts
|
||||||
} else {
|
} else {
|
||||||
// Make sorting case-insensitive for string columns
|
|
||||||
if ($column === 'name') {
|
if ($column === 'name') {
|
||||||
$query->orderByRaw('LOWER(roles.name) ' . $order);
|
$query->orderBy('roles.name', $order);
|
||||||
} else {
|
} else {
|
||||||
$query->orderBy($column, $order);
|
$query->orderBy($column, $order);
|
||||||
}
|
}
|
||||||
@@ -328,7 +329,7 @@
|
|||||||
$filteredRecords = $countQuery->distinct()->count('roles.id');
|
$filteredRecords = $countQuery->distinct()->count('roles.id');
|
||||||
|
|
||||||
// Get the data for the current page
|
// Get the data for the current page
|
||||||
$roles = $query->with('position')->get();
|
$data = $query->with('position')->get();
|
||||||
|
|
||||||
// Calculate the page count - ensure we don't divide by zero
|
// Calculate the page count - ensure we don't divide by zero
|
||||||
$pageSize = $request->get('size', 10); // Default to 10 if not provided
|
$pageSize = $request->get('size', 10); // Default to 10 if not provided
|
||||||
@@ -345,7 +346,7 @@
|
|||||||
'pageCount' => $pageCount,
|
'pageCount' => $pageCount,
|
||||||
'page' => $currentPage,
|
'page' => $currentPage,
|
||||||
'totalCount' => $totalRecords,
|
'totalCount' => $totalRecords,
|
||||||
'data' => $roles,
|
'data' => $data,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,10 +79,16 @@
|
|||||||
// Retrieve data from the database
|
// Retrieve data from the database
|
||||||
$query = User::query();
|
$query = User::query();
|
||||||
|
|
||||||
|
if(!$this->user->hasRole('administrator')){
|
||||||
|
$query->whereHas('roles', function($q){
|
||||||
|
$q->where('name', '!=', 'administrator');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
$search = $request->get('search');
|
$search = $request->get('search');
|
||||||
$query->whereAny(['name','email'],'like','%'.$search.'%');
|
$query->whereAny(['name', 'email'], 'like', '%'.$search.'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply sorting if provided
|
// Apply sorting if provided
|
||||||
@@ -108,7 +114,7 @@
|
|||||||
$filteredRecords = $query->count();
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
// Get the data for the current page
|
// Get the data for the current page
|
||||||
$users = $query->with(['branch', 'roles'])->get();
|
$data = $query->with(['branch', 'roles'])->get();
|
||||||
|
|
||||||
// Calculate the page count
|
// Calculate the page count
|
||||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
@@ -124,7 +130,7 @@
|
|||||||
'pageCount' => $pageCount,
|
'pageCount' => $pageCount,
|
||||||
'page' => $currentPage,
|
'page' => $currentPage,
|
||||||
'totalCount' => $totalRecords,
|
'totalCount' => $totalRecords,
|
||||||
'data' => $users,
|
'data' => $data,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,6 +150,9 @@
|
|||||||
|
|
||||||
$user = User::find($id);
|
$user = User::find($id);
|
||||||
$roles = Role::all();
|
$roles = Role::all();
|
||||||
|
if(!$this->user->hasRole('administrator')){
|
||||||
|
$roles = $roles->where('name', '!=', 'administrator');
|
||||||
|
}
|
||||||
$branches = Branch::all();
|
$branches = Branch::all();
|
||||||
return view('usermanagement::users.create', compact('user', 'roles', 'branches'));
|
return view('usermanagement::users.create', compact('user', 'roles', 'branches'));
|
||||||
}
|
}
|
||||||
@@ -234,6 +243,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$roles = Role::all();
|
$roles = Role::all();
|
||||||
|
if(!$this->user->hasRole('administrator')){
|
||||||
|
$roles = $roles->where('name', '!=', 'administrator');
|
||||||
|
}
|
||||||
$branches = Branch::all();
|
$branches = Branch::all();
|
||||||
return view('usermanagement::users.create', compact('roles', 'branches'));
|
return view('usermanagement::users.create', compact('roles', 'branches'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="5" data-datatable-state-save="true" id="permissions-table" data-api-url="{{ route('users.permissions.datatables') }}">
|
<div class="min-w-full card card-grid" data-datatable="false" data-datatable-page-size="5"
|
||||||
<div class="card-header py-5 flex-wrap">
|
data-datatable-state-save="true" id="permissions-table"
|
||||||
|
data-api-url="{{ route('users.permissions.datatables') }}">
|
||||||
|
<div class="flex-wrap py-5 card-header">
|
||||||
<h3 class="card-title">
|
<h3 class="card-title">
|
||||||
List of Permissions
|
List of Permissions
|
||||||
</h3>
|
</h3>
|
||||||
@@ -21,38 +23,43 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-wrap gap-2.5 lg:gap-5">
|
<div class="flex flex-wrap gap-2.5 lg:gap-5">
|
||||||
<div class="h-[24px] border border-r-gray-200"> </div>
|
<div class="h-[24px] border border-r-gray-200"> </div>
|
||||||
<a class="btn btn-sm btn-light" href="{{ route('users.permissions.export') }}"> Export to Excel </a>
|
<a class="btn btn-sm btn-light" href="{{ route('users.permissions.export') }}"> Export to Excel
|
||||||
<a class="btn btn-sm btn-primary" href="{{ route('users.permissions.create') }}"> Add Permission </a>
|
</a>
|
||||||
|
<a class="btn btn-sm btn-primary" href="{{ route('users.permissions.create') }}"> Add Permission
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="scrollable-x-auto">
|
<div class="scrollable-x-auto">
|
||||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm" data-datatable-table="true">
|
<table class="table text-sm font-medium text-gray-700 align-middle table-auto table-border"
|
||||||
|
data-datatable-table="true">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-14">
|
<th class="w-14">
|
||||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox" />
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[250px]" data-datatable-column="name">
|
<th class="min-w-[250px]" data-datatable-column="name">
|
||||||
<span class="sort"> <span class="sort-label"> Permission </span>
|
<span class="sort"> <span class="sort-label"> Permission </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[250px]" data-datatable-column="roles">
|
<th class="min-w-[250px]" data-datatable-column="roles">
|
||||||
<span class="sort"> <span class="sort-label"> Roles </span>
|
<span class="sort"> <span class="sort-label"> Roles </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer justify-center md:justify-between flex-col md:flex-row gap-3 text-gray-600 text-2sm font-medium">
|
<div
|
||||||
<div class="flex items-center gap-2">
|
class="flex-col gap-3 justify-center font-medium text-gray-600 card-footer md:justify-between md:flex-row text-2sm">
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
Show
|
Show
|
||||||
<select class="select select-sm w-16" data-datatable-size="true" name="perpage"> </select> per page
|
<select class="w-16 select select-sm" data-datatable-size="true" name="perpage"> </select> per
|
||||||
|
page
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex gap-4 items-center">
|
||||||
<span data-datatable-info="true"> </span>
|
<span data-datatable-info="true"> </span>
|
||||||
<div class="pagination" data-datatable-pagination="true">
|
<div class="pagination" data-datatable-pagination="true">
|
||||||
</div>
|
</div>
|
||||||
@@ -70,7 +77,7 @@
|
|||||||
function deleteData(data) {
|
function deleteData(data) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Are you sure?',
|
title: 'Are you sure?',
|
||||||
text: "You won't be able to revert this!" ,
|
text: "You won't be able to revert this!",
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonColor: '#3085d6',
|
confirmButtonColor: '#3085d6',
|
||||||
@@ -80,14 +87,14 @@
|
|||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax(`permissions/${data}`, {
|
$.ajax(`permissions/${data}`, {
|
||||||
type: 'DELETE'
|
type: 'DELETE'
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
swal.fire('Deleted!', 'User has been deleted.','success').then(() => {
|
swal.fire('Deleted!', 'User has been deleted.', 'success').then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@@ -102,7 +109,7 @@
|
|||||||
const element = document.querySelector('#permissions-table');
|
const element = document.querySelector('#permissions-table');
|
||||||
const searchInput = document.getElementById('search');
|
const searchInput = document.getElementById('search');
|
||||||
const apiUrl = element.getAttribute('data-api-url');
|
const apiUrl = element.getAttribute('data-api-url');
|
||||||
const colors = ['','badge-primary', 'badge-success', 'badge-info', 'badge-danger', 'badge-warning', 'badge-dark'];
|
const colors = ['', 'badge-primary', 'badge-success', 'badge-info', 'badge-danger', 'badge-warning', 'badge-dark'];
|
||||||
|
|
||||||
|
|
||||||
const dataTableOptions = {
|
const dataTableOptions = {
|
||||||
@@ -125,12 +132,12 @@
|
|||||||
roles: {
|
roles: {
|
||||||
title: 'Roles',
|
title: 'Roles',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
const _render = data.roles.map((role) =>{
|
const _render = data.roles.map((role) => {
|
||||||
const randomColor = colors[Math.floor(Math.random() * colors.length)];
|
const randomColor = colors[Math.floor(Math.random() * colors.length)];
|
||||||
return `<span class="badge ${randomColor} badge-sm">${role.name}</span>`;
|
return `<span class="badge ${randomColor} badge-sm">${role.name}</span>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
return _render.join(' ');
|
return _render.join(' ');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@@ -151,10 +158,10 @@
|
|||||||
|
|
||||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||||
// Custom search functionality
|
// Custom search functionality
|
||||||
searchInput.addEventListener('input', function () {
|
searchInput.addEventListener('input', function() {
|
||||||
const searchValue = this.value.trim();
|
const searchValue = this.value.trim();
|
||||||
dataTable.search(searchValue, true);
|
dataTable.search(searchValue, true);
|
||||||
|
dataTable.goPage(1);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="5" data-datatable-state-save="true" id="positions-table" data-api-url="{{ route('users.positions.datatables') }}">
|
<div class="min-w-full card card-grid" data-datatable="false" data-datatable-page-size="5"
|
||||||
<div class="card-header py-5 flex-wrap">
|
data-datatable-state-save="true" id="positions-table" data-api-url="{{ route('users.positions.datatables') }}">
|
||||||
|
<div class="flex-wrap py-5 card-header">
|
||||||
<h3 class="card-title">
|
<h3 class="card-title">
|
||||||
List of Positions
|
List of Positions
|
||||||
</h3>
|
</h3>
|
||||||
@@ -20,42 +21,47 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-wrap gap-2.5 lg:gap-5">
|
<div class="flex flex-wrap gap-2.5 lg:gap-5">
|
||||||
<div class="h-[100%] border border-r-gray-200"> </div>
|
<div class="h-[100%] border border-r-gray-200"> </div>
|
||||||
<a class="btn btn-sm btn-light" id="export-btn" href="{{ route('users.positions.export') }}"> Export to Excel </a>
|
<a class="btn btn-sm btn-light" id="export-btn" href="{{ route('users.positions.export') }}">
|
||||||
<a class="btn btn-sm btn-primary" href="{{ route('users.positions.create') }}"> Add Position </a>
|
Export to Excel </a>
|
||||||
|
<a class="btn btn-sm btn-primary" href="{{ route('users.positions.create') }}"> Add Position
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="scrollable-x-auto">
|
<div class="scrollable-x-auto">
|
||||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm" data-datatable-table="true">
|
<table class="table text-sm font-medium text-gray-700 align-middle table-auto table-border"
|
||||||
|
data-datatable-table="true">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-14">
|
<th class="w-14">
|
||||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox" />
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="code">
|
<th class="min-w-[150px]" data-datatable-column="code">
|
||||||
<span class="sort"> <span class="sort-label"> Code </span>
|
<span class="sort"> <span class="sort-label"> Code </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[250px]" data-datatable-column="name">
|
<th class="min-w-[250px]" data-datatable-column="name">
|
||||||
<span class="sort"> <span class="sort-label"> Name </span>
|
<span class="sort"> <span class="sort-label"> Name </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[100px]" data-datatable-column="level">
|
<th class="min-w-[100px]" data-datatable-column="level">
|
||||||
<span class="sort"> <span class="sort-label"> Tingkat Jabatan </span>
|
<span class="sort"> <span class="sort-label"> Tingkat Jabatan </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer justify-center md:justify-between flex-col md:flex-row gap-3 text-gray-600 text-2sm font-medium">
|
<div
|
||||||
<div class="flex items-center gap-2">
|
class="flex-col gap-3 justify-center font-medium text-gray-600 card-footer md:justify-between md:flex-row text-2sm">
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
Show
|
Show
|
||||||
<select class="select select-sm w-16" data-datatable-size="true" name="perpage"> </select> per page
|
<select class="w-16 select select-sm" data-datatable-size="true" name="perpage"> </select> per
|
||||||
|
page
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex gap-4 items-center">
|
||||||
<span data-datatable-info="true"> </span>
|
<span data-datatable-info="true"> </span>
|
||||||
<div class="pagination" data-datatable-pagination="true">
|
<div class="pagination" data-datatable-pagination="true">
|
||||||
</div>
|
</div>
|
||||||
@@ -73,7 +79,7 @@
|
|||||||
function deleteData(data) {
|
function deleteData(data) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Are you sure?',
|
title: 'Are you sure?',
|
||||||
text: "You won't be able to revert this!" ,
|
text: "You won't be able to revert this!",
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonColor: '#3085d6',
|
confirmButtonColor: '#3085d6',
|
||||||
@@ -83,14 +89,14 @@
|
|||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax(`positions/${data}`, {
|
$.ajax(`positions/${data}`, {
|
||||||
type: 'DELETE'
|
type: 'DELETE'
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
swal.fire('Deleted!', 'Position has been deleted.','success').then(() => {
|
swal.fire('Deleted!', 'Position has been deleted.', 'success').then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@@ -150,9 +156,10 @@
|
|||||||
const baseExportUrl = exportBtn.getAttribute('href');
|
const baseExportUrl = exportBtn.getAttribute('href');
|
||||||
|
|
||||||
// Custom search functionality
|
// Custom search functionality
|
||||||
searchInput.addEventListener('input', function () {
|
searchInput.addEventListener('input', function() {
|
||||||
const searchValue = this.value.trim();
|
const searchValue = this.value.trim();
|
||||||
dataTable.search(searchValue, true);
|
dataTable.search(searchValue, true);
|
||||||
|
dataTable.goPage(1);
|
||||||
|
|
||||||
// Update export URL with search parameter
|
// Update export URL with search parameter
|
||||||
if (searchValue) {
|
if (searchValue) {
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="5" data-datatable-state-save="true" id="roles-table" data-api-url="{{ route('users.roles.datatables') }}">
|
<div class="min-w-full card card-grid" data-datatable="false" data-datatable-page-size="5"
|
||||||
<div class="card-header py-5 flex-wrap">
|
data-datatable-state-save="true" id="roles-table" data-api-url="{{ route('users.roles.datatables') }}">
|
||||||
|
<div class="flex-wrap py-5 card-header">
|
||||||
<h3 class="card-title">
|
<h3 class="card-title">
|
||||||
List of Roles
|
List of Roles
|
||||||
</h3>
|
</h3>
|
||||||
@@ -28,35 +29,38 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="scrollable-x-auto">
|
<div class="scrollable-x-auto">
|
||||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm" data-datatable-table="true">
|
<table class="table text-sm font-medium text-gray-700 align-middle table-auto table-border"
|
||||||
|
data-datatable-table="true">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-14">
|
<th class="w-14">
|
||||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox" />
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[250px]" data-datatable-column="name">
|
<th class="min-w-[250px]" data-datatable-column="name">
|
||||||
<span class="sort"> <span class="sort-label"> Role </span>
|
<span class="sort"> <span class="sort-label"> Role </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[200px]" data-datatable-column="position_name">
|
<th class="min-w-[200px]" data-datatable-column="position_name">
|
||||||
<span class="sort"> <span class="sort-label"> Position </span>
|
<span class="sort"> <span class="sort-label"> Position </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[100px]" data-datatable-column="level">
|
<th class="min-w-[100px]" data-datatable-column="level">
|
||||||
<span class="sort"> <span class="sort-label"> Tingkat Jabatan </span>
|
<span class="sort"> <span class="sort-label"> Tingkat Jabatan </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer justify-center md:justify-between flex-col md:flex-row gap-3 text-gray-600 text-2sm font-medium">
|
<div
|
||||||
<div class="flex items-center gap-2">
|
class="flex-col gap-3 justify-center font-medium text-gray-600 card-footer md:justify-between md:flex-row text-2sm">
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
Show
|
Show
|
||||||
<select class="select select-sm w-16" data-datatable-size="true" name="perpage"> </select> per page
|
<select class="w-16 select select-sm" data-datatable-size="true" name="perpage"> </select> per
|
||||||
|
page
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex gap-4 items-center">
|
||||||
<span data-datatable-info="true"> </span>
|
<span data-datatable-info="true"> </span>
|
||||||
<div class="pagination" data-datatable-pagination="true">
|
<div class="pagination" data-datatable-pagination="true">
|
||||||
</div>
|
</div>
|
||||||
@@ -74,7 +78,7 @@
|
|||||||
function deleteData(data) {
|
function deleteData(data) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Are you sure?',
|
title: 'Are you sure?',
|
||||||
text: "You won't be able to revert this!" ,
|
text: "You won't be able to revert this!",
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonColor: '#3085d6',
|
confirmButtonColor: '#3085d6',
|
||||||
@@ -84,14 +88,14 @@
|
|||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax(`roles/${data}`, {
|
$.ajax(`roles/${data}`, {
|
||||||
type: 'DELETE'
|
type: 'DELETE'
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
swal.fire('Deleted!', 'User has been deleted.','success').then(() => {
|
swal.fire('Deleted!', 'User has been deleted.', 'success').then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@@ -156,9 +160,10 @@
|
|||||||
|
|
||||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||||
// Custom search functionality
|
// Custom search functionality
|
||||||
searchInput.addEventListener('input', function () {
|
searchInput.addEventListener('input', function() {
|
||||||
const searchValue = this.value.trim();
|
const searchValue = this.value.trim();
|
||||||
dataTable.search(searchValue, true);
|
dataTable.search(searchValue, true);
|
||||||
|
dataTable.goPage(1);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
Reference in New Issue
Block a user