fix(surveyor) : penambahan tombol switch objek penilaian, tambah luas fisik bangunan, dan print out linkungan
This commit is contained in:
@@ -702,8 +702,8 @@
|
||||
console.log(
|
||||
'Current route matches');
|
||||
} else {
|
||||
window.location.href =
|
||||
"{{ route('surveyor.show', ['id' => $permohonan->id]) }}";
|
||||
// window.location.href =
|
||||
// "{{ route('surveyor.show', ['id' => $permohonan->id]) }}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,6 +743,75 @@
|
||||
input.value = formatCurrency(input.value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// hide the "Lihat Objek Penilaian" toggle
|
||||
const tableContainer = document.querySelector('.scrollable-x-auto');
|
||||
const toggleContainer = document.createElement('div');
|
||||
toggleContainer.className = 'flex items-center gap-4 mb-4 p-3 bg-gray-50 rounded';
|
||||
|
||||
const objekToggle = createCustomSwitch('Lihat Objek Penilaian', false, function(checked) {
|
||||
toggleColumn(1, checked);
|
||||
});
|
||||
|
||||
toggleContainer.appendChild(objekToggle);
|
||||
|
||||
tableContainer.parentNode.insertBefore(toggleContainer, tableContainer);
|
||||
|
||||
function createCustomSwitch(label, initialState, onChangeCallback) {
|
||||
const container = document.createElement('div');
|
||||
|
||||
const switchLabel = document.createElement('label');
|
||||
switchLabel.className = 'switch';
|
||||
|
||||
const input = document.createElement('input');
|
||||
input.name = "check";
|
||||
input.type = "checkbox";
|
||||
input.value = "1";
|
||||
input.checked = initialState;
|
||||
|
||||
const span = document.createElement('span');
|
||||
span.className = 'switch-label';
|
||||
span.textContent = label;
|
||||
|
||||
switchLabel.appendChild(input);
|
||||
switchLabel.appendChild(span);
|
||||
container.appendChild(switchLabel);
|
||||
|
||||
|
||||
input.addEventListener('change', function() {
|
||||
onChangeCallback(this.checked);
|
||||
});
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
function toggleColumn(columnIndex, show) {
|
||||
const table = document.getElementById('dataTable');
|
||||
const rows = table.querySelectorAll('tr');
|
||||
|
||||
rows.forEach(row => {
|
||||
|
||||
const cells = row.querySelectorAll('td, th');
|
||||
if (cells.length === 1 && cells[0].hasAttribute('colspan')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (cells[columnIndex]) {
|
||||
cells[columnIndex].style.display = show ? '' : 'none';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const headerRow = table.querySelector('thead tr');
|
||||
const headerCells = headerRow.querySelectorAll('th');
|
||||
if (headerCells[columnIndex]) {
|
||||
headerCells[columnIndex].style.display = show ? '' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
toggleColumn(1, false);
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
Reference in New Issue
Block a user