done next -> testing

This commit is contained in:
JokoPrasetio 2026-01-26 16:05:39 +07:00
parent de1216c5f5
commit 21012d38c3
8 changed files with 392 additions and 68 deletions

View File

@ -25,6 +25,7 @@ class DashboardController extends Controller
public function index(){
$katDok = MasterKategori::where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get();
$klasifikasiDok = MasterKlasifikasi::where('statusenabled', true)->select('master_klasifikasi_directory_id', 'nama_klasifikasi_directory')->get();
$prefillFilter = session()->pull('dashboard_prefill');
$authMapping = auth()->user()?->dataUser?->mappingUnitKerjaPegawai[0];
$authUnitKerja = $authMapping->objectunitkerjapegawaifk;
@ -37,13 +38,37 @@ class DashboardController extends Controller
'klasifikasiDok' => $klasifikasiDok,
'authUnitKerja' => $authUnitKerja,
'authSubUnitKerja' => $authSubUnitKerja,
'allAkses' => $allAkses ?? null
'allAkses' => $allAkses ?? null,
'prefillFilter' => $prefillFilter
];
return view('dashboard.index', $payload);
}
public function setDashboardPrefill(Request $request)
{
$payload = [
'unitId' => (string) $request->input('unitId', ''),
'subId' => (string) $request->input('subId', ''),
'kategoriId' => (string) $request->input('kategoriId', ''),
'unitName' => (string) $request->input('unitName', ''),
'subName' => (string) $request->input('subName', ''),
'kategoriName' => (string) $request->input('kategoriName', ''),
];
session(['dashboard_prefill' => $payload]);
return response()->json([
'status' => true,
'message' => 'Prefill disimpan'
]);
}
public function dataUnitKerja(){
$user = auth()->user()?->dataUser;
$entryPegawaiId = auth()->user()?->objectpegawaifk;
$authMapping = $user?->mappingUnitKerjaPegawai[0] ?? null;
$authUnit = $authMapping?->objectunitkerjapegawaifk;
$authSub = $authMapping?->objectsubunitkerjapegawaifk;
$akses = AksesFile::where(['pegawai_id' => $user->id, 'statusenabled' => true])->first();
$aksesAll = $akses?->akses ?? $akses?->all_akses ?? false;
$detailUnitIds = collect();
@ -62,6 +87,11 @@ class DashboardController extends Controller
$allowedUnitIds = collect([$akses->unit_akses]);
}
}
$limitPrivateToSubUnit = false;
if (!$aksesAll && !$allowedUnitIds && $authUnit) {
$allowedUnitIds = collect([$authUnit]);
$limitPrivateToSubUnit = true;
}
$kategori = request('kategori');
$filterUnit = request('unitKerja');
@ -70,28 +100,61 @@ class DashboardController extends Controller
$subArray = $subUnit ? explode(',', $subUnit) : [];
$katArray = $kategori ? explode(',', $kategori) : [];
$katDok = MasterKategori::when($katArray, fn($q) => $q->whereIn('master_kategori_directory_id', $katArray))->where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get();
$applyFileFilters = function ($q) use ($keyword, $katArray, $subArray, $entryPegawaiId) {
$q->where(function($subQuery) use ($entryPegawaiId){
$subQuery->where('status_action', '!=', 'rejected')
->orWhere(function ($pending) use ($entryPegawaiId) {
$pending->whereNull('status_action')
->where('pegawai_id_entry', $entryPegawaiId);
});
})
->when($subArray, fn($sq) => $sq->whereIn('id_sub_unit_kerja', $subArray))
->when($katArray, fn($sq) => $sq->whereIn('master_kategori_directory_id', $katArray))
->when($keyword, fn($sq) =>
$sq->where(function ($query) use ($keyword) {
$query->where('file', 'ilike', "%{$keyword}%");
})
);
};
$applyAccessFilter = function ($q) use ($aksesAll, $allowedUnitIds, $limitPrivateToSubUnit, $authSub) {
if ($aksesAll) {
return;
}
$hasPrivateScope = ($allowedUnitIds && $allowedUnitIds->isNotEmpty())
|| ($limitPrivateToSubUnit && $authSub);
$q->where(function ($query) use ($allowedUnitIds, $limitPrivateToSubUnit, $authSub, $hasPrivateScope) {
$query->where('permission_file', true);
if ($hasPrivateScope) {
$query->orWhere(function ($sub) use ($allowedUnitIds, $limitPrivateToSubUnit, $authSub) {
$sub->where('permission_file', false);
if ($allowedUnitIds && $allowedUnitIds->isNotEmpty()) {
$sub->whereIn('id_unit_kerja', $allowedUnitIds);
}
if ($limitPrivateToSubUnit && $authSub) {
$sub->where('id_sub_unit_kerja', $authSub);
}
});
}
});
};
$applyFileQuery = function ($q) use ($applyFileFilters, $applyAccessFilter) {
$applyFileFilters($q);
$applyAccessFilter($q);
};
if ($katArray && $filterUnit && $subArray) {
/* mode pencarian lengkap */
if ($allowedUnitIds && !$allowedUnitIds->contains((int) $filterUnit)) {
$unitKerja = collect();
} else {
$unitKerja = UnitKerja::where('statusenabled', true)
->where('id', $filterUnit)
->with(['subUnitKerja' => fn($q) => $q->whereIn('id', $subArray)
->with(['fileDirectory' => fn($q) => $q
->where('id_unit_kerja', $filterUnit)->whereNotNull('status_action')
->when($subArray, fn($q) => $q->whereIn('id_sub_unit_kerja', $subArray))
->when($katArray, fn($q) => $q->whereIn('master_kategori_directory_id', $katArray))
->when($keyword, fn($q) =>
$q->where(function($query) use ($keyword) {
$query->where('file', 'ilike', "%{$keyword}%");
})
)
])
->whereHas('fileDirectory', fn($f) => $applyFileQuery($f))
->with(['fileDirectory' => fn($f) => $applyFileQuery($f)])
])
->select('id', 'name')
->get();
}
} elseif ($aksesAll) {
/* all akses */
@ -107,33 +170,36 @@ class DashboardController extends Controller
} elseif ($allowedUnitIds) {
$unitKerja = UnitKerja::where('statusenabled', true)
->whereIn('id', $allowedUnitIds)
->where(function ($q) use ($allowedUnitIds, $applyFileQuery) {
if ($allowedUnitIds && $allowedUnitIds->isNotEmpty()) {
$q->whereIn('id', $allowedUnitIds);
}
$q->orWhereHas('subUnitKerja.fileDirectory', fn($f) => $applyFileQuery($f));
})
->with([
'subUnitKerja' => fn($q) => $q->with([
'fileDirectory' => fn($f) => $f->whereNotNull('status_action')->when($keyword, fn($q) =>
$q->where(function($query) use ($keyword) {
$query->where('file', 'ilike', "%{$keyword}%");
})
)
])
'subUnitKerja' => fn($q) => $q->whereHas('fileDirectory', fn($f) => $applyFileQuery($f))
->with(['fileDirectory' => fn($f) => $applyFileQuery($f)])
])
->select('id', 'name')
->get();
} else {
$authUnit = $user?->mappingUnitKerjaPegawai[0]?->objectunitkerjapegawaifk;
$authSub = $user?->mappingUnitKerjaPegawai[0]?->objectsubunitkerjapegawaifk;
$unitKerja = UnitKerja::where('statusenabled', true)
->where('id', $authUnit)
->where(function ($q) use ($authUnit, $applyFileQuery) {
if ($authUnit) {
$q->where('id', $authUnit);
}
$q->orWhereHas('subUnitKerja.fileDirectory', fn($f) => $applyFileQuery($f));
})
->with([ // 1. sub-unit milik user
'subUnitKerja' => fn($q) => $q->where('id', $authSub)
'subUnitKerja' => fn($q) => $q->where(function ($sq) use ($authSub, $applyFileQuery) {
if ($authSub) {
$sq->where('id', $authSub);
}
$sq->orWhereHas('fileDirectory', fn($f) => $applyFileQuery($f));
})
->with([ // 2. file-directory + filter keyword
'fileDirectory' => fn($f) => $f->whereNotNull('status_action')->when($keyword, fn($q) =>
$q->where(function($query) use ($keyword) {
$query->where('file', 'ilike', "%{$keyword}%");
})
)
'fileDirectory' => fn($f) => $applyFileQuery($f)
])
])
->select('id', 'name')
@ -295,7 +361,7 @@ class DashboardController extends Controller
$paths = [];
foreach ($rows as $r) {
if(!empty($r['sub_unit_id'])){
$files = FileDirectory::where('id_sub_unit_kerja', $r['sub_unit_id'])->where('statusenabled', true)->pluck('file');
$files = FileDirectory::where('id_sub_unit_kerja', $r['sub_unit_id'])->where('statusenabled', true)->where('status_action', 'approved')->pluck('file');
$paths = array_merge($paths, $files->toArray());
}
@ -340,9 +406,9 @@ class DashboardController extends Controller
$type = request('type');
if($type === "unit"){
$data = FileDirectory::where('id_unit_kerja', $id)->where('statusenabled', true)->pluck('file');
$data = FileDirectory::where('id_unit_kerja', $id)->where('statusenabled', true)->where('status_action', 'approved')->pluck('file');
}else{
$data = FileDirectory::where('id_sub_unit_kerja', $id)->where('statusenabled', true)->pluck('file');
$data = FileDirectory::where('id_sub_unit_kerja', $id)->where('statusenabled', true)->where('status_action', 'approved')->pluck('file');
}
if (empty($data)) {
return response()->json(['message' => 'File tidak ditemukan'], 404);
@ -393,11 +459,18 @@ class DashboardController extends Controller
$perPage = (int) request('per_page', 10);
$authUnitId = auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]?->objectunitkerjapegawaifk;
$user = auth()->user()?->dataUser;
$entryPegawaiId = auth()->user()?->objectpegawaifk;
$akses = AksesFile::where(['pegawai_id' => $user->id, 'statusenabled' => true])->first();
$keyword = request('keyword');
$query = FileDirectory::where('statusenabled', true)->whereNotNull('status_action')
->when($keyword, function ($q) use ($keyword) {
$query = FileDirectory::where('statusenabled', true)
->where(function($subQuery) use ($entryPegawaiId){
$subQuery->where('status_action', '!=', 'rejected')
->orWhere(function ($pending) use ($entryPegawaiId) {
$pending->whereNull('status_action')
->where('pegawai_id_entry', $entryPegawaiId);
});
})->when($keyword, function ($q) use ($keyword) {
$q->where(function ($sub) use ($keyword) {
$sub->where('file', 'ILIKE', "%{$keyword}%")
->orWhere('no_dokumen', 'ILIKE', "%{$keyword}%");
@ -749,7 +822,10 @@ class DashboardController extends Controller
$end = request('end_date');
$authUnit = auth()->user()->masterPersetujuan->details->pluck('unit_pegawai_id')->unique()->toArray();
$query = FileDirectory::where('statusenabled', true)->whereNull('status_action')->whereIn('id_unit_kerja', $authUnit)->orderBy('entry_at','desc');
$query = FileDirectory::where('statusenabled', true)->where(function($q){
$q->where('status_action', '!=', 'approved')
->orWhereNull('status_action');
})->whereIn('id_unit_kerja', $authUnit)->orderBy('entry_at','desc');
if($keyword){
$query->where(function($q) use ($keyword){
$q->where('file', 'ILIKE', "%{$keyword}%")
@ -777,6 +853,7 @@ class DashboardController extends Controller
'entry_at' => $item->entry_at,
'tanggal_terbit' => $item->tanggal_terbit,
'permission_file' => $item->permission_file,
'status_action' => $item->status_action
];
});
return response()->json([

View File

@ -47,11 +47,16 @@ $(document).ready(function() {
loadSubUnitKerja(initialUnit);
}
let prefillSubIds = [];
let prefillSubMeta = {};
// jalankan setiap kali unit_kerja berubah
$('.unit_kerja').on('change', function(){
let idUnit = $(this).val();
if(idUnit){
loadSubUnitKerja(idUnit);
loadSubUnitKerja(idUnit, prefillSubIds, prefillSubMeta);
prefillSubIds = [];
prefillSubMeta = {};
}
});
@ -62,9 +67,67 @@ $(document).ready(function() {
}else{
selectOptionUnitKerjaV2(0);
}
if (window.__folderPrefillApplied) return;
const urlParams = new URLSearchParams(window.location.search);
const prefill = window.__prefillFromSession || null;
const unitId = prefill?.unitId || urlParams.get('unitKerja');
const subParam = prefill?.subId || urlParams.get('subUnit');
const katParam = prefill?.kategoriId || urlParams.get('kategori');
const unitName = prefill?.unitName || urlParams.get('unitName');
const subName = prefill?.subName || urlParams.get('subName');
const kategoriName = prefill?.kategoriName || urlParams.get('kategoriName');
let prefillSubIdsFinal = [];
let prefillKatIdsFinal = [];
if (unitId) {
window.__folderPrefillApplied = true;
window.__prefillFromSession = null;
$('.unit_kerja').val(null).trigger('change');
$('.sub_unit_kerja').val(null).trigger('change');
$('.kategori_dok').val(null).trigger('change');
const unitLabel = unitName || unitId;
const unitOption = new Option(unitLabel, unitId, true, true);
const selectedSubIds = subParam ? Array.from(new Set(subParam.split(',').filter(Boolean))) : [];
const subNames = subName ? subName.split(',').map(s => s.trim()).filter(Boolean) : [];
prefillSubIds = selectedSubIds;
prefillSubMeta = selectedSubIds.reduce((acc, id, idx) => {
let label = subNames[idx] || subNames[0] || id;
label = label.replace(/^\d+\s*\/\s*/, '');
acc[id] = label;
return acc;
}, {});
$('.unit_kerja').append(unitOption).trigger('change');
if (selectedSubIds.length) {
$('.sub_unit_kerja').val(selectedSubIds).trigger('change');
}
prefillSubIdsFinal = selectedSubIds;
}
if (katParam) {
const katIds = Array.from(new Set(katParam.split(',').filter(Boolean)));
if (katIds.length) {
$('.kategori_dok').val(katIds).trigger('change');
prefillKatIdsFinal = katIds;
} else if (kategoriName) {
const katOption = new Option(kategoriName, katParam, true, true);
$('.kategori_dok').append(katOption).trigger('change');
prefillKatIdsFinal = katParam ? [katParam] : [];
}
}
if ((unitId || subParam || katParam) && typeof index === 'function') {
index(prefillKatIdsFinal, unitId, prefillSubIdsFinal, '');
}
});
function loadSubUnitKerja(unitId){
function loadSubUnitKerja(unitId, selectedSubIds = [], selectedSubMeta = {}){
$('.sub_unit_kerja').empty().append('<option value="" disabled>-- Pilih Sub Unit Kerja --</option>');
$.ajax({
@ -73,10 +136,24 @@ function loadSubUnitKerja(unitId){
success: function(response) {
if (response?.data) {
response.data.forEach(unit => {
let selected = (authSubUnitKerja && unit.id === authSubUnitKerja.objectsubunitkerjapegawaifk);
let selected = false;
if (selectedSubIds.length) {
selected = selectedSubIds.includes(String(unit.id));
} else if (authSubUnitKerja) {
selected = unit.id === authSubUnitKerja.objectsubunitkerjapegawaifk;
}
const option = new Option(unit.name, unit.id, false, selected);
$('.sub_unit_kerja').append(option);
});
if (selectedSubIds.length) {
selectedSubIds.forEach(id => {
if ($(`.sub_unit_kerja option[value="${id}"]`).length === 0) {
const label = selectedSubMeta[id] || id;
const opt = new Option(label, id, false, true);
$('.sub_unit_kerja').append(opt);
}
});
}
$('.sub_unit_kerja').trigger('change');
}
}
@ -321,4 +398,3 @@ function selectOptionUnitKerjaV2(colCount) {
}
});
}

View File

@ -10,9 +10,18 @@ function renderTree(units, katDok, keyword) {
<li class="file-tree-li folder">
<input class="form-check-input" type="checkbox" data-select="unit" data-unit_id="${el?.id}">
<span class="fw-bolder">📂 ${el.name}</span>
<button type="button" class="btn btn-primary btn-sm" onclick="download(this)" data-part="unit" data-id="${el?.id}">
<i class="fa-solid fa-download"></i>
</button>
<div class="dropdown d-inline ms-1">
<button type="button" class="btn btn-sm btn-link text-decoration-none folder-menu-icon dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Menu folder">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu">
<li>
<button type="button" class="dropdown-item folder-download" data-part="unit" data-id="${el?.id}">
<i class="fa-solid fa-download me-2"></i>Download
</button>
</li>
</ul>
</div>
${Array.isArray(el.sub_unit_kerja) && el.sub_unit_kerja.length > 0 ? `
<ul class="file-tree-ul mt-1 ms-2">
@ -21,9 +30,18 @@ function renderTree(units, katDok, keyword) {
\
<input class="form-check-input" type="checkbox" data-select="sub_unit" data-unit_id="${el.id}" data-sub_unit_id="${sub?.id}" >
<span class="fw-semibold">📂 ${sub.name}</span>
<button type="button" class="btn btn-outline-primary btn-sm ms-auto" onclick="download(this)" data-part="sub_unit" data-id="${sub?.id}">
<i class="fa-solid fa-download"></i>
</button>
<div class="dropdown d-inline ms-1">
<button type="button" class="btn btn-sm btn-link text-decoration-none folder-menu-icon dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Menu folder">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu">
<li>
<button type="button" class="dropdown-item folder-download" data-part="sub_unit" data-id="${sub?.id}">
<i class="fa-solid fa-download me-2"></i>Download
</button>
</li>
</ul>
</div>
${Array.isArray(katDok) && katDok.length > 0 ? `
<ul class="file-tree-ul ms-2">
@ -41,20 +59,33 @@ function renderTree(units, katDok, keyword) {
${files.map(file => {
let fileName = file.file.split('/').pop();
const isPublic = String(file.permission_file).toLowerCase() === 'true' || file.permission_file === 1 || file.permission_file === '1';
console.log(file);
let statusLabel = '';
let statusClass = '';
if (!file.status_action) {
statusLabel = 'Pending';
statusClass = 'bg-warning text-dark';
} else if (isPublic) {
statusLabel = 'Umum';
statusClass = 'bg-success';
} else {
statusLabel = 'Internal Unit';
statusClass = 'bg-secondary';
}
return `
<li class="file-tree-li">
<div class="d-flex align-items-center gap-2 flex-wrap">
<span>📄</span>
<a href="#" class="file-link"
<a href="#" class="file-link ${!file?.status_action ? 'fst-italic' :''}"
data-file="${file?.file}"
data-fileName="${fileName || '-'}"
data-id="${file.file_directory_id}"
data-no_dokumen="${file.no_dokumen || '-'}"
data-tanggal_terbit="${file.tanggal_terbit || '-'}"
data-permission_file="${file.permission_file || '-'}">${fileName}</a>
<span class="badge ${isPublic ? 'bg-success' : 'bg-secondary'}">
${isPublic ? 'Umum' : 'Internal'}
<span class="badge ${statusClass}">
${statusLabel}
</span>
</div>
</li>
@ -94,6 +125,7 @@ function index(kategori_dok = [], unitKerja = null, subUnitKerja = [], keyword =
if (Array.isArray(data?.data?.unitKerja)) {
file_tree.innerHTML = renderTree(data.data.unitKerja, data.data.katDok, keyword);
// Toggle buka/tutup folder
// Toggle buka/tutup folder
file_tree.querySelectorAll(".folder > span").forEach(span => {
span.addEventListener("click", () => {
@ -108,6 +140,7 @@ function index(kategori_dok = [], unitKerja = null, subUnitKerja = [], keyword =
}
});
});
} else {
file_tree.innerHTML = `
<p style="color: primary">
@ -120,7 +153,19 @@ function index(kategori_dok = [], unitKerja = null, subUnitKerja = [], keyword =
}
index();
const initialParams = new URLSearchParams(window.location.search);
const initialUnit = initialParams.get('unitKerja');
const initialSub = initialParams.get('subUnit');
const initialKat = initialParams.get('kategori');
const initialKeyword = initialParams.get('keyword');
const initialSubArr = initialSub ? initialSub.split(',').filter(Boolean) : [];
const initialKatArr = initialKat ? initialKat.split(',').filter(Boolean) : [];
if (initialUnit || initialSubArr.length || initialKatArr.length || initialKeyword) {
index(initialKatArr, initialUnit, initialSubArr, initialKeyword || '');
} else {
index();
}
function referesh(){
index()
@ -280,3 +325,10 @@ function downloadMultiple(){
})
}
// Klik menu download dari ikon ⋮
document.addEventListener('click', function (e) {
const btn = e.target.closest('.folder-download');
if (!btn) return;
download(btn);
});

View File

@ -54,8 +54,13 @@ document.addEventListener('DOMContentLoaded', () => {
`;
return `
<tr>
<td>${aksi}</td>
<td>${item?.status_action !== "rejected" ? aksi : ''}</td>
<td>${item.no_dokumen || '-'}</td>
<td>
<button class="btn btn-sm ${item?.status_action !== "rejected" ? 'btn-warning' : 'btn-danger'} btn-warning ">
${item?.status_action !== "rejected" ? 'Pending' : 'Rejected'}
</button>
</td>
<td><a href="#" class="file-link"
data-file="${item.file}"
data-fileName="${item.fileName}"
@ -115,7 +120,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (pageData.length === 0) {
tbody.innerHTML = `
<tr>
<td colspan="4" class="text-center text-muted py-4">
<td colspan="7" class="text-center text-muted py-4">
Tidak ada data
</td>
</tr>

View File

@ -42,6 +42,22 @@
user-select: none;
}
.folder-menu-icon {
cursor: pointer;
opacity: 0;
visibility: hidden;
padding: 0 4px;
}
.file-tree-li.folder:hover .folder-menu-icon {
opacity: 1;
visibility: visible;
}
.folder-menu-icon.dropdown-toggle::after {
display: none;
}
.collapsed > .file-tree-ul {
display: none;
}
@ -129,12 +145,11 @@
<span class="badge bg-secondary">Internal</span>
</div>
</div>
<div id="file_tree"></div>
<div id="file_tree" style="max-height: 60vh; overflow-y:auto;"></div>
</div>
</div>
</div>
</div>
</div>
@ -147,6 +162,7 @@
const allAkses = @json($allAkses);
const authUnitKerja = @json(auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]?->unitKerja);
const authSubUnitKerja = @json(auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]);
window.__prefillFromSession = @json($prefillFilter ?? null);
function isPublic(permissionVal){
if(permissionVal === null || permissionVal === undefined) return false;
const val = String(permissionVal).toLowerCase();
@ -266,10 +282,6 @@
}
});
</script>
<script src="{{ ver('/js/dashboard/_init.js') }}"></script>

View File

@ -1,4 +1,41 @@
@extends('layout.main')
<style>
.table-fixed{ table-layout: fixed; width: 100%; }
.table-fixed th:nth-child(1), .table-fixed td:nth-child(1){ width: 140px; }
.table-fixed th:nth-child(2), .table-fixed td:nth-child(2){ width: 260px; }
.table-fixed th:nth-child(3), .table-fixed td:nth-child(3){ width: 220px; }
.table-fixed th:nth-child(4), .table-fixed td:nth-child(4){ width: 120px; }
.table-fixed th:nth-child(5), .table-fixed td:nth-child(5){ width: 150px; }
.file-cell{
white-space: normal;
word-break: break-word;
overflow-wrap: anywhere;
}
.folder-cell{
max-width: 220px;
}
.folder-badge{
white-space: normal !important;
word-break: break-word;
overflow-wrap: anywhere;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
max-width: 100%;
text-align: left;
line-height: 1.3;
padding: .35rem .5rem;
}
.folder-link-sm{
font-size: 13px;
text-decoration: underline;
}
</style>
@section('body_main')
<div class="row">
<div class="col-md-12">
@ -30,8 +67,8 @@
</div>
<div class="small text-muted ms-md-auto" id="tableSummary">Memuat data...</div>
</div>
<div class="table-responsive" style="max-height: 100vh; overflow-y:auto;">
<table class="table table-sm table-hover align-middle mb-0" id="lastUpdatedTable">
<div class="table-responsive" style="max-height: 70vh; overflow-y:auto;">
<table class="table table-sm table-hover align-middle mb-0 table-fixed" id="lastUpdatedTable">
<thead>
<tr>
<th>Nomor Surat</th>
@ -100,12 +137,29 @@
const fileName = parts.pop() || '-';
const folderPath = parts.join('/') || '-';
const publicDoc = isPublic(item.permission_file);
const unitName = parts[0] || '';
const subName = parts[1] || '';
const kategoriName = parts[2] || '';
let statusLabel = '';
let statusClass = '';
if (!item.status_action) {
statusLabel = 'Pending';
statusClass = 'bg-warning text-dark';
} else if (publicDoc) {
statusLabel = 'Umum';
statusClass = 'bg-success';
} else {
statusLabel = 'Internal Unit';
statusClass = 'bg-secondary';
}
return `
<tr>
<td class="text-nowrap">${item.no_dokumen || '-'}</td>
<td>
<td class="file-cell">
<span class="me-1">📄</span>
<a href="#" class="file-link"
<a href="#" class="file-link ${statusLabel === "Pending" ? 'fst-italic' : ''}"
data-file="${item.file}"
data-fileName="${fileName}"
data-id="${item.file_directory_id}"
@ -113,10 +167,22 @@
data-tanggal_terbit="${item.tanggal_terbit || '-'}"
data-permission_file="${item.permission_file || '-'}">${fileName}</a>
</td>
<td class="text-break"><span class="badge bg-light text-dark fw-semibold">${folderPath}</span></td>
<td class="folder-cell">
<a href="#"
class="text-dark fw-semibold folder-prefill folder-link-sm ${statusLabel === "Pending" ? 'fst-italic' : ''}"
title="${folderPath}"
data-unit_id="${item.id_unit_kerja || ''}"
data-sub_id="${item.id_sub_unit_kerja || ''}"
data-kategori_id="${item.master_kategori_directory_id || ''}"
data-unit_name="${unitName}"
data-sub_name="${subName}"
data-kategori_name="${kategoriName}">
${folderPath}
</a>
</td>
<td>
<span class="badge ${publicDoc ? 'bg-success' : 'bg-secondary'}">
${publicDoc ? 'Umum' : 'Internal Unit'}
<span class="badge ${statusClass}">
${statusLabel}
</span>
</td>
<td class="text-nowrap">${formatTanggal(item.entry_at)}</td>
@ -234,6 +300,38 @@
}
fetchData()
document.addEventListener('click', function (e) {
const btn = e.target.closest('.folder-prefill');
if (!btn) return;
e.preventDefault();
const payload = {
unitId: btn.getAttribute('data-unit_id') || '',
subId: btn.getAttribute('data-sub_id') || '',
kategoriId: btn.getAttribute('data-kategori_id') || '',
unitName: btn.getAttribute('data-unit_name') || '',
subName: btn.getAttribute('data-sub_name') || '',
kategoriName: btn.getAttribute('data-kategori_name') || '',
};
fetch('/dashboard/prefill', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
'X-Requested-With': 'XMLHttpRequest'
},
body: JSON.stringify(payload)
})
.then(res => {
if (!res.ok) throw new Error('Gagal set filter');
window.location.href = '/';
})
.catch(() => {
Swal.fire({ icon: 'error', title: 'Gagal', text: 'Tidak bisa buka folder' });
});
});
let colCount = 1;
$(document).ready(function() {
$('.unit_kerja').select2({

View File

@ -44,8 +44,11 @@
<table class="table table-sm table-hover align-middle mb-0" id="lastUpdatedTable">
<thead>
<tr>
@if(auth()->user()->masterPersetujuan)
<th>Aksi</th>
@endif
<th>No Dokumen</th>
<th>Status</th>
<th>File</th>
<th>Folder</th>
<th>Unit/Sub Unit</th>

View File

@ -18,6 +18,7 @@ Route::middleware(['auth'])->group(function(){
Route::get('/file-preview/{id}', [DashboardController::class, 'dataPdf']);
Route::post('/upload', [DashboardController::class, 'store']);
Route::get('/data-unit-kerja', [DashboardController::class, 'dataUnitKerja']);
Route::post('/dashboard/prefill', [DashboardController::class, 'setDashboardPrefill']);
Route::get('/select-pegawai', [AksesFileController::class, 'optionPegawai']);
Route::get('/select-unit-kerja-option', [AksesFileController::class, 'optionUnitKerja']);