feat(KategoriSampah) : add field jenis sampah and column jenis_sampah
parent
0f97fb9c14
commit
566986bf68
|
|
@ -47,6 +47,22 @@ namespace BankSampahApp.Controllers.Master
|
||||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
"</div>",
|
"</div>",
|
||||||
},
|
},
|
||||||
|
new {
|
||||||
|
nama = "Sisa Makanan",
|
||||||
|
jenis_sampah = "Organik",
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
},
|
||||||
|
new {
|
||||||
|
nama = "Baterai Bekas",
|
||||||
|
jenis_sampah = "B3 Sampah Rumah Tangga",
|
||||||
|
aksi = "<div class=\"flex gap-2\">" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||||
|
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||||
|
"</div>",
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var response = new
|
var response = new
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,18 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<fieldset class="fieldset">
|
||||||
|
<legend class="fieldset-legend">
|
||||||
|
Jenis Sampah
|
||||||
|
<span class="text-red-500">*</span>
|
||||||
|
</legend>
|
||||||
|
<select id="jenis_sampah" class="select w-full" required>
|
||||||
|
<option value="" disabled selected>Pilih Jenis Sampah</option>
|
||||||
|
</select>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Buttons -->
|
<!-- Buttons -->
|
||||||
<div class="flex flex-col sm:flex-row gap-3 justify-end">
|
<div class="flex flex-col sm:flex-row gap-3 justify-end">
|
||||||
<button type="button" class="px-8 py-2.5 bg-white rounded-full outline outline-1 -outline-offset-1 outline-gray-300 text-slate-800 text-base font-semibold font-['Plus_Jakarta_Sans'] leading-6 hover:bg-gray-50 w-full sm:w-auto" onclick="closeModal()">
|
<button type="button" class="px-8 py-2.5 bg-white rounded-full outline outline-1 -outline-offset-1 outline-gray-300 text-slate-800 text-base font-semibold font-['Plus_Jakarta_Sans'] leading-6 hover:bg-gray-50 w-full sm:w-auto" onclick="closeModal()">
|
||||||
|
|
@ -62,7 +74,8 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-[5%]">No</th>
|
<th class="w-[5%]">No</th>
|
||||||
<th class="w-[85%]">Nama Kategori Sampah</th>
|
<th class="w-[60%]">Nama Kategori Sampah</th>
|
||||||
|
<th class="w-[25%]">Jenis Sampah</th>
|
||||||
<th class="w-[10%]">Aksi</th>
|
<th class="w-[10%]">Aksi</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
@ -88,6 +101,7 @@
|
||||||
columns: [
|
columns: [
|
||||||
{ data: null, render: (d, t, r, m) => m.row + 1, orderable: false, searchable: false },
|
{ data: null, render: (d, t, r, m) => m.row + 1, orderable: false, searchable: false },
|
||||||
{ data: 'nama' },
|
{ data: 'nama' },
|
||||||
|
{ data: 'jenis_sampah' },
|
||||||
{ data: 'aksi' },
|
{ data: 'aksi' },
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
@ -145,6 +159,33 @@
|
||||||
// Open modal
|
// Open modal
|
||||||
modal_tambah.showModal();
|
modal_tambah.showModal();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get data for jenis sampah select
|
||||||
|
$.ajax({
|
||||||
|
url: '/Master/JenisSampah/table', // Ganti sesuai endpoint kamu
|
||||||
|
method: 'GET',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function (response) {
|
||||||
|
var dropdown = $('#jenis_sampah');
|
||||||
|
|
||||||
|
// Hapus placeholder lama
|
||||||
|
dropdown.empty();
|
||||||
|
dropdown.append('<option value="" disabled selected>Pilih Jenis Sampah</option>');
|
||||||
|
|
||||||
|
// Tambahkan item dari API
|
||||||
|
$.each(response, function (index, item) {
|
||||||
|
dropdown.append(
|
||||||
|
$('<option>', {
|
||||||
|
value: item.nama,
|
||||||
|
text: item.nama
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
console.error('Gagal memuat data jenis sampah.');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue