add status spatial plannings
This commit is contained in:
@@ -9,6 +9,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
if (!saveButton || !form) return;
|
||||
|
||||
// Initialize is_terbit toggle
|
||||
initIsTerbitToggle();
|
||||
|
||||
saveButton.addEventListener("click", function () {
|
||||
// Disable tombol dan tampilkan spinner
|
||||
modalButton.disabled = true;
|
||||
@@ -29,6 +32,12 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
data[key] = value;
|
||||
});
|
||||
|
||||
// Handle checkbox properly - ensure boolean value is sent
|
||||
const isTerbitCheckbox = document.getElementById("is_terbit");
|
||||
if (isTerbitCheckbox) {
|
||||
data["is_terbit"] = isTerbitCheckbox.checked ? 1 : 0;
|
||||
}
|
||||
|
||||
const url = form.getAttribute("action");
|
||||
|
||||
const method = isEdit ? "PUT" : "POST";
|
||||
@@ -183,4 +192,29 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
document.querySelector(".btn-back").addEventListener("click", function () {
|
||||
window.history.back();
|
||||
});
|
||||
|
||||
// Function to handle is_terbit toggle
|
||||
function initIsTerbitToggle() {
|
||||
const checkbox = document.getElementById("is_terbit");
|
||||
const statusText = document.querySelector(".status-text");
|
||||
const statusDescription = statusText?.nextElementSibling;
|
||||
|
||||
if (checkbox && statusText) {
|
||||
checkbox.addEventListener("change", function () {
|
||||
if (this.checked) {
|
||||
statusText.textContent = "Sudah Terbit";
|
||||
if (statusDescription) {
|
||||
statusDescription.textContent =
|
||||
"Status PBG sudah diterbitkan";
|
||||
}
|
||||
} else {
|
||||
statusText.textContent = "Belum Terbit";
|
||||
if (statusDescription) {
|
||||
statusDescription.textContent =
|
||||
"Status PBG belum diterbitkan";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user