@push('styles')
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/choices.js/public/assets/styles/choices.min.css" />
<style>
.choices__list--dropdown {
z-index: 99 !important;
background-color: white !important;
}
</style>
@endpush
@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/choices.js/public/assets/scripts/choices.min.js"></script>
<script>
const provinsiIdChoice = new Choices('#provinsi_id');
const kabupatenKotaIdChoice = new Choices('#kabupaten_kota_id');
const kecamatanIdChoice = new Choices('#kecamatan_id');
const kelurahanDesaIdChoice = new Choices('#kelurahan_desa_id');
const tpsIdChoice = new Choices('#tps_id');
const dpsIdChoice = new Choices('#dps_id');
const valueProvinsiId = '{{ old('provinsi_id', @$data->provinsi_id) }}';
const valueKabupatenKotaId = '{{ old('kabupaten_kota_id', @$data->kabupaten_kota_id) }}';
const valueKecamatanId = '{{ old('kecamatan_id', @$data->kecamatan_id) }}';
const valueKelurahanDesaId = '{{ old('kelurahan_desa_id', @$data->kelurahan_desa_id) }}';
const valueTpsId = '{{ old('tps_id', @$data->tps_id) }}';
const valueDpsId = '{{ old('dps_id', @$data->dps_id) }}';
function ajaxKabupatenKota() {
document.getElementById('loading-kabupaten-kota').innerHTML = 'Loading...';
const provinsiId = document.getElementById('provinsi_id').value;
kabupatenKotaIdChoice.clearStore();
fetch(`/ajax/kabupaten-kota?provinsi_id=${provinsiId}`)
.then(response => response.json())
.then(data => {
document.getElementById('loading-kabupaten-kota').innerHTML = '.';
kabupatenKotaIdChoice.setChoices(data, 'id', 'nama', false);
if (valueKabupatenKotaId) {
kabupatenKotaIdChoice.setChoiceByValue(parseInt(valueKabupatenKotaId));
}
})
.catch(error => {
document.getElementById('loading-kabupaten-kota').innerHTML = 'Error';
});
}
function ajaxKecamatan() {
document.getElementById('loading-kecamatan').innerHTML = 'Loading...';
const kabupatenKotaId = document.getElementById('kabupaten_kota_id').value != "" ? document.getElementById('kabupaten_kota_id').value : valueKabupatenKotaId;
kecamatanIdChoice.clearStore();
fetch(`/ajax/kecamatan?kabupaten_kota_id=${kabupatenKotaId}`)
.then(response => response.json())
.then(data => {
document.getElementById('loading-kecamatan').innerHTML = '.';
kecamatanIdChoice.setChoices(data, 'id', 'nama', false);
if (valueKecamatanId) {
kecamatanIdChoice.setChoiceByValue(parseInt(valueKecamatanId));
}
})
.catch(error => {
document.getElementById('loading-kecamatan').innerHTML = 'Error';
});
}
function ajaxKelurahanDesa() {
document.getElementById('loading-kelurahan-desa').innerHTML = 'Loading...';
const kecamatanId = document.getElementById('kecamatan_id').value != "" ? document.getElementById('kecamatan_id').value : valueKecamatanId;
kelurahanDesaIdChoice.clearStore();
fetch(`/ajax/kelurahan-desa?kecamatan_id=${kecamatanId}`)
.then(response => response.json())
.then(data => {
document.getElementById('loading-kelurahan-desa').innerHTML = '.';
kelurahanDesaIdChoice.setChoices(data, 'id', 'nama', false);
if (valueKelurahanDesaId) {
kelurahanDesaIdChoice.setChoiceByValue(parseInt(valueKelurahanDesaId));
}
})
.catch(error => {
document.getElementById('loading-kelurahan-desa').innerHTML = 'Error';
});
}
function ajaxTps() {
document.getElementById('loading-tps').innerHTML = 'Loading...';
const kelurahanDesaId = document.getElementById('kelurahan_desa_id').value != "" ? document.getElementById('kelurahan_desa_id').value : valueKelurahanDesaId;
tpsIdChoice.clearStore();
fetch(`/ajax/tps?kelurahan_desa_id=${kelurahanDesaId}`)
.then(response => response.json())
.then(data => {
document.getElementById('loading-tps').innerHTML = '.';
tpsIdChoice.setChoices(data, 'id', 'nomor', false);
if (valueTpsId) {
tpsIdChoice.setChoiceByValue(parseInt(valueTpsId));
}
})
.catch(error => {
console.log(error);
document.getElementById('loading-tps').innerHTML = 'Error';
});
}
function ajaxDps(){
document.getElementById('loading-dps').innerHTML = 'Loading...';
const kelurahanDesaId = document.getElementById('kelurahan_desa_id').value != "" ? document.getElementById('kelurahan_desa_id').value : valueKelurahanDesaId;
const tpsId = document.getElementById('tps_id').value != null ? document.getElementById('tps_id').value : valueTpsId;
const dpsId = document.getElementById('dps_id');
dpsIdChoice.clearStore();
fetch(`/saksi/ajax/dps?kelurahan_desa_id=${kelurahanDesaId}&tps_id=${tpsId}`)
.then(response => response.json())
.then(data => {
document.getElementById('loading-dps').innerHTML = '.';
dpsIdChoice.setChoices(data, 'id', 'nama', false);
if (valueDpsId){
dpsIdChoice.setChoiceByValue(parseInt(valueDpsId));
}
})
.catch(error => {
document.getElementById('loading-dps').innerHTML = 'Error';
});
}
document.getElementById('provinsi_id').addEventListener('change', function() {
const provinsiId = this.value;
kabupatenKotaIdChoice.clearStore();
ajaxKabupatenKota();
});
document.getElementById('kabupaten_kota_id').addEventListener('change', ajaxKecamatan);
document.getElementById('kecamatan_id').addEventListener('change', ajaxKelurahanDesa);
document.getElementById('kelurahan_desa_id').addEventListener('change', ajaxTps);
document.getElementById('tps_id').addEventListener('change', ajaxDps);
//on page load
window.addEventListener('load', function() {
if (valueProvinsiId) {
provinsiIdChoice.setChoiceByValue(valueProvinsiId);
ajaxKabupatenKota();
}
if (valueKabupatenKotaId) {
kabupatenKotaIdChoice.setChoiceByValue(valueKabupatenKotaId);
ajaxKecamatan();
}
if (valueKecamatanId) {
kelurahanDesaIdChoice.setChoiceByValue(valueKecamatanId);
ajaxKelurahanDesa();
}
if (valueKelurahanDesaId) {
kelurahanDesaIdChoice.setChoiceByValue(valueKelurahanDesaId);
ajaxTps();
}
if (valueTpsId){
tpsIdChoice.setChoiceByValue(valueTpsId);
ajaxDps();
}
});
</script>
@endpush
<div class="grid grid-cols-1 md:grid-cols-2" x-data="{ role: 'saksi' }">
<div class="flex flex-col gap-5.5 p-6.5">
<div x-show="role !== 'admin'">
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
Provinsi
</label>
<select name="provinsi_id" id="provinsi_id"
class="relative z-20 w-full appearance-none rounded border border-stroke bg-transparent py-3 pl-5 pr-12 outline-none transition focus:border-primary active:border-primary dark:border-form-strokedark dark:bg-form-input">
<option value="">Pilih Provinsi</option>
@foreach ($provinsis as $provinsi)
<option value="{{ $provinsi->id }}" @if (old('provinsi_id', @$data->provinsi_id) == $provinsi->id) selected @endif>
{{ $provinsi->nama }}
</option>
@endforeach
</select>
@error('provinsi_id')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div x-show="!['admin','koordinator-provinsi'].includes(role)">
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
Kabupaten/Kota <small id="loading-kabupaten-kota"></small>
</label>
<select name="kabupaten_kota_id" id="kabupaten_kota_id"
class="relative z-20 w-full js-choice appearance-none rounded border border-stroke bg-transparent py-3 pl-5 pr-12 outline-none transition focus:border-primary active:border-primary dark:border-form-strokedark dark:bg-form-input">
</select>
@error('kabupaten_kota_id')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div x-show="!['admin','koordinator-provinsi','koordinator-kabupaten-kota'].includes(role)">
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
Kecamatan <small id="loading-kecamatan"></small>
</label>
<select name="kecamatan_id" id="kecamatan_id"
class="relative z-20 w-full appearance-none rounded border border-stroke bg-transparent py-3 pl-5 pr-12 outline-none transition focus:border-primary active:border-primary dark:border-form-strokedark dark:bg-form-input">
</select>
@error('kecamatan_id')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div
x-show="!['admin','koordinator-provinsi','koordinator-kabupaten-kota','koordinator-kecamatan'].includes(role)">
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
Kelurahan/Desa <small id="loading-kelurahan-desa"></small>
</label>
<select name="kelurahan_desa_id" id="kelurahan_desa_id"
class="relative z-20 w-full appearance-none rounded border border-stroke bg-transparent py-3 pl-5 pr-12 outline-none transition focus:border-primary active:border-primary dark:border-form-strokedark dark:bg-form-input">
</select>
@error('kelurahan_desa_id')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div x-show="role == 'saksi'">
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
TPS <small id="loading-tps"></small>
</label>
<select name="tps_id" id="tps_id"
class="relative z-20 w-full appearance-none rounded border border-stroke bg-transparent py-3 pl-5 pr-12 outline-none transition focus:border-primary active:border-primary dark:border-form-strokedark dark:bg-form-input">
</select>
@error('tps_id')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div x-show="role == 'saksi'">
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
DPS <small id="loading-dps"></small>
</label>
<select name="dps_id" id="dps_id"
class="relative z-20 w-full appearance-none rounded border border-stroke bg-transparent py-3 pl-5 pr-12 outline-none transition focus:border-primary active:border-primary dark:border-form-strokedark dark:bg-form-input">
</select>
@error('dps_id')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
</div>
<div class="flex flex-col gap-5.5 p-6.5">
<div>
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
No Telp
</label>
<input type="number" maxlength="20" name="no_telp" placeholder="08..."
value="{{ old('no_telp', @$data->no_telp) }}"
class="w-full rounded-lg border-[1.5px] border-stroke bg-transparent px-5 py-3 font-normal text-black outline-none transition focus:border-primary active:border-primary disabled:cursor-default disabled:bg-whiter dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-primary" />
@error('no_telp')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div>
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
No Wa
</label>
<input type="number" maxlength="20" name="no_wa" placeholder="08..."
value="{{ old('no_wa', @$data->no_wa) }}"
class="w-full rounded-lg border-[1.5px] border-stroke bg-transparent px-5 py-3 font-normal text-black outline-none transition focus:border-primary active:border-primary disabled:cursor-default disabled:bg-whiter dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-primary" />
@error('no_wa')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div>
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
Email
</label>
<input required type="email" name="email" placeholder="Email..."
value="{{ old('email', @$data->email) }}"
class="w-full rounded-lg border-[1.5px] border-stroke bg-transparent px-5 py-3 font-normal text-black outline-none transition focus:border-primary active:border-primary disabled:cursor-default disabled:bg-whiter dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-primary" />
@error('email')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
@if (isset($data))
<div>
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
Password Baru
</label>
<input type="password" name="password_baru" placeholder="Password..." value=""
class="w-full rounded-lg border-[1.5px] border-stroke bg-transparent px-5 py-3 font-normal text-black outline-none transition focus:border-primary active:border-primary disabled:cursor-default disabled:bg-whiter dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-primary" />
@error('password_baru')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
@else
<div>
<label class="mb-3 block text-sm font-medium text-black dark:text-white">
Password
</label>
<p class="font-bold">{{$password}}</p>
<input required type="hidden" name="password" placeholder="Password..." value="{{$password}}"
class="w-full rounded-lg border-[1.5px] border-stroke bg-transparent px-5 py-3 font-normal text-black outline-none transition focus:border-primary active:border-primary disabled:cursor-default disabled:bg-whiter dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-primary" />
@error('password')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
@endif
<button
class="inline-flex items-center justify-center rounded-md bg-primary px-10 py-4 text-center font-medium text-white hover:bg-opacity-90 lg:px-8 xl:px-10 mt-6">Simpan</button>
</div>
</div>
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]