feat: create input page and with checkbox, adding add button
parent
5b3c7eb55d
commit
6d27a03e78
|
|
@ -80,5 +80,26 @@ namespace BpsRwApp.Controllers
|
||||||
|
|
||||||
return Json(new { data });
|
return Json(new { data });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Input()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult InputTable()
|
||||||
|
{
|
||||||
|
var data = Enumerable.Range(1, 10)
|
||||||
|
.Select(i => new
|
||||||
|
{
|
||||||
|
no = i,
|
||||||
|
alamat_rumah = $"Jalan Buah No. {10 + i}",
|
||||||
|
rw = (3 + i).ToString("D2")
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return Json(new { data });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,13 @@
|
||||||
<div class="flex items-center justify-between mb-6">
|
<div class="flex items-center justify-between mb-6">
|
||||||
<h2 class="text-xl font-semibold text-gray-800">Data Checklist Rumah</h2>
|
<h2 class="text-xl font-semibold text-gray-800">Data Checklist Rumah</h2>
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-primary rounded-full text-white border-0"
|
||||||
|
onclick="window.location='/ChecklistHarian/Input'">
|
||||||
|
<span class="icon icon-fill me-2">add</span>
|
||||||
|
Tambah
|
||||||
|
</button>
|
||||||
|
|
||||||
<button class="btn rounded-full bg-white" onclick="modal_filter_checklist.showModal()">
|
<button class="btn rounded-full bg-white" onclick="modal_filter_checklist.showModal()">
|
||||||
<span class="icon icon-fill me-2">filter_list</span>
|
<span class="icon icon-fill me-2">filter_list</span>
|
||||||
Filter
|
Filter
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,197 @@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Input Checklist Rumah";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="flex items-center gap-2 text-sm mb-6">
|
||||||
|
<span class="text-gray-600">Checklist Harian</span>
|
||||||
|
<span class="text-gray-400">›</span>
|
||||||
|
<span class="font-medium">Input</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-between items-center mb-6">
|
||||||
|
<h2 class="text-2xl font-semibold">Input Checklist Rumah</h2>
|
||||||
|
<a href="/ChecklistHarian/Index" class="btn bg-white hover:bg-gray-50 rounded-full border border-gray-200">
|
||||||
|
<span class="icon">arrow_back</span>
|
||||||
|
Kembali
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap items-center gap-6 mb-6">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<label class="text-sm font-medium text-gray-700">Tanggal :</label>
|
||||||
|
<input type="date" class="input input-bordered rounded-lg px-4 py-2" id="tanggalInput" style="width: 180px;" />
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<label class="text-sm font-medium text-gray-700">RW :</label>
|
||||||
|
<select class="select select-bordered rounded-lg px-4 py-2" id="rwInput" style="width: 120px;">
|
||||||
|
<option value="">Pilih RW</option>
|
||||||
|
@for (int i = 1; i <= 10; i++)
|
||||||
|
{
|
||||||
|
<option>@i.ToString("D2")</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card bg-white shadow-sm rounded-xl">
|
||||||
|
<div class="card-body p-0">
|
||||||
|
<table class="table w-full" id="inputChecklistTable">
|
||||||
|
<thead class="bg-gray-50">
|
||||||
|
<tr>
|
||||||
|
<th>No</th>
|
||||||
|
<th>Alamat Rumah</th>
|
||||||
|
<th>RW</th>
|
||||||
|
<th>Mudah Terurai</th>
|
||||||
|
<th>Material Daur</th>
|
||||||
|
<th>B3</th>
|
||||||
|
<th>Residu</th>
|
||||||
|
<th>Photo</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Upload Modal -->
|
||||||
|
<dialog id="modalUpload" class="modal modal-bottom sm:modal-middle">
|
||||||
|
<div class="modal-box w-full sm:max-w-md">
|
||||||
|
|
||||||
|
<div class="flex items-start justify-between">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-lg font-semibold">Upload Kegiatan</h3>
|
||||||
|
<p class="text-sm text-gray-500">Unggah foto dokumentasi kegiatan harian.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="dialog">
|
||||||
|
<button type="submit" class="btn btn-sm btn-circle btn-ghost">✕</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-6">
|
||||||
|
<div class="flex justify-center mb-6">
|
||||||
|
<img src="/images/clean.png" class="w-52" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<fieldset class="fieldset w-full">
|
||||||
|
<input type="file" id="fileDokumentasi" class="file-input w-full" accept="image/*" />
|
||||||
|
<span class="text-xs text-gray-500 mt-1 block">
|
||||||
|
Ukuran foto maksimal 600KB
|
||||||
|
</span>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-action">
|
||||||
|
<button type="button" class="btn rounded-full" onclick="modalUpload.close()">
|
||||||
|
<span class="icon me-1">close</span>
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button id="BtnSimpanKegiatan" class="btn btn-primary rounded-full text-white">
|
||||||
|
<span class="icon me-1">save</span>
|
||||||
|
Simpan
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
|
||||||
|
<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/sweetalert2@11"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function () {
|
||||||
|
let table = new DataTable('#inputChecklistTable', {
|
||||||
|
ajax: '@Url.Action("InputTable","ChecklistHarian")',
|
||||||
|
scrollX: true,
|
||||||
|
autoWidth: false,
|
||||||
|
pageLength: 10,
|
||||||
|
initComplete: function () {
|
||||||
|
$('div.dt-scroll-body thead').css('visibility', 'collapse');
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{ data: 'no' },
|
||||||
|
{ data: 'alamat_rumah' },
|
||||||
|
{ data: 'rw' },
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
render: () => `<input type="checkbox" class="chk-field checkbox checkbox-success checked:text-white" />`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
render: () => `<input type="checkbox" class="chk-field checkbox checkbox-success checked:text-white" />`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
render: () => `<input type="checkbox" class="chk-field checkbox checkbox-success checked:text-white" />`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
render: () => `<input type="checkbox" class="chk-field checkbox checkbox-success checked:text-white" />`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
render: () => `
|
||||||
|
<button class="btn btn-sm rounded-full btn-upload bg-gray-200 text-gray-500" disabled>
|
||||||
|
Upload
|
||||||
|
</button>`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("change", ".chk-field", function () {
|
||||||
|
const row = $(this).closest("tr");
|
||||||
|
const checked = row.find(".chk-field:checked").length > 0;
|
||||||
|
const btn = row.find(".btn-upload");
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
btn.prop("disabled", false)
|
||||||
|
.removeClass("bg-gray-200 text-gray-500")
|
||||||
|
.addClass("bg-white text-gray-700");
|
||||||
|
} else {
|
||||||
|
btn.prop("disabled", true)
|
||||||
|
.removeClass("bg-white text-gray-700")
|
||||||
|
.addClass("bg-gray-200 text-gray-500");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("click", ".btn-upload", function () {
|
||||||
|
if (!$(this).prop("disabled")) {
|
||||||
|
modalUpload.showModal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#BtnSimpanKegiatan').on('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
modalUpload.close();
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Upload Foto Kegiatan?',
|
||||||
|
text: "Pastikan foto sudah sesuai.",
|
||||||
|
icon: 'question',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: '#22c55e',
|
||||||
|
cancelButtonColor: '#6b7280',
|
||||||
|
confirmButtonText: 'Upload',
|
||||||
|
cancelButtonText: 'Batal'
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Berhasil!',
|
||||||
|
text: 'Foto kegiatan berhasil diupload.',
|
||||||
|
icon: 'success',
|
||||||
|
confirmButtonText: 'OK',
|
||||||
|
confirmButtonColor: '#22c55e'
|
||||||
|
});
|
||||||
|
document.getElementById('fileDokumentasi').value = '';
|
||||||
|
} else {
|
||||||
|
modalUpload.showModal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Loading…
Reference in New Issue