update form inspeksi dan so bisa ambil alih

This commit is contained in:
majid76
2024-11-28 11:16:45 +07:00
parent b7a60abd3e
commit a2c7df7af3
18 changed files with 1712 additions and 1269 deletions

View File

@@ -5,7 +5,20 @@
</div>
<div class="grid gap-5">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Luas Tanah</label>
<label class="form-label max-w-56">Luas Bagunan</label>
<div class="mt-2">
@if (isset($permohonan->debiture->documents))
@foreach ($permohonan->debiture->documents as $item)
@php
$luas = $item->detail;
$details = json_decode($luas[0]->details, true);
$luas_bangunan = isset($details['luas_bangunan']) ? $details['luas_bangunan'] : 'N/A';
@endphp
<p class="text-2sm text-gray-700">{{ $luas_bangunan }} m<sup>2</sup></p>
@endforeach
@endif
<div class="flex flex-wrap items-baseline w-full">
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 mt-2">
<label class="form-label flex items-center gap-3 text-nowrap">
@@ -25,15 +38,16 @@
<div id="luas_tanah_bagunan_tidak_sesuai" class="flex items-baseline gap-2"
style="{{ old('luas_tanah_bagunan_bagunan', $forminspeksi['bangunan']['luas_tanah_bagunan_bagunan'] ?? '') == 'tidak sesuai' ? '' : 'display: none;' }}">
<input type="text" name="luas_tanah_bagunan_tidak_sesuai" class="input w-full"
<input type="text"id="analisa_bangunan_tidak_sesuai" name="luas_tanah_bagunan_tidak_sesuai" class="input w-full"
placeholder="Masukan Luas Bangunan Tidak Sesuai..."
value="{{ old('luas_tanah_bagunan_tidak_sesuai', $forminspeksi['bangunan']['luas_tanah_bagunan_tidak_sesuai'] ?? '') }}">
<button type="button" class="btn btn-md btn-primary">Save</button>
<button type="button" class="btn btn-md btn-primary" onclick="updateAnalisa('analisa_bangunan')">Save</button>
</div>
</div>
<em id="error-luas_tanah_bagunan" class="alert text-danger text-sm"></em>
</div>
</div>
</div>
<!-- Jenis Bangunan -->
@@ -139,7 +153,7 @@
@if (@isset($spekKategoriBagunan))
@foreach ($spekKategoriBagunan as $item)
<div>
<input type="hidden" name="spek_kategori_bangunan[]"
<input type="hidden" name="spek_kategori_bangunan.[]"
value="{{ $item->name }}">
<label
class="form-label flex items-center gap-3 text-nowrap">{{ $item->name }}</label>
@@ -149,7 +163,7 @@
@if ($spek->spek_kategori_bangunan_id == $item->id)
<label class="form-label flex items-center gap-2.5">
<input class="checkbox"
name="spek_bangunan_{{ $item->name }}[]"
name="spek_bangunan[{{ $item->name }}][]"
type="checkbox" value="{{ $spek->name }}" />
{{ $spek->name }}
</label>
@@ -235,33 +249,39 @@
document.getElementById('addBagunan').addEventListener('click', function() {
const newDiv = spekBangunanContainer.querySelector('.spek-bangunan').cloneNode(true);
console.log('Building label');
// Clear the selected values and input fields of the cloned input fields
newDiv.querySelectorAll('select, input').forEach(input => {
// Update input fields
newDiv.querySelectorAll('select, input').forEach((input, index) => {
if (input.type === 'checkbox' || input.type === 'radio') {
input.checked = false;
} else {
input.value = '';
}
// Update name attribute
if (input.name) {
const baseName = input.name.split('[')[0]; // Get the base name
const count = spekBangunanContainer.querySelectorAll('.spek-bangunan').length + 1;
input.name = `${baseName}[${count}]`;
}
});
// Append the cloned div to the container
// Append the cloned div
spekBangunanContainer.appendChild(newDiv);
// Add event listener to the delete button in the cloned div
newDiv.querySelector('.delete-button').addEventListener('click', function() {
spekBangunanContainer.removeChild(newDiv);
updateDeleteButtonsVisibility();
updateBuildingLabels(); // Update the labels after removing
console.log('Building label');
updateBuildingLabels();
});
// Update delete buttons visibility and labels
// Update UI
updateDeleteButtonsVisibility();
updateBuildingLabels();
console.log('Building label');
});
// Initial setup: Ensure "Bangunan 1" is labeled
document.addEventListener('DOMContentLoaded', () => {
updateDeleteButtonsVisibility();