refactor: Delete tabs and combine into one page, add status filter

main-dlh
Regiaaaaaa 2025-11-26 15:14:53 +07:00
parent 0f8b77005b
commit 45b7d3fc25
5 changed files with 57 additions and 176 deletions

View File

@ -11,7 +11,7 @@ namespace BpsRwApp.Controllers
}
[HttpGet]
public IActionResult Table(string status = "all")
public IActionResult Table()
{
var startDate = new DateTime(2025, 1, 1);
@ -49,12 +49,6 @@ namespace BpsRwApp.Controllers
})
.ToArray();
if (status == "sudah")
data = data.Where(x => x.status.Contains("badge-success")).ToArray();
if (status == "belum")
data = data.Where(x => x.status.Contains("badge-error")).ToArray();
return Json(new { data });
}

View File

@ -2,20 +2,16 @@
ViewData["Title"] = "Checklist Harian";
}
<link href="https://cdn.jsdelivr.net/npm/tom-select@2.2.2/dist/css/tom-select.css" rel="stylesheet">
<div class="breadcrumbs text-sm">
<div class="breadcrumbs text-sm mb-4">
<ul>
<li class="text-gray-500"><a>Checklist Harian</a></li>
<li id="breadcrumb-active">Semua</li>
</ul>
</div>
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2 mt-4">
<div class="prose">
<h3 class="mb-2">Data Checklist Rumah</h3>
</div>
<div class="justify-self-end lg:self-center">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-semibold text-gray-800">Data Checklist Rumah</h2>
<div class="flex items-center gap-3">
<button class="btn rounded-full bg-white" onclick="modal_filter_checklist.showModal()">
<span class="icon icon-fill me-2">filter_list</span>
Filter
@ -23,24 +19,23 @@
</div>
</div>
<div class="h-8"></div>
<!-- Tabs -->
<div class="tabs tabs-lift">
<input type="radio" name="tab_checklist_harian" checked class="tab checked:text-white [--tab-bg:green]" aria-label="Semua" />
<div class="tab-content bg-base-100 border-base-300 p-0">
@await Html.PartialAsync("_TabIndexSemua")
</div>
<input type="radio" name="tab_checklist_harian" class="tab checked:text-white [--tab-bg:green]" aria-label="Verifikasi" />
<div class="tab-content bg-base-100 border-base-300 p-0">
@await Html.PartialAsync("_TabIndexSudahVerifikasi")
</div>
<input type="radio" name="tab_checklist_harian" class="tab checked:text-white [--tab-bg:green]" aria-label="Belum Terverifikasi" />
<div class="tab-content bg-base-100 border-base-300 p-0">
@await Html.PartialAsync("_TabIndexBelumVerifikasi")
<div class="card bg-white shadow-sm">
<div class="card-body p-0">
<table class="table w-full" id="tableChecklistHarian">
<thead>
<tr>
<th>No</th>
<th>Tanggal</th>
<th>Mudah Terurai</th>
<th>Material Daur Ulang</th>
<th>B3</th>
<th>Residu</th>
<th>Status</th>
<th>Aksi</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
@ -98,6 +93,14 @@
<option value="10">RW 10</option>
</select>
</fieldset>
<fieldset class="fieldset mt-4">
<legend class="fieldset-legend">Status</legend>
<select id="statusSelect" class="select w-full">
<option disabled selected>Pilih Status</option>
<option value="verifikasi">Verifikasi</option>
<option value="belum">Belum Verifikasi</option>
</select>
</fieldset>
<div class="modal-action">
<button type="button" class="btn" onclick="modal_filter_checklist.close()">Bersihkan</button>
<button type="submit" class="btn btn-neutral">Terapkan Filter</button>
@ -106,14 +109,15 @@
</div>
</dialog>
@section Scripts {
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://cdn.datatables.net/2.3.4/js/dataTables.js"></script>
<script src="/plugins/datatables/dataTables.tailwindcss.js"></script>
<script src="https://cdn.jsdelivr.net/npm/tom-select@2.2.2/dist/js/tom-select.complete.min.js"></script>
<script type="text/javascript">
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://cdn.datatables.net/2.3.4/js/dataTables.js"></script>
<script src="/plugins/datatables/dataTables.tailwindcss.js"></script>
<link href="https://cdn.jsdelivr.net/npm/tom-select@2.2.2/dist/css/tom-select.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/tom-select@2.2.2/dist/js/tom-select.complete.min.js"></script>
<script type="text/javascript">
var table;
$(document).ready(function () {
new TomSelect("#kelurahanSelect", {
closeAfterSelect: true,
maxItems: 1,
@ -126,82 +130,23 @@
placeholder: "Pilih RW",
});
let tableSemua = null;
let tableSudah = null;
let tableBelum = null;
function initTableSemua() {
if (tableSemua != null) return;
tableSemua = new DataTable('#tableChecklistSemua', {
ajax: '@Url.Action("Table", "ChecklistHarian")?status=semua',
scrollX: true,
autoWidth: false,
initComplete: () => $('div.dt-scroll-body thead').css('visibility', 'collapse'),
columns: [
{ data: null, render: (d,t,r,m)=> m.row+1 },
{ data: 'tanggal' },
{ data: 'mudah_terurai' },
{ data: 'material_daur_ulang' },
{ data: 'b3' },
{ data: 'residu' },
{ data: 'status' },
{ data: 'aksi' }
]
});
}
function initTableSudahVerifikasi() {
if (tableSudah != null) return;
tableSudah = new DataTable('#tableChecklistSudahVerifikasi', {
ajax: '@Url.Action("Table", "ChecklistHarian")?status=sudah',
scrollX: true,
autoWidth: false,
initComplete: () => $('div.dt-scroll-body thead').css('visibility', 'collapse'),
columns: [
{ data: null, render: (d,t,r,m)=> m.row+1 },
{ data: 'tanggal' },
{ data: 'mudah_terurai' },
{ data: 'material_daur_ulang' },
{ data: 'b3' },
{ data: 'residu' },
{ data: 'status' },
{ data: 'aksi' }
]
});
}
function initTableBelumVerifikasi() {
if (tableBelum != null) return;
tableBelum = new DataTable('#tableChecklistBelumVerifikasi', {
ajax: '@Url.Action("Table", "ChecklistHarian")?status=belum',
scrollX: true,
autoWidth: false,
initComplete: () => $('div.dt-scroll-body thead').css('visibility', 'collapse'),
columns: [
{ data: null, render: (d,t,r,m)=> m.row+1 },
{ data: 'tanggal' },
{ data: 'mudah_terurai' },
{ data: 'material_daur_ulang' },
{ data: 'b3' },
{ data: 'residu' },
{ data: 'status' },
{ data: 'aksi' }
]
});
}
document.querySelectorAll('input[name="tab_checklist_harian"]').forEach((tab, index) => {
tab.addEventListener('change', () => {
if (index === 0) initTableSemua();
if (index === 1) initTableSudahVerifikasi();
if (index === 2) initTableBelumVerifikasi();
});
table = new DataTable('#tableChecklistHarian', {
ajax: '@Url.Action("Table", "ChecklistHarian")',
scrollX: true,
autoWidth: false,
initComplete: function () {
$('div.dt-scroll-body thead').css('visibility', 'collapse');
},
columns: [
{ data: null, render: (d, t, r, m) => m.row + 1 },
{ data: 'tanggal' },
{ data: 'mudah_terurai' },
{ data: 'material_daur_ulang' },
{ data: 'b3' },
{ data: 'residu' },
{ data: 'status' },
{ data: 'aksi' }
]
});
initTableSemua();
</script>
}
});
</script>

View File

@ -1,19 +0,0 @@
<div class="card bg-base-100 rounded-none border border-base-300">
<div class="card-body p-0">
<table class="table-zebra table w-full text-sm" id="tableChecklistBelumVerifikasi">
<thead>
<tr>
<th class="w-[5%]">No</th>
<th class="w-[15%]">Tanggal</th>
<th class="w-[15%]">Mudah Terurai</th>
<th class="w-[15%]">Material Daur Ulang</th>
<th class="w-[10%]">B3</th>
<th class="w-[10%]">Residu</th>
<th class="w-[15%]">Status</th>
<th class="w-[15%] text-center">Aksi</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>

View File

@ -1,20 +0,0 @@
<div class="card bg-base-100 rounded-none border border-base-300">
<div class="card-body p-0">
<table class="table-zebra table w-full text-sm" id="tableChecklistSemua">
<thead>
<tr>
<th class="w-[5%]">No</th>
<th class="w-[15%]">Tanggal</th>
<th class="w-[15%]">Mudah Terurai</th>
<th class="w-[15%]">Material Daur Ulang</th>
<th class="w-[10%]">B3</th>
<th class="w-[10%]">Residu</th>
<th class="w-[15%]">Status</th>
<th class="w-[15%] text-center">Aksi</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>

View File

@ -1,19 +0,0 @@
<div class="card bg-base-100 rounded-none border border-base-300">
<div class="card-body p-0">
<table class="table-zebra table w-full text-sm" id="tableChecklistSudahVerifikasi">
<thead>
<tr>
<th class="w-[5%]">No</th>
<th class="w-[15%]">Tanggal</th>
<th class="w-[15%]">Mudah Terurai</th>
<th class="w-[15%]">Material Daur Ulang</th>
<th class="w-[10%]">B3</th>
<th class="w-[10%]">Residu</th>
<th class="w-[15%]">Status</th>
<th class="w-[15%] text-center">Aksi</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>