progress
This commit is contained in:
parent
ac86078d96
commit
ba857bea05
@ -155,21 +155,65 @@ class DashboardController extends Controller
|
|||||||
->all();
|
->all();
|
||||||
$keyword = request('keyword');
|
$keyword = request('keyword');
|
||||||
$kategori = request('kategori');
|
$kategori = request('kategori');
|
||||||
|
$kategoriHeader = request('kategori_header');
|
||||||
|
|
||||||
$unitFilter = request('unit');
|
$unitFilter = request('unit');
|
||||||
$kategoriIds = is_array($kategori)
|
$kategoriValues = is_array($kategori)
|
||||||
? array_values(array_filter($kategori))
|
? array_values(array_filter($kategori))
|
||||||
: array_values(array_filter(explode(',', (string) $kategori)));
|
: array_values(array_filter(explode(',', (string) $kategori)));
|
||||||
|
$kategoriHeaderValues = is_array($kategoriHeader)
|
||||||
|
? array_values(array_filter($kategoriHeader))
|
||||||
|
: array_values(array_filter(explode(',', (string) $kategoriHeader)));
|
||||||
|
$allKategoriValues = array_values(array_filter(array_merge($kategoriValues, $kategoriHeaderValues)));
|
||||||
|
$kategoriTypes = [];
|
||||||
|
$kategoriIds = [];
|
||||||
|
foreach ($allKategoriValues as $val) {
|
||||||
|
$lower = strtolower(trim((string) $val));
|
||||||
|
if (in_array($lower, ['akreditasi', 'akre'], true)) {
|
||||||
|
$kategoriTypes[] = 'akreditasi';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($lower === 'hukum') {
|
||||||
|
$kategoriTypes[] = 'hukum';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($lower === 'lainnya') {
|
||||||
|
$kategoriTypes[] = 'lainnya';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$kategoriIds[] = $val;
|
||||||
|
}
|
||||||
$unitFilterIds = is_array($unitFilter)
|
$unitFilterIds = is_array($unitFilter)
|
||||||
? array_values(array_filter($unitFilter))
|
? array_values(array_filter($unitFilter))
|
||||||
: array_values(array_filter(explode(',', (string) $unitFilter)));
|
: array_values(array_filter(explode(',', (string) $unitFilter)));
|
||||||
if (!empty($unitFilterIds)) {
|
if (!empty($unitFilterIds)) {
|
||||||
$unitIds = array_values(array_intersect($unitIds, $unitFilterIds));
|
$unitIds = array_values(array_intersect($unitIds, $unitFilterIds));
|
||||||
}
|
}
|
||||||
$query = FileDirectory::with('kategori')->where('statusenabled', true)
|
$baseQuery = FileDirectory::with('kategori')
|
||||||
|
->where('statusenabled', true)
|
||||||
->where('status_action', 'approved')
|
->where('status_action', 'approved')
|
||||||
->whereIn('id_unit_kerja', $unitIds)
|
->whereIn('id_unit_kerja', $unitIds);
|
||||||
->when(!empty($kategoriIds), function ($q) use ($kategoriIds) {
|
|
||||||
$q->whereIn('master_kategori_directory_id', $kategoriIds);
|
$query = (clone $baseQuery)
|
||||||
|
->when(!empty($kategoriIds) || !empty($kategoriTypes), function ($q) use ($kategoriIds, $kategoriTypes) {
|
||||||
|
$q->where(function ($sub) use ($kategoriIds, $kategoriTypes) {
|
||||||
|
$hasClause = false;
|
||||||
|
if (!empty($kategoriIds)) {
|
||||||
|
$sub->whereIn('master_kategori_directory_id', $kategoriIds);
|
||||||
|
$hasClause = true;
|
||||||
|
}
|
||||||
|
if (in_array('akreditasi', $kategoriTypes, true)) {
|
||||||
|
$sub->where('is_akre', true);
|
||||||
|
$hasClause = true;
|
||||||
|
}
|
||||||
|
if (in_array('hukum', $kategoriTypes, true)) {
|
||||||
|
$hasClause ? $sub->orWhereNotNull('kategori_hukum') : $sub->whereNotNull('kategori_hukum');
|
||||||
|
$hasClause = true;
|
||||||
|
}
|
||||||
|
if (in_array('lainnya', $kategoriTypes, true)) {
|
||||||
|
$hasClause ? $sub->orWhereNotNull('master_kategori_directory_id') : $sub->whereNotNull('master_kategori_directory_id');
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
->when($keyword, function ($q) use ($keyword) {
|
->when($keyword, function ($q) use ($keyword) {
|
||||||
$q->where(function ($sub) use ($keyword) {
|
$q->where(function ($sub) use ($keyword) {
|
||||||
@ -185,10 +229,23 @@ class DashboardController extends Controller
|
|||||||
$item->nama_kategori = $item->kategori->nama_kategori_directory ?? $item->kategori_hukum ?? null;
|
$item->nama_kategori = $item->kategori->nama_kategori_directory ?? $item->kategori_hukum ?? null;
|
||||||
return $item;
|
return $item;
|
||||||
});
|
});
|
||||||
|
$kategoriList = (clone $baseQuery)->get()->map(function($item){
|
||||||
|
if ($item->is_akre) {
|
||||||
|
return ['id' => 'akreditasi', 'label' => 'Kategori Akreditasi'];
|
||||||
|
}
|
||||||
|
if (!empty($item->kategori_hukum)) {
|
||||||
|
return ['id' => 'hukum', 'label' => 'Kategori Hukum'];
|
||||||
|
}
|
||||||
|
$label = $item->kategori->nama_kategori_directory ?? $item->nama_kategori_directory ?? 'Kategori';
|
||||||
|
$id = $item->master_kategori_directory_id ?? $label;
|
||||||
|
return ['id' => (string) $id, 'label' => $label];
|
||||||
|
})->unique('id')->values();
|
||||||
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'message' => 'Berhasil mendapatkan data',
|
'message' => 'Berhasil mendapatkan data',
|
||||||
'data' => $items,
|
'data' => $items,
|
||||||
|
'kategori_list' => $kategoriList,
|
||||||
'pagination' => [
|
'pagination' => [
|
||||||
'current_page' => $data->currentPage(),
|
'current_page' => $data->currentPage(),
|
||||||
'next_page' => $data->hasMorePages() ? $data->currentPage() + 1 : null,
|
'next_page' => $data->hasMorePages() ? $data->currentPage() + 1 : null,
|
||||||
@ -928,18 +985,61 @@ class DashboardController extends Controller
|
|||||||
$keyword = request('keyword');
|
$keyword = request('keyword');
|
||||||
$unitId = request('unit');
|
$unitId = request('unit');
|
||||||
$kategori = request('kategori');
|
$kategori = request('kategori');
|
||||||
|
$kategoriHeader = request('kategori_header');
|
||||||
$unitIds = is_array($unitId)
|
$unitIds = is_array($unitId)
|
||||||
? array_values(array_filter($unitId))
|
? array_values(array_filter($unitId))
|
||||||
: array_values(array_filter(explode(',', (string) $unitId)));
|
: array_values(array_filter(explode(',', (string) $unitId)));
|
||||||
$kategoriIds = is_array($kategori)
|
$kategoriValues = is_array($kategori)
|
||||||
? array_values(array_filter($kategori))
|
? array_values(array_filter($kategori))
|
||||||
: array_values(array_filter(explode(',', (string) $kategori)));
|
: array_values(array_filter(explode(',', (string) $kategori)));
|
||||||
$query = FileDirectory::with('kategori')->where('statusenabled', true)->where('status_action', 'approved')
|
$kategoriHeaderValues = is_array($kategoriHeader)
|
||||||
|
? array_values(array_filter($kategoriHeader))
|
||||||
|
: array_values(array_filter(explode(',', (string) $kategoriHeader)));
|
||||||
|
$allKategoriValues = array_values(array_filter(array_merge($kategoriValues, $kategoriHeaderValues)));
|
||||||
|
$kategoriTypes = [];
|
||||||
|
$kategoriIds = [];
|
||||||
|
foreach ($allKategoriValues as $val) {
|
||||||
|
$lower = strtolower(trim((string) $val));
|
||||||
|
if (in_array($lower, ['akreditasi', 'akre'], true)) {
|
||||||
|
$kategoriTypes[] = 'akreditasi';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($lower === 'hukum') {
|
||||||
|
$kategoriTypes[] = 'hukum';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($lower === 'lainnya') {
|
||||||
|
$kategoriTypes[] = 'lainnya';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$kategoriIds[] = $val;
|
||||||
|
}
|
||||||
|
$baseQuery = FileDirectory::with('kategori')
|
||||||
|
->where('statusenabled', true)->where('status_action', 'approved')
|
||||||
->when(!empty($unitIds), function ($q) use ($unitIds) {
|
->when(!empty($unitIds), function ($q) use ($unitIds) {
|
||||||
$q->whereIn('id_unit_kerja', $unitIds);
|
$q->whereIn('id_unit_kerja', $unitIds);
|
||||||
})
|
});
|
||||||
->when(!empty($kategoriIds), function ($q) use ($kategoriIds) {
|
|
||||||
$q->whereIn('master_kategori_directory_id', $kategoriIds);
|
$query = (clone $baseQuery)
|
||||||
|
->when(!empty($kategoriIds) || !empty($kategoriTypes), function ($q) use ($kategoriIds, $kategoriTypes) {
|
||||||
|
$q->where(function ($sub) use ($kategoriIds, $kategoriTypes) {
|
||||||
|
$hasClause = false;
|
||||||
|
if (!empty($kategoriIds)) {
|
||||||
|
$sub->whereIn('master_kategori_directory_id', $kategoriIds);
|
||||||
|
$hasClause = true;
|
||||||
|
}
|
||||||
|
if (in_array('akreditasi', $kategoriTypes, true)) {
|
||||||
|
$hasClause ? $sub->orWhere('is_akre', true) : $sub->where('is_akre', true);
|
||||||
|
$hasClause = true;
|
||||||
|
}
|
||||||
|
if (in_array('hukum', $kategoriTypes, true)) {
|
||||||
|
$hasClause ? $sub->orWhereNotNull('kategori_hukum') : $sub->whereNotNull('kategori_hukum');
|
||||||
|
$hasClause = true;
|
||||||
|
}
|
||||||
|
if (in_array('lainnya', $kategoriTypes, true)) {
|
||||||
|
$hasClause ? $sub->orWhereNotNull('master_kategori_directory_id') : $sub->whereNotNull('master_kategori_directory_id');
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
->when($keyword, function ($q) use ($keyword) {
|
->when($keyword, function ($q) use ($keyword) {
|
||||||
$q->where(function ($sub) use ($keyword) {
|
$q->where(function ($sub) use ($keyword) {
|
||||||
@ -962,10 +1062,23 @@ class DashboardController extends Controller
|
|||||||
return $item;
|
return $item;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$kategoriList = (clone $baseQuery)->get()->map(function($item){
|
||||||
|
if ($item->is_akre) {
|
||||||
|
return ['id' => 'akreditasi', 'label' => 'Kategori Akreditasi'];
|
||||||
|
}
|
||||||
|
if (!empty($item->kategori_hukum)) {
|
||||||
|
return ['id' => 'hukum', 'label' => 'Kategori Hukum'];
|
||||||
|
}
|
||||||
|
$label = $item->kategori->nama_kategori_directory ?? $item->nama_kategori_directory ?? 'Kategori';
|
||||||
|
$id = $item->master_kategori_directory_id ?? $label;
|
||||||
|
return ['id' => (string) $id, 'label' => $label];
|
||||||
|
})->unique('id')->values();
|
||||||
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'message' => 'Berhasil mendapatkan data',
|
'message' => 'Berhasil mendapatkan data',
|
||||||
'data' => $items,
|
'data' => $items,
|
||||||
|
'kategori_list' => $kategoriList,
|
||||||
'pagination' => [
|
'pagination' => [
|
||||||
'current_page' => $data->currentPage(),
|
'current_page' => $data->currentPage(),
|
||||||
'next_page' => $data->hasMorePages() ? $data->currentPage() + 1 : null,
|
'next_page' => $data->hasMorePages() ? $data->currentPage() + 1 : null,
|
||||||
|
|||||||
@ -141,11 +141,11 @@
|
|||||||
<div class="d-flex align-items-center gap-2 table-header-filter">
|
<div class="d-flex align-items-center gap-2 table-header-filter">
|
||||||
<span>Kategori</span>
|
<span>Kategori</span>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button class="btn btn-light btn-sm border" type="button" id="tableKategoriHeaderBtn" data-bs-toggle="dropdown" aria-expanded="false">
|
<button class="btn btn-light btn-sm border" type="button" id="tableKategoriHeaderBtn" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
|
||||||
<i class="ti ti-filter"></i>
|
<i class="ti ti-filter"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu p-2" id="tableKategoriHeaderMenu" style="min-width: 220px;">
|
<div class="dropdown-menu p-2" id="tableKategoriHeaderMenu" style="min-width: 220px;">
|
||||||
<div class="small text-muted px-1">Filter kategori</div>
|
<div class="small text-muted px-1">Filter kategori (BETA)</div>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<div class="kategori-header-list"></div>
|
<div class="kategori-header-list"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -161,7 +161,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-2 small text-muted" id="tableLegend"></div>
|
|
||||||
<div class="d-flex flex-wrap align-items-center gap-2 mt-3">
|
<div class="d-flex flex-wrap align-items-center gap-2 mt-3">
|
||||||
<div class="d-flex align-items-center gap-1">
|
<div class="d-flex align-items-center gap-1">
|
||||||
<span class="small text-muted">Tampilkan</span>
|
<span class="small text-muted">Tampilkan</span>
|
||||||
@ -198,7 +198,8 @@
|
|||||||
const authPegawai = @json(auth()->user()->objectpegawaifk);
|
const authPegawai = @json(auth()->user()->objectpegawaifk);
|
||||||
const formCreate = $("#formFile")
|
const formCreate = $("#formFile")
|
||||||
const modalCreate = document.getElementById('modalCreateFile')
|
const modalCreate = document.getElementById('modalCreateFile')
|
||||||
const tableState = { data: [], page: 1, pageSize: 8, search: '', unit: [], kategori: [], kategoriType: [], lastPage: 1, total: 0 };
|
const tableState = { data: [], page: 1, pageSize: 8, search: '', unit: [], kategori: [], kategoriType: [], kategoriHeader: [], lastPage: 1, total: 0 };
|
||||||
|
let kategoriOptionCache = [];
|
||||||
const tbody = document.getElementById('tableDataUmum');
|
const tbody = document.getElementById('tableDataUmum');
|
||||||
const paginationEl = document.getElementById('paginationControls');
|
const paginationEl = document.getElementById('paginationControls');
|
||||||
const summaryEl = document.getElementById('tableSummary');
|
const summaryEl = document.getElementById('tableSummary');
|
||||||
@ -294,7 +295,7 @@
|
|||||||
if (!checkbox) return;
|
if (!checkbox) return;
|
||||||
const selected = Array.from(kategoriHeaderMenu.querySelectorAll('input[type="checkbox"]:checked'))
|
const selected = Array.from(kategoriHeaderMenu.querySelectorAll('input[type="checkbox"]:checked'))
|
||||||
.map(el => el.value);
|
.map(el => el.value);
|
||||||
tableState.kategoriType = selected;
|
tableState.kategoriHeader = selected;
|
||||||
if (kategoriSelect && window.$ && $.fn.select2) {
|
if (kategoriSelect && window.$ && $.fn.select2) {
|
||||||
const single = selected.length === 1 ? selected[0] : '';
|
const single = selected.length === 1 ? selected[0] : '';
|
||||||
$('#tableKategori').val(single).trigger('change');
|
$('#tableKategori').val(single).trigger('change');
|
||||||
@ -396,10 +397,14 @@
|
|||||||
const kategoriFlag = resolveKategoriFlag(item);
|
const kategoriFlag = resolveKategoriFlag(item);
|
||||||
|
|
||||||
const rowColor = pickColor(kategoriFlag.key, kategoriFlag.label);
|
const rowColor = pickColor(kategoriFlag.key, kategoriFlag.label);
|
||||||
const rowClass = expiryStatus === 'expired' ? 'table-danger' : (expiryStatus === 'soon' ? 'table-warning' : 'row-shade');
|
const isAkre = kategoriFlag.key === 'akre';
|
||||||
|
const rowClass = isAkre ? 'table-info' : (expiryStatus === 'expired' ? 'table-danger' : (expiryStatus === 'soon' ? 'table-warning' : 'row-shade'));
|
||||||
const expiryBadge = expiryStatus === 'expired'
|
const expiryBadge = expiryStatus === 'expired'
|
||||||
? `<span class="badge bg-danger" style="font-size:10px;">Expired</span>`
|
? `<span class="badge bg-danger" style="font-size:10px;">Expired</span>`
|
||||||
: (expiryStatus === 'soon' ? `<span class="badge bg-warning text-dark" style="font-size:10px;">Akan Expired</span>` : '');
|
: (expiryStatus === 'soon' ? `<span class="badge bg-warning text-dark" style="font-size:10px;">Akan Expired</span>` : '');
|
||||||
|
const akreBadge = isAkre
|
||||||
|
? `<span class="badge bg-primary text-white" style="font-size:10px;">Akreditasi</span>`
|
||||||
|
: '';
|
||||||
return `
|
return `
|
||||||
<tr class="${rowClass}" style="--row-bg:${rowColor};">
|
<tr class="${rowClass}" style="--row-bg:${rowColor};">
|
||||||
|
|
||||||
@ -460,7 +465,7 @@
|
|||||||
word-break:break-word;
|
word-break:break-word;
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
${item.nama_dokumen || '-'}
|
${item.nama_dokumen || '-'} ${akreBadge}
|
||||||
</a>
|
</a>
|
||||||
${expiryBadge}
|
${expiryBadge}
|
||||||
|
|
||||||
@ -582,22 +587,33 @@
|
|||||||
return Array.from(seen.values()).sort((a,b) => a.label.localeCompare(b.label));
|
return Array.from(seen.values()).sort((a,b) => a.label.localeCompare(b.label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isKategoriMatch(item, types){
|
||||||
|
if (!types.length) return true;
|
||||||
|
const lowerTypes = types.map(t => String(t).toLowerCase());
|
||||||
|
const isAkre = (item.is_akre === true) || String(item.is_akre).toLowerCase() === 'true' || Number(item.is_akre) === 1;
|
||||||
|
const isHukum = !!item.kategori_hukum;
|
||||||
|
const hasKategoriId = !!item.master_kategori_directory_id;
|
||||||
|
if (isAkre && lowerTypes.includes('akreditasi')) return true;
|
||||||
|
if (isHukum && lowerTypes.includes('hukum')) return true;
|
||||||
|
if (!isAkre && !isHukum && hasKategoriId && lowerTypes.includes('lainnya')) return true;
|
||||||
|
|
||||||
|
const catId = String(getKategoriId(item)).toLowerCase();
|
||||||
|
const catLabel = String(getKategoriLabel(item)).toLowerCase();
|
||||||
|
return lowerTypes.includes(catId) || lowerTypes.includes(catLabel);
|
||||||
|
}
|
||||||
|
|
||||||
function filterByKategoriType(items){
|
function filterByKategoriType(items){
|
||||||
const types = (tableState.kategoriType || []).map(v => String(v));
|
const types = (tableState.kategoriType || []).map(v => String(v));
|
||||||
if (!types.length) return items;
|
if (!types.length) return items;
|
||||||
return items.filter(item => {
|
return items.filter(item => isKategoriMatch(item, types));
|
||||||
const catId = getKategoriId(item);
|
|
||||||
const catLabel = getKategoriLabel(item);
|
|
||||||
return types.includes(catId) || types.includes(catLabel);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderKategoriHeaderOptions(){
|
function renderKategoriHeaderOptions(){
|
||||||
if (!kategoriHeaderMenu) return;
|
if (!kategoriHeaderMenu) return;
|
||||||
const list = kategoriHeaderMenu.querySelector('.kategori-header-list');
|
const list = kategoriHeaderMenu.querySelector('.kategori-header-list');
|
||||||
if (!list) return;
|
if (!list) return;
|
||||||
const options = getKategoriOptionsFromData();
|
const options = kategoriOptionCache.length ? kategoriOptionCache : getKategoriOptionsFromData();
|
||||||
const selected = (tableState.kategoriType || []).map(v => String(v));
|
const selected = (tableState.kategoriHeader || []).map(v => String(v));
|
||||||
if(options.length === 0){
|
if(options.length === 0){
|
||||||
list.innerHTML = '<div class=\"dropdown-item text-muted\">Tidak ada kategori</div>';
|
list.innerHTML = '<div class=\"dropdown-item text-muted\">Tidak ada kategori</div>';
|
||||||
return;
|
return;
|
||||||
@ -627,10 +643,14 @@
|
|||||||
if (tableState.kategoriType && tableState.kategoriType.length > 0) {
|
if (tableState.kategoriType && tableState.kategoriType.length > 0) {
|
||||||
tableState.kategoriType.forEach(id => params.append('kategori[]', id));
|
tableState.kategoriType.forEach(id => params.append('kategori[]', id));
|
||||||
}
|
}
|
||||||
|
if (tableState.kategoriHeader && tableState.kategoriHeader.length > 0) {
|
||||||
|
tableState.kategoriHeader.forEach(id => params.append('kategori_header[]', id));
|
||||||
|
}
|
||||||
fetch(`/datatable-umum?${params.toString()}`)
|
fetch(`/datatable-umum?${params.toString()}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
tableState.data = data?.data || [];
|
tableState.data = data?.data || [];
|
||||||
|
kategoriOptionCache = data?.kategori_list || kategoriOptionCache;
|
||||||
tableState.lastPage = data?.pagination?.last_page || 1;
|
tableState.lastPage = data?.pagination?.last_page || 1;
|
||||||
tableState.total = data?.pagination?.total || 0;
|
tableState.total = data?.pagination?.total || 0;
|
||||||
renderKategoriHeaderOptions();
|
renderKategoriHeaderOptions();
|
||||||
|
|||||||
@ -135,11 +135,11 @@
|
|||||||
<div class="d-flex align-items-center gap-2 table-header-filter">
|
<div class="d-flex align-items-center gap-2 table-header-filter">
|
||||||
<span>Kategori</span>
|
<span>Kategori</span>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button class="btn btn-light btn-sm border" type="button" id="tableKategoriHeaderBtn" data-bs-toggle="dropdown" aria-expanded="false">
|
<button class="btn btn-light btn-sm border" type="button" id="tableKategoriHeaderBtn" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
|
||||||
<i class="ti ti-filter"></i>
|
<i class="ti ti-filter"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu p-2" id="tableKategoriHeaderMenu" style="min-width: 220px;">
|
<div class="dropdown-menu p-2" id="tableKategoriHeaderMenu" style="min-width: 220px;">
|
||||||
<div class="small text-muted px-1">Filter kategori</div>
|
<div class="small text-muted px-1">Filter kategori (BETA)</div>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<div class="kategori-header-list"></div>
|
<div class="kategori-header-list"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -156,7 +156,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-2 small text-muted" id="tableLegend"></div>
|
|
||||||
<div class="d-flex flex-wrap align-items-center gap-2 mt-3">
|
<div class="d-flex flex-wrap align-items-center gap-2 mt-3">
|
||||||
<div class="d-flex align-items-center gap-1">
|
<div class="d-flex align-items-center gap-1">
|
||||||
<span class="small text-muted">Tampilkan</span>
|
<span class="small text-muted">Tampilkan</span>
|
||||||
@ -199,7 +199,8 @@
|
|||||||
const authPegawai = @json(auth()->user()->objectpegawaifk);
|
const authPegawai = @json(auth()->user()->objectpegawaifk);
|
||||||
const formCreate = $("#formFile");
|
const formCreate = $("#formFile");
|
||||||
const modalCreate = document.getElementById('modalCreateFile');
|
const modalCreate = document.getElementById('modalCreateFile');
|
||||||
const tableState = { data: [], page: 1, pageSize: 8, search: '', unit: [], kategori: [], kategoriType: [], lastPage: 1, total: 0 };
|
const tableState = { data: [], page: 1, pageSize: 8, search: '', unit: [], kategori: [], kategoriType: [], kategoriHeader: [], lastPage: 1, total: 0 };
|
||||||
|
let kategoriOptionCache = [];
|
||||||
const tbody = document.getElementById('tableDataUnit');
|
const tbody = document.getElementById('tableDataUnit');
|
||||||
const paginationEl = document.getElementById('paginationControls');
|
const paginationEl = document.getElementById('paginationControls');
|
||||||
const summaryEl = document.getElementById('tableSummary');
|
const summaryEl = document.getElementById('tableSummary');
|
||||||
@ -291,7 +292,7 @@
|
|||||||
if (!checkbox) return;
|
if (!checkbox) return;
|
||||||
const selected = Array.from(kategoriHeaderMenu.querySelectorAll('input[type="checkbox"]:checked'))
|
const selected = Array.from(kategoriHeaderMenu.querySelectorAll('input[type="checkbox"]:checked'))
|
||||||
.map(el => el.value);
|
.map(el => el.value);
|
||||||
tableState.kategoriType = selected;
|
tableState.kategoriHeader = selected;
|
||||||
if (kategoriSelect && window.$ && $.fn.select2) {
|
if (kategoriSelect && window.$ && $.fn.select2) {
|
||||||
const single = selected.length === 1 ? selected[0] : '';
|
const single = selected.length === 1 ? selected[0] : '';
|
||||||
$('#tableKategori').val(single).trigger('change');
|
$('#tableKategori').val(single).trigger('change');
|
||||||
@ -525,10 +526,14 @@
|
|||||||
const checked = selectedIds.has(String(item.file_directory_id)) ? 'checked' : '';
|
const checked = selectedIds.has(String(item.file_directory_id)) ? 'checked' : '';
|
||||||
const kategoriFlag = resolveKategoriFlag(item);
|
const kategoriFlag = resolveKategoriFlag(item);
|
||||||
const rowColor = pickColor(kategoriFlag.key, kategoriFlag.label);
|
const rowColor = pickColor(kategoriFlag.key, kategoriFlag.label);
|
||||||
const rowClass = expiryStatus === 'expired' ? 'table-danger' : (expiryStatus === 'soon' ? 'table-warning' : 'row-shade');
|
const isAkre = kategoriFlag.key === 'akre';
|
||||||
|
const rowClass = isAkre ? 'table-info' : (expiryStatus === 'expired' ? 'table-danger' : (expiryStatus === 'soon' ? 'table-warning' : 'row-shade'));
|
||||||
const expiryBadge = expiryStatus === 'expired'
|
const expiryBadge = expiryStatus === 'expired'
|
||||||
? `<span class="badge bg-danger" style="font-size:10px;">Expired</span>`
|
? `<span class="badge bg-danger" style="font-size:10px;">Expired</span>`
|
||||||
: (expiryStatus === 'soon' ? `<span class="badge bg-warning text-dark" style="font-size:10px;">Akan Expired</span>` : '');
|
: (expiryStatus === 'soon' ? `<span class="badge bg-warning text-dark" style="font-size:10px;">Akan Expired</span>` : '');
|
||||||
|
const akreBadge = isAkre
|
||||||
|
? `<span class="badge bg-primary text-white ms-2" style="font-size:10px;">Akreditasi</span>`
|
||||||
|
: '';
|
||||||
return `
|
return `
|
||||||
<tr class="${rowClass}" style="--row-bg:${rowColor};">
|
<tr class="${rowClass}" style="--row-bg:${rowColor};">
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
@ -579,7 +584,7 @@
|
|||||||
>
|
>
|
||||||
${item.nama_dokumen || '-'}
|
${item.nama_dokumen || '-'}
|
||||||
</a>
|
</a>
|
||||||
${expiryBadge}
|
${akreBadge}${expiryBadge}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@ -697,22 +702,35 @@
|
|||||||
return Array.from(seen.values()).sort((a,b) => a.label.localeCompare(b.label));
|
return Array.from(seen.values()).sort((a,b) => a.label.localeCompare(b.label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isKategoriMatch(item, types){
|
||||||
|
if (!types.length) return true;
|
||||||
|
const lowerTypes = types.map(t => String(t).toLowerCase());
|
||||||
|
const isAkre = (item.is_akre === true) || String(item.is_akre).toLowerCase() === 'true' || Number(item.is_akre) === 1;
|
||||||
|
const isHukum = !!item.kategori_hukum;
|
||||||
|
const hasKategoriId = !!item.master_kategori_directory_id;
|
||||||
|
// special buckets
|
||||||
|
if (isAkre && lowerTypes.includes('akreditasi')) return true;
|
||||||
|
if (isHukum && lowerTypes.includes('hukum')) return true;
|
||||||
|
if (!isAkre && !isHukum && hasKategoriId && lowerTypes.includes('lainnya')) return true;
|
||||||
|
|
||||||
|
// fallback to id/label comparison
|
||||||
|
const catId = String(getKategoriId(item)).toLowerCase();
|
||||||
|
const catLabel = String(getKategoriLabel(item)).toLowerCase();
|
||||||
|
return lowerTypes.includes(catId) || lowerTypes.includes(catLabel);
|
||||||
|
}
|
||||||
|
|
||||||
function filterByKategoriType(items){
|
function filterByKategoriType(items){
|
||||||
const types = (tableState.kategoriType || []).map(v => String(v));
|
const types = (tableState.kategoriType || []).map(v => String(v));
|
||||||
if (!types.length) return items;
|
if (!types.length) return items;
|
||||||
return items.filter(item => {
|
return items.filter(item => isKategoriMatch(item, types));
|
||||||
const catId = getKategoriId(item);
|
|
||||||
const catLabel = getKategoriLabel(item);
|
|
||||||
return types.includes(catId) || types.includes(catLabel);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderKategoriHeaderOptions(){
|
function renderKategoriHeaderOptions(){
|
||||||
if (!kategoriHeaderMenu) return;
|
if (!kategoriHeaderMenu) return;
|
||||||
const list = kategoriHeaderMenu.querySelector('.kategori-header-list');
|
const list = kategoriHeaderMenu.querySelector('.kategori-header-list');
|
||||||
if (!list) return;
|
if (!list) return;
|
||||||
const options = getKategoriOptionsFromData();
|
const options = kategoriOptionCache.length ? kategoriOptionCache : getKategoriOptionsFromData();
|
||||||
const selected = (tableState.kategoriType || []).map(v => String(v));
|
const selected = (tableState.kategoriHeader || []).map(v => String(v));
|
||||||
if(options.length === 0){
|
if(options.length === 0){
|
||||||
list.innerHTML = '<div class=\"dropdown-item text-muted\">Tidak ada kategori</div>';
|
list.innerHTML = '<div class=\"dropdown-item text-muted\">Tidak ada kategori</div>';
|
||||||
return;
|
return;
|
||||||
@ -739,7 +757,7 @@
|
|||||||
const event = new Event('change', { bubbles: true });
|
const event = new Event('change', { bubbles: true });
|
||||||
checkbox.dispatchEvent(event);
|
checkbox.dispatchEvent(event);
|
||||||
}else{
|
}else{
|
||||||
tableState.kategoriType = [id];
|
tableState.kategoriHeader = [id];
|
||||||
if (kategoriSelect && window.$ && $.fn.select2) {
|
if (kategoriSelect && window.$ && $.fn.select2) {
|
||||||
$('#tableKategori').val(id).trigger('change');
|
$('#tableKategori').val(id).trigger('change');
|
||||||
}
|
}
|
||||||
@ -763,10 +781,14 @@
|
|||||||
if (tableState.kategoriType && tableState.kategoriType.length > 0) {
|
if (tableState.kategoriType && tableState.kategoriType.length > 0) {
|
||||||
tableState.kategoriType.forEach(id => params.append('kategori[]', id));
|
tableState.kategoriType.forEach(id => params.append('kategori[]', id));
|
||||||
}
|
}
|
||||||
|
if (tableState.kategoriHeader && tableState.kategoriHeader.length > 0) {
|
||||||
|
tableState.kategoriHeader.forEach(id => params.append('kategori_header[]', id));
|
||||||
|
}
|
||||||
fetch(`/data-internal?${params.toString()}`)
|
fetch(`/data-internal?${params.toString()}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
tableState.data = data?.data || [];
|
tableState.data = data?.data || [];
|
||||||
|
kategoriOptionCache = data?.kategori_list || kategoriOptionCache;
|
||||||
tableState.lastPage = data?.pagination?.last_page || 1;
|
tableState.lastPage = data?.pagination?.last_page || 1;
|
||||||
tableState.total = data?.pagination?.total || 0;
|
tableState.total = data?.pagination?.total || 0;
|
||||||
renderKategoriHeaderOptions();
|
renderKategoriHeaderOptions();
|
||||||
|
|||||||
@ -41,13 +41,14 @@
|
|||||||
<span class="hide-menu">Dokumen Umum</span>
|
<span class="hide-menu">Dokumen Umum</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@if(auth()->user()->dataUser->mappingUnitKerjaPegawai()->where('objectunitkerjapegawaifk', 51)->exists())
|
||||||
<li class="sidebar-item">
|
<li class="sidebar-item">
|
||||||
<a class="sidebar-link" href="{{ url('/data-akreditasi') }}" aria-expanded="false">
|
<a class="sidebar-link" href="{{ url('/data-akreditasi') }}" aria-expanded="false">
|
||||||
<i class="fa-solid fa-sliders"></i>
|
<i class="fa-solid fa-sliders"></i>
|
||||||
<span class="hide-menu">Dokumen Akreditasi</span>
|
<span class="hide-menu">Dokumen Akreditasi</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@endif
|
||||||
{{-- AKTIVITAS --}}
|
{{-- AKTIVITAS --}}
|
||||||
<li class="nav-small-cap"><span class="hide-menu">Aktivitas</span></li>
|
<li class="nav-small-cap"><span class="hide-menu">Aktivitas</span></li>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user