diff --git a/Controllers/DataRumahRumahController.cs b/Controllers/DataRumahRumahController.cs
index 7060f28..eb926e6 100644
--- a/Controllers/DataRumahRumahController.cs
+++ b/Controllers/DataRumahRumahController.cs
@@ -23,9 +23,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Rizky Adi",
status_rumah_memilah = "Aktif",
status_nasabah_bank_sampah = "Aktif",
- aksi = "
",
+ aksi = "",
},
new {
rt = "002",
@@ -35,9 +33,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Dewi Lestari",
status_rumah_memilah = "Aktif",
status_nasabah_bank_sampah = "Aktif",
- aksi = "",
+ aksi = "",
},
new {
rt = "003",
@@ -47,9 +43,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Fajar Setiawan",
status_rumah_memilah = "Aktif",
status_nasabah_bank_sampah = "Aktif",
- aksi = "",
+ aksi = "",
},
new {
rt = "004",
@@ -59,9 +53,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Budi Santoso",
status_rumah_memilah = "Aktif",
status_nasabah_bank_sampah = "Aktif",
- aksi = "",
+ aksi = "",
},
new {
rt = "005",
@@ -71,9 +63,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Siti Nurhaliza",
status_rumah_memilah = "Tidak Aktif",
status_nasabah_bank_sampah = "Tidak Aktif",
- aksi = "",
+ aksi = "",
},
new {
rt = "006",
@@ -83,9 +73,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Andi Prabowo",
status_rumah_memilah = "Tidak Aktif",
status_nasabah_bank_sampah = "Tidak Aktif",
- aksi = "",
+ aksi = "",
},
new {
rt = "007",
@@ -95,9 +83,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Tina Sari",
status_rumah_memilah = "Aktif",
status_nasabah_bank_sampah = "Aktif",
- aksi = "",
+ aksi = "",
},
new {
rt = "008",
@@ -107,9 +93,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Hendra Wijaya",
status_rumah_memilah = "Aktif",
status_nasabah_bank_sampah = "Aktif",
- aksi = "",
+ aksi = "",
},
new {
rt = "009",
@@ -119,9 +103,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Lina Anggraini",
status_rumah_memilah = "Aktif",
status_nasabah_bank_sampah = "Aktif",
- aksi = "",
+ aksi = "",
},
new {
rt = "010",
@@ -131,9 +113,7 @@ namespace BpsRwApp.Controllers
pemilik_rumah = "Nina Kurniawati",
status_rumah_memilah = "Aktif",
status_nasabah_bank_sampah = "Aktif",
- aksi = "",
+ aksi = "",
},
};
diff --git a/Views/DataRumahRumah/Index.cshtml b/Views/DataRumahRumah/Index.cshtml
index 9828c1f..f18e454 100644
--- a/Views/DataRumahRumah/Index.cshtml
+++ b/Views/DataRumahRumah/Index.cshtml
@@ -14,7 +14,11 @@
Rumah
-
+
+
+
+
+
+
@@ -68,11 +154,56 @@
{ data: 'pemilik_rumah' },
{ data: 'status_rumah_memilah' },
{ data: 'status_nasabah_bank_sampah' },
- { data: 'aksi' },
+ {
+ data: 'aksi',
+ orderable: false,
+ searchable: false,
+ },
],
"columnDefs": [
{ "className": "whitespace-normal", "targets": 3 }
]
});
+
+ const btnTambahRumah = document.getElementById('btn-tambah-rumah');
+ const formCreateRumah = document.getElementById('form-create-rumah');
+ const formEditRumah = document.getElementById('form-edit-rumah');
+ const editRtInput = document.getElementById('edit-rt');
+ const editNamaPemilikInput = document.getElementById('edit-nama-pemilik');
+ const editAlamatInput = document.getElementById('edit-alamat');
+ const modalCreateElement = document.getElementById('modal_create');
+ const modalEditElement = document.getElementById('modal_edit');
+
+ window.modal_create = modalCreateElement;
+ window.modal_edit = modalEditElement;
+
+ btnTambahRumah?.addEventListener('click', () => {
+ formCreateRumah?.reset();
+ modalCreateElement?.showModal();
+ });
+
+ formCreateRumah?.addEventListener('submit', (event) => {
+ event.preventDefault();
+ modalCreateElement?.close();
+ });
+
+ formEditRumah?.addEventListener('submit', (event) => {
+ event.preventDefault();
+ modalEditElement?.close();
+ });
+
+ $('#example').on('click', '.btn-edit-rumah', function () {
+ const rowData = table.row($(this).closest('tr')).data();
+
+ if (!rowData) {
+ return;
+ }
+
+ editRtInput.value = rowData.rt ?? '';
+ editNamaPemilikInput.value = rowData.pemilik_rumah ?? '';
+ editAlamatInput.value = rowData.alamat ?? '';
+
+ modalEditElement?.showModal();
+ });
});
-
+
\ No newline at end of file