tambahan satuan luas di denah

This commit is contained in:
majid
2025-02-13 13:40:30 +07:00
parent 90249b83e1
commit 5a4c8ab3a4
2 changed files with 42 additions and 7 deletions

View File

@@ -20,7 +20,7 @@
<div class="card-header bg-agi-50">
<h3 class="card-title">Denah</h3>
<div class="flex items-center gap-2">
<a href="{{ route('surveyor.show', ['id' => $permohonan->id ]) }}?form=denah" class="btn btn-xs btn-info">
<a href="{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=denah" class="btn btn-xs btn-info">
<i class="ki-filled ki-exit-left"></i> Back
</a>
</div>
@@ -98,7 +98,7 @@
</label>
<input type="text" name="luas_denah[]"
class="input w-full number-format"
value="{{ $denah['luas_denah'] ?? '' }}"
value="{{ isset($denah['luas_denah']) ? $denah['luas_denah'] . ' m²' : '' }}"
onkeyup="formatNumber(this)">
</div>
</div>
@@ -191,14 +191,34 @@
input.addEventListener('input', function() {
formatNumber(this);
});
input.addEventListener('focus', function() {
if (this.value === 'm²') {
this.setSelectionRange(0, 0); // Kursor di awal
}
});
});
// Tambah Denah
document.getElementById('tambahDenah').addEventListener('click', function() {
const denahContainer = document.getElementById('denah-container');
const newDenah = createDenahElement(denahIndex);
denahContainer.appendChild(newDenah);
denahIndex++;
const newInputs = newDenah.querySelectorAll('.number-format');
newInputs.forEach(input => {
input.addEventListener('input', function() {
formatNumber(this);
});
input.addEventListener('focus', function() {
if (this.value === 'm²') {
this.setSelectionRange(0, 0); // Kursor di awal
}
});
});
});
// Event delegation untuk tombol hapus denah
@@ -303,6 +323,12 @@
function submitDenah() {
showLoadingSwal('Mengirim data ke server...');
document.querySelectorAll('.number-format').forEach(input => {
if (input.value.includes('m²')) {
input.value = input.value.replace('m²', '').trim();
}
});
const formElement = $('#formDenah')[0];
const formData = new FormData(formElement);