fix(hse): prevent modal auto-close on text selection and make unit kerja input flexible
This commit is contained in:
@@ -165,7 +165,14 @@ class EmployeeController extends Controller
|
||||
|
||||
$availableSimperTypes = SimperType::active()->orderBy('name')->get();
|
||||
|
||||
return view('hse.employees_index', compact('employees', 'employeeTypes', 'availableSimperTypes'));
|
||||
$unitKerjaList = Employee::whereNotNull('unit_kerja')
|
||||
->where('unit_kerja', '!=', '')
|
||||
->distinct()
|
||||
->orderBy('unit_kerja')
|
||||
->pluck('unit_kerja')
|
||||
->all();
|
||||
|
||||
return view('hse.employees_index', compact('employees', 'employeeTypes', 'availableSimperTypes', 'unitKerjaList'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -585,8 +592,8 @@ class EmployeeController extends Controller
|
||||
'nik.required' => 'NIK wajib diisi.',
|
||||
'nik.unique' => 'NIK sudah terdaftar dalam sistem.',
|
||||
'name.required' => 'Nama karyawan wajib diisi.',
|
||||
'unit_kerja.required' => 'Unit kerja wajib dipilih.',
|
||||
'division.required' => 'Divisi wajib dipilih.',
|
||||
'unit_kerja.required' => 'Unit kerja wajib diisi.',
|
||||
'division.required' => 'Divisi wajib diisi.',
|
||||
'position.required' => 'Posisi / Jabatan wajib diisi.',
|
||||
'is_operator.required' => 'Pilih apakah karyawan berstatus Operator / Driver.',
|
||||
]);
|
||||
@@ -656,7 +663,21 @@ class EmployeeController extends Controller
|
||||
->values()
|
||||
->all();
|
||||
|
||||
return view('hse.employees_edit', compact('employee', 'availableSimperTypes', 'employeeTypes'));
|
||||
if (!in_array('Karyawan', $employeeTypes)) {
|
||||
array_unshift($employeeTypes, 'Karyawan');
|
||||
}
|
||||
if (!in_array('Sukon', $employeeTypes)) {
|
||||
$employeeTypes[] = 'Sukon';
|
||||
}
|
||||
|
||||
$unitKerjaList = Employee::whereNotNull('unit_kerja')
|
||||
->where('unit_kerja', '!=', '')
|
||||
->distinct()
|
||||
->orderBy('unit_kerja')
|
||||
->pluck('unit_kerja')
|
||||
->all();
|
||||
|
||||
return view('hse.employees_edit', compact('employee', 'availableSimperTypes', 'employeeTypes', 'unitKerjaList'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -417,7 +417,7 @@
|
||||
|
||||
{{-- MODAL 1: KOREKSI ODOMETER DRIVER (HANYA STATUS PENDING) --}}
|
||||
<div id="driverEditKmModal"
|
||||
onclick="if(event.target === this) closeDriverEditKmModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-xs flex items-center justify-center p-4 overflow-y-auto"
|
||||
aria-labelledby="modal-title" role="dialog" aria-modal="true">
|
||||
<div class="relative z-10 bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all my-8 max-w-lg w-full border border-slate-200 animate-scale-in">
|
||||
@@ -504,7 +504,7 @@
|
||||
|
||||
{{-- MODAL 2: KONFIRMASI BATALKAN PERJALANAN --}}
|
||||
<div id="driverCancelModal"
|
||||
onclick="if(event.target === this) closeDriverCancelModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-xs flex items-center justify-center p-4 overflow-y-auto"
|
||||
aria-labelledby="modal-title" role="dialog" aria-modal="true">
|
||||
<div class="relative z-10 bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all my-8 max-w-md w-full border border-slate-200 animate-scale-in">
|
||||
@@ -548,7 +548,6 @@
|
||||
|
||||
{{-- MODAL 3: IN-APP LIVE QR/BARCODE SCANNER UNIT (LANGSUNG LIVE STREAMING KAMERA KE FORM) --}}
|
||||
<div id="unitQrScannerModal"
|
||||
onclick="if(event.target === this) closeUnitQrScannerModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/80 backdrop-blur-xs flex items-center justify-center p-4 overflow-y-auto"
|
||||
aria-labelledby="qr-scanner-title" role="dialog" aria-modal="true">
|
||||
<div class="relative z-10 bg-slate-900 rounded-3xl text-left overflow-hidden shadow-2xl transform transition-all my-8 max-w-md w-full border border-slate-800 animate-scale-in text-white">
|
||||
|
||||
@@ -282,7 +282,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (DASHBOARD OPERASIONAL HSE) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -121,6 +121,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Unit Kerja (Fleksibel) -->
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1.5">
|
||||
Unit Kerja <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<input type="text" name="unit_kerja" list="unitKerjaSuggestions" required
|
||||
value="{{ old('unit_kerja', $employee->unit_kerja) }}"
|
||||
placeholder="Contoh: Umum, HSE, dll"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
</div>
|
||||
|
||||
<!-- Status Operator / Driver -->
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1.5">
|
||||
@@ -238,6 +249,20 @@
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Datalist Saran Unit Kerja Fleksibel -->
|
||||
<datalist id="unitKerjaSuggestions">
|
||||
@php
|
||||
$defaultUnits = ['Umum', 'HSE', 'QMA', 'Pembangkit', 'Bendungan', 'Teknik', 'Logistik', 'Security'];
|
||||
$allUnits = collect($defaultUnits);
|
||||
if (isset($unitKerjaList)) {
|
||||
$allUnits = $allUnits->merge($unitKerjaList)->filter()->unique()->values();
|
||||
}
|
||||
@endphp
|
||||
@foreach($allUnits as $unit)
|
||||
<option value="{{ $unit }}">
|
||||
@endforeach
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -332,7 +332,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: TAMBAH KARYAWAN MANUAL -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="addKaryawanModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div id="addKaryawanModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-4xl w-full p-6 sm:p-7 border border-slate-100 flex flex-col max-h-[92vh] overflow-hidden animate-scale-in">
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100 flex-shrink-0">
|
||||
<div>
|
||||
@@ -416,15 +416,8 @@
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-2.5">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1">Unit Kerja <span class="text-rose-500">*</span></label>
|
||||
<select name="unit_kerja" required class="w-full text-xs px-2.5 py-2 rounded-xl border border-slate-200 bg-slate-50 focus:bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20]">
|
||||
<option value="Pembangkit">Pembangkit</option>
|
||||
<option value="Bendungan">Bendungan</option>
|
||||
<option value="Teknik">Teknik</option>
|
||||
<option value="Umum" selected>Umum</option>
|
||||
<option value="Logistik">Logistik</option>
|
||||
<option value="HSE">HSE</option>
|
||||
<option value="QMA">QMA</option>
|
||||
</select>
|
||||
<input type="text" name="unit_kerja" id="addUnitKerjaInput" list="unitKerjaSuggestions" required placeholder="Contoh: HSE, Umum, dll" value="{{ old('unit_kerja', 'Umum') }}"
|
||||
class="w-full text-xs px-2.5 py-2 rounded-xl border border-slate-200 bg-slate-50 focus:bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] transition">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1">Divisi <span class="text-rose-500">*</span></label>
|
||||
@@ -538,7 +531,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: IMPOR DATA KARYAWAN EXCEL -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="importKaryawanModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div id="importKaryawanModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 overflow-hidden animate-scale-in">
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
|
||||
<div>
|
||||
@@ -628,11 +621,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Modal Dialog Perpanjang SIMPER (Clean White Card) -->
|
||||
<div id="renewModal" onclick="if(event.target === this) this.classList.add('hidden')" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div id="renewModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-md w-full p-7 border border-slate-100 overflow-hidden">
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
|
||||
<h3 class="text-xl font-bold text-slate-900 tracking-tight">Perpanjang SIMPER</h3>
|
||||
<button type="button" onclick="document.getElementById('renewModal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 transition p-1">
|
||||
<button type="button" onclick="closeRenewModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
|
||||
<i class="fa-solid fa-xmark text-lg"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -657,7 +650,7 @@
|
||||
class="w-full text-sm px-4 py-3 rounded-2xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition">
|
||||
</div>
|
||||
<div class="pt-6 border-t border-slate-100 flex items-center justify-end space-x-3 mt-6">
|
||||
<button type="button" onclick="document.getElementById('renewModal').classList.add('hidden')"
|
||||
<button type="button" onclick="closeRenewModal()"
|
||||
class="px-6 py-2.5 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-sm transition">
|
||||
Batal
|
||||
</button>
|
||||
@@ -671,7 +664,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Modal Dialog Edit Data Simper Karyawan -->
|
||||
<div id="editModal" onclick="if(event.target === this) this.classList.add('hidden')" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div id="editModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-4xl w-full p-6 sm:p-7 border border-slate-100 flex flex-col max-h-[92vh] overflow-hidden animate-scale-in">
|
||||
<!-- Header Modal -->
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100 flex-shrink-0">
|
||||
@@ -689,7 +682,7 @@
|
||||
<i class="fa-solid fa-up-right-from-square text-[10px]"></i>
|
||||
<span class="hidden sm:inline">Halaman Penuh</span>
|
||||
</a>
|
||||
<button type="button" onclick="document.getElementById('editModal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 transition p-1">
|
||||
<button type="button" onclick="closeEditModal()" class="text-slate-400 hover:text-slate-600 transition p-1">
|
||||
<i class="fa-solid fa-xmark text-lg"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -774,6 +767,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Unit Kerja (Fleksibel) -->
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1">
|
||||
Unit Kerja <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<input type="text" name="unit_kerja" id="editUnitKerjaInput" list="unitKerjaSuggestions" required placeholder="Contoh: HSE, Umum, dll"
|
||||
class="w-full text-xs px-3 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] transition">
|
||||
</div>
|
||||
|
||||
<!-- Status Operator -->
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1">Status Operator / Driver <span class="text-rose-500">*</span></label>
|
||||
@@ -854,7 +856,7 @@
|
||||
|
||||
<!-- Footer Tombol -->
|
||||
<div class="pt-4 border-t border-slate-100 flex items-center justify-end space-x-2.5 flex-shrink-0">
|
||||
<button type="button" onclick="document.getElementById('editModal').classList.add('hidden')"
|
||||
<button type="button" onclick="closeEditModal()"
|
||||
class="px-5 py-2 rounded-xl border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 font-bold text-xs transition">
|
||||
Batal
|
||||
</button>
|
||||
@@ -867,11 +869,24 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Datalist Saran Unit Kerja Fleksibel -->
|
||||
<datalist id="unitKerjaSuggestions">
|
||||
@php
|
||||
$defaultUnits = ['Umum', 'HSE', 'QMA', 'Pembangkit', 'Bendungan', 'Teknik', 'Logistik', 'Security'];
|
||||
$allUnits = collect($defaultUnits);
|
||||
if (isset($unitKerjaList)) {
|
||||
$allUnits = $allUnits->merge($unitKerjaList)->filter()->unique()->values();
|
||||
}
|
||||
@endphp
|
||||
@foreach($allUnits as $unit)
|
||||
<option value="{{ $unit }}">
|
||||
@endforeach
|
||||
</datalist>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (DATA SIMPER) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
@@ -1111,6 +1126,10 @@
|
||||
document.getElementById('editNikDisplay').textContent = emp.nik || '-';
|
||||
document.getElementById('editNameDisplay').textContent = emp.name || '-';
|
||||
document.getElementById('editUnitKerjaDisplay').textContent = emp.unit_kerja || '-';
|
||||
const editUnitKerjaInput = document.getElementById('editUnitKerjaInput');
|
||||
if (editUnitKerjaInput) {
|
||||
editUnitKerjaInput.value = emp.unit_kerja || '';
|
||||
}
|
||||
document.getElementById('editDivisionPositionDisplay').textContent = (emp.division || '-') + ' / ' + (emp.position || '-');
|
||||
document.getElementById('editOperator').value = emp.is_operator ? '1' : '0';
|
||||
|
||||
@@ -1219,6 +1238,11 @@
|
||||
document.getElementById('editModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeEditModal() {
|
||||
const modal = document.getElementById('editModal');
|
||||
if (modal) modal.classList.add('hidden');
|
||||
}
|
||||
|
||||
function openRenewModal(id, name, expiredDate, isOperator) {
|
||||
document.getElementById('renewName').textContent = name;
|
||||
document.getElementById('renewOperator').value = isOperator ? '1' : '0';
|
||||
@@ -1231,6 +1255,11 @@
|
||||
document.getElementById('renewModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeRenewModal() {
|
||||
const modal = document.getElementById('renewModal');
|
||||
if (modal) modal.classList.add('hidden');
|
||||
}
|
||||
|
||||
// Pencarian Server-side Otomatis (Global ke seluruh database)
|
||||
const employeeFilterForm = document.getElementById('employeeFilterForm');
|
||||
const searchInput = document.getElementById('simperSearchInput');
|
||||
@@ -1274,6 +1303,8 @@
|
||||
if (e.key === 'Escape') {
|
||||
closeGuideModal();
|
||||
closeAddKaryawanModal();
|
||||
closeEditModal();
|
||||
closeRenewModal();
|
||||
closeImportKaryawanModal();
|
||||
const exportMenu = document.getElementById('exportMenuSimper');
|
||||
if (exportMenu) exportMenu.style.display = 'none';
|
||||
@@ -1283,6 +1314,8 @@
|
||||
// Modal Tambah Karyawan Manual
|
||||
function openAddKaryawanModal() {
|
||||
const modal = document.getElementById('addKaryawanModal');
|
||||
const addUnitKerja = document.getElementById('addUnitKerjaInput');
|
||||
if (addUnitKerja) addUnitKerja.value = 'Umum';
|
||||
const addPhotoPreview = document.getElementById('addEmpPhotoPreview');
|
||||
const addPhotoPlaceholder = document.getElementById('addEmpPhotoPlaceholder');
|
||||
const addPhotoInput = document.getElementById('addEmpPhotoInput');
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: TAMBAH JENIS SIMPER -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="addSimperTypeModal" onclick="if(event.target === this) closeAddSimperTypeModal()" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div id="addSimperTypeModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-3xl w-full p-6 sm:p-7 border border-slate-100 flex flex-col max-h-[92vh] overflow-hidden animate-scale-in">
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100 flex-shrink-0">
|
||||
<div>
|
||||
@@ -357,7 +357,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: EDIT JENIS SIMPER -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="editSimperTypeModal" onclick="if(event.target === this) closeEditSimperTypeModal()" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div id="editSimperTypeModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-3xl w-full p-6 sm:p-7 border border-slate-100 flex flex-col max-h-[92vh] overflow-hidden animate-scale-in">
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100 flex-shrink-0">
|
||||
<div>
|
||||
@@ -503,7 +503,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: HAPUS JENIS SIMPER -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="deleteSimperTypeModal" onclick="if(event.target === this) closeDeleteSimperTypeModal()" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div id="deleteSimperTypeModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-sm w-full p-6 border border-slate-100 text-center animate-scale-in">
|
||||
<div class="w-12 h-12 rounded-full bg-rose-100 text-rose-600 flex items-center justify-center text-xl mx-auto mb-3">
|
||||
<i class="fa-solid fa-triangle-exclamation"></i>
|
||||
@@ -529,7 +529,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: PANDUAN HALAMAN MASTER SIMPER -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="simperTypeGuideModal" onclick="if(event.target === this) closeSimperTypeGuideModal()" class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div id="simperTypeGuideModal" class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100">
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
|
||||
<div class="flex items-center space-x-3">
|
||||
|
||||
@@ -1185,6 +1185,13 @@
|
||||
document.addEventListener('mousedown', function(e) {
|
||||
const modal = e.target.closest('[id$="Modal"], [id$="modal"], .fixed.inset-0.z-50');
|
||||
if (modal && !modal.classList.contains('hidden') && modal.id !== 'mobileDrawer') {
|
||||
// MODAL STATIS / FORM: Jangan pernah tutup modal input form via klik/drag backdrop
|
||||
if (modal.dataset.backdrop === 'static' || modal.getAttribute('data-backdrop') === 'static' || modal.querySelector('form')) {
|
||||
isMouseDownOnBackdrop = false;
|
||||
activeBackdropModal = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const dialogCard = modal.querySelector('.bg-white, [role="dialog"], .modal-dialog, div[class*="rounded-"]');
|
||||
// Tandai mousedown hanya jika terjadi langsung di luar kartu dialog (pada area backdrop)
|
||||
if (dialogCard && !dialogCard.contains(e.target)) {
|
||||
@@ -1211,6 +1218,11 @@
|
||||
isMouseDownOnBackdrop = false;
|
||||
activeBackdropModal = null;
|
||||
|
||||
// MODAL STATIS / FORM: Lindungi form agar data input pengguna tidak hilang
|
||||
if (modal.dataset.backdrop === 'static' || modal.getAttribute('data-backdrop') === 'static' || modal.querySelector('form')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Proteksi: jangan tutup modal jika pengguna sedang menyeleksi / memblok teks
|
||||
const selection = window.getSelection();
|
||||
if (selection && selection.toString().trim().length > 0) {
|
||||
|
||||
@@ -230,7 +230,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (DASHBOARD PRIVATE GUARD) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -266,7 +266,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL POPUP: TAMBAH PETUGAS SATPAM BARU -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="addGuardModal" onclick="if(event.target === this) this.classList.add('hidden')" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div id="addGuardModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-7 sm:p-8 border border-slate-100 overflow-hidden">
|
||||
<!-- Header Modal -->
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
|
||||
@@ -359,7 +359,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL POPUP: EDIT DATA PETUGAS SATPAM -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="editGuardModal" onclick="if(event.target === this) closeEditGuardModal()" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div id="editGuardModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-7 sm:p-8 border border-slate-100 overflow-hidden">
|
||||
<!-- Header Modal -->
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
|
||||
@@ -431,7 +431,7 @@
|
||||
<!-- MODAL POPUP: KONFIRMASI AKTIFKAN / NONAKTIFKAN PETUGAS SATPAM -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="toggleStatusModal"
|
||||
onclick="if(event.target === this) closeToggleStatusModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-sm sm:max-w-md w-full p-6 sm:p-7 border border-slate-100 transform transition-all text-center">
|
||||
<!-- Icon Dinamis (Rose untuk Nonaktifkan, Emerald untuk Aktifkan) -->
|
||||
@@ -481,7 +481,7 @@
|
||||
<!-- MODAL POPUP: KONFIRMASI HAPUS PETUGAS SATPAM -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="deleteGuardModal"
|
||||
onclick="if(event.target === this) closeDeleteGuardModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-sm sm:max-w-md w-full p-6 sm:p-7 border border-slate-100 transform transition-all text-center">
|
||||
<!-- Icon Peringatan Sampah Merah -->
|
||||
@@ -684,7 +684,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (DATA SATPAM) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -524,7 +524,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (LOG VERIFIKASI GERBANG) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -202,7 +202,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (PROFIL SAYA) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -543,7 +543,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (LOG AKTIVITAS KENDARAAN) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
@@ -625,7 +624,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
@can('qma.logs.edit_odometer')
|
||||
{{-- MODAL KOREKSI ODOMETER QMA --}}
|
||||
<div id="qmaOdometerModal"
|
||||
onclick="if(event.target === this) closeQmaOdometerModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-xs flex items-center justify-center p-4 overflow-y-auto"
|
||||
aria-labelledby="modal-title" role="dialog" aria-modal="true">
|
||||
<div class="relative z-10 bg-white rounded-2xl text-left overflow-hidden shadow-2xl transform transition-all my-8 max-w-lg w-full border border-slate-200 animate-scale-in">
|
||||
|
||||
@@ -461,7 +461,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (SUMMARY AKTIVITAS KENDARAAN) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -308,7 +308,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (DASHBOARD QMA) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -322,7 +322,6 @@ function closeGuideModal() {
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (LOG P2H HEAVY EQUIPMENT) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -514,7 +514,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (SUMMARY P2H) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<div class="flex items-center justify-between pb-4 border-b border-slate-100">
|
||||
|
||||
@@ -258,7 +258,7 @@
|
||||
<!-- MODAL: TAMBAH SECTION & DAFTAR PERTANYAAN (BATCH) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="addSectionModal"
|
||||
onclick="if(event.target === this) closeAddSectionModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-2xl w-full p-6 sm:p-8 border border-slate-100 my-8 max-h-[90vh] flex flex-col">
|
||||
<!-- Modal Header -->
|
||||
@@ -437,7 +437,7 @@
|
||||
<!-- MODAL: ATUR URUTAN POSISI SECTION (REORDER) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="reorderSectionsModal"
|
||||
onclick="if(event.target === this) closeReorderSectionsModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-8 border border-slate-100 my-8 max-h-[90vh] flex flex-col">
|
||||
<!-- Header -->
|
||||
@@ -522,7 +522,7 @@
|
||||
<!-- MODAL: EDIT BUTIR PERTANYAAN -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="editItemModal"
|
||||
onclick="if(event.target === this) closeEditItemModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-8 border border-slate-100">
|
||||
<div class="flex items-center justify-between mb-5">
|
||||
@@ -610,7 +610,7 @@
|
||||
<!-- MODAL: TAMBAH BUTIR PERTANYAAN TUNGGAL -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="addItemModal"
|
||||
onclick="if(event.target === this) closeAddItemModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-8 border border-slate-100">
|
||||
<div class="flex items-center justify-between mb-5">
|
||||
@@ -701,7 +701,7 @@
|
||||
<!-- MODAL: KONFIRMASI HAPUS PERTANYAAN -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="deleteItemModal"
|
||||
onclick="if(event.target === this) closeDeleteItemModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-md w-full p-6 sm:p-8 border border-slate-100 text-center">
|
||||
<div class="w-14 h-14 bg-rose-50 text-rose-600 rounded-full flex items-center justify-center mx-auto mb-4 text-2xl">
|
||||
|
||||
@@ -1091,7 +1091,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (TIMESHEET HEAVY EQUIPMENT) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -273,7 +273,7 @@
|
||||
<!-- MODAL: TAMBAH LIGHT VEHICLE -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="addVehicleModal"
|
||||
onclick="if(event.target === this) closeAddModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-8 border border-slate-100">
|
||||
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
|
||||
@@ -389,7 +389,7 @@
|
||||
<!-- MODAL: EDIT LIGHT VEHICLE -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="editVehicleModal"
|
||||
onclick="if(event.target === this) closeEditModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-8 border border-slate-100">
|
||||
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Tambah Aset -->
|
||||
@@ -499,7 +499,6 @@
|
||||
<!-- MODAL: DETAIL LIGHT VEHICLE -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="detailVehicleModal"
|
||||
onclick="if(event.target === this) closeDetailModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-8 border border-slate-100">
|
||||
<!-- Header Modal Bersih Tanpa Icon Box Sesuai Referensi Card Tambah Data -->
|
||||
@@ -587,7 +586,7 @@
|
||||
<!-- MODAL: KONFIRMASI HAPUS KENDARAAN (LIGHT VEHICLE) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="deleteVehicleModal"
|
||||
onclick="if(event.target === this) closeDeleteModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-sm sm:max-w-md w-full p-6 sm:p-7 border border-slate-100 transform transition-all text-center">
|
||||
<!-- Icon Peringatan Elegan -->
|
||||
@@ -631,7 +630,6 @@
|
||||
<!-- MODAL: PREVIEW & CETAK STIKER QR CODE KENDARAAN -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="qrVehicleModal"
|
||||
onclick="if(event.target === this) closeQrModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
@@ -1420,7 +1418,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (LIGHT VEHICLE) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -242,7 +242,7 @@
|
||||
<!-- MODAL: TAMBAH HEAVY EQUIPMENT (KENDARAAN BERAT) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="addVehicleModal"
|
||||
onclick="if(event.target === this) closeAddModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
@@ -364,7 +364,7 @@
|
||||
<!-- MODAL: EDIT KATEGORI HEAVY EQUIPMENT -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="editVehicleModal"
|
||||
onclick="if(event.target === this) closeEditModal()"
|
||||
data-backdrop="static"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
@@ -483,7 +483,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: DETAIL SPESIFIKASI KATEGORI HEAVY EQUIPMENT -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="detailVehicleModal" onclick="if(event.target === this) closeDetailModal()" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
|
||||
<div id="detailVehicleModal" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-xl w-full p-6 sm:p-7 border border-slate-100 max-h-[92vh] overflow-y-auto no-scrollbar">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div>
|
||||
@@ -588,7 +588,7 @@
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: KONFIRMASI HAPUS HEAVY EQUIPMENT (KENDARAAN BERAT) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="deleteVehicleModal" onclick="if(event.target === this) closeDeleteModal()" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
|
||||
<div id="deleteVehicleModal" data-backdrop="static" class="hidden fixed inset-0 z-50 bg-slate-900/50 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto no-scrollbar">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-sm sm:max-w-md w-full p-6 sm:p-7 border border-slate-100 transform transition-all text-center">
|
||||
<!-- Icon Peringatan Elegan -->
|
||||
<div class="w-14 h-14 rounded-2xl bg-rose-50 border border-rose-100 text-rose-600 flex items-center justify-center mx-auto mb-4 text-2xl shadow-sm">
|
||||
@@ -987,7 +987,6 @@
|
||||
<!-- MODAL POPUP: PANDUAN HALAMAN (HEAVY EQUIPMENT) -->
|
||||
<!-- ========================================================================= -->
|
||||
<div id="guideModal"
|
||||
onclick="if(event.target === this) closeGuideModal()"
|
||||
class="hidden fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto">
|
||||
<div class="bg-white rounded-3xl shadow-2xl max-w-lg w-full p-6 sm:p-7 border border-slate-100 transform transition-all my-8">
|
||||
<!-- Header Modal -->
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Employee;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HseEmployeeFlexibleUnitKerjaAndModalTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $hseAdmin;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Permission::firstOrCreate(['name' => 'hse.employees.view']);
|
||||
Permission::firstOrCreate(['name' => 'hse.employees.create']);
|
||||
Permission::firstOrCreate(['name' => 'hse.employees.edit']);
|
||||
|
||||
$hseRole = Role::firstOrCreate(['name' => 'hse_admin']);
|
||||
$hseRole->syncPermissions(['hse.employees.view', 'hse.employees.create', 'hse.employees.edit']);
|
||||
|
||||
Role::firstOrCreate(['name' => 'employee']);
|
||||
|
||||
$this->hseAdmin = User::factory()->create([
|
||||
'username' => 'hseadmin_unit_test',
|
||||
'role' => 'hse_admin',
|
||||
]);
|
||||
$this->hseAdmin->assignRole('hse_admin');
|
||||
}
|
||||
|
||||
public function test_hse_employees_index_renders_static_backdrops_and_flexible_unit_kerja_input(): void
|
||||
{
|
||||
Employee::create([
|
||||
'nik' => 'KMH-TEST-001',
|
||||
'name' => 'Budi Santoso',
|
||||
'employee_type' => 'Karyawan',
|
||||
'unit_kerja' => 'Maintenance Sipil',
|
||||
'division' => 'Operasional',
|
||||
'position' => 'Teknisi',
|
||||
'is_operator' => false,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($this->hseAdmin)
|
||||
->get(route('hse.employees.index'));
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertViewHas('unitKerjaList');
|
||||
|
||||
$content = $response->getContent();
|
||||
|
||||
// Verifikasi perlindungan backdrop modal form
|
||||
$this->assertStringContainsString('id="addKaryawanModal" data-backdrop="static"', $content);
|
||||
$this->assertStringContainsString('id="editModal" data-backdrop="static"', $content);
|
||||
$this->assertStringContainsString('id="renewModal" data-backdrop="static"', $content);
|
||||
$this->assertStringContainsString('id="importKaryawanModal" data-backdrop="static"', $content);
|
||||
|
||||
// Verifikasi tidak ada inline onclick auto-close yang merusak blok teks
|
||||
$this->assertStringNotContainsString('if(event.target === this) this.classList.add(\'hidden\')', $content);
|
||||
|
||||
// Verifikasi input isian unit kerja fleksibel dengan datalist saran
|
||||
$this->assertStringContainsString('name="unit_kerja" id="addUnitKerjaInput" list="unitKerjaSuggestions"', $content);
|
||||
$this->assertStringContainsString('name="unit_kerja" id="editUnitKerjaInput" list="unitKerjaSuggestions"', $content);
|
||||
$this->assertStringContainsString('<datalist id="unitKerjaSuggestions">', $content);
|
||||
$this->assertStringContainsString('<option value="Maintenance Sipil">', $content);
|
||||
}
|
||||
|
||||
public function test_hse_can_store_employee_with_custom_flexible_unit_kerja(): void
|
||||
{
|
||||
$response = $this->actingAs($this->hseAdmin)
|
||||
->from(route('hse.employees.index'))
|
||||
->post(route('hse.employees.store'), [
|
||||
'nik' => 'KMH-SIPIL-99',
|
||||
'name' => 'Ahmad Teknisi',
|
||||
'employee_type' => 'Sukon',
|
||||
'unit_kerja' => 'Subkontraktor Sipil & Piping',
|
||||
'division' => 'Proyek Konstruksi',
|
||||
'position' => 'Welder Specialist',
|
||||
'is_operator' => '0',
|
||||
]);
|
||||
|
||||
$response->assertSessionHasNoErrors();
|
||||
$response->assertRedirect(route('hse.employees.index'));
|
||||
|
||||
$this->assertDatabaseHas('employees', [
|
||||
'nik' => 'KMH-SIPIL-99',
|
||||
'name' => 'Ahmad Teknisi',
|
||||
'employee_type' => 'Sukon',
|
||||
'unit_kerja' => 'Subkontraktor Sipil & Piping',
|
||||
'division' => 'Proyek Konstruksi',
|
||||
'position' => 'Welder Specialist',
|
||||
'is_operator' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_hse_can_update_employee_with_flexible_unit_kerja(): void
|
||||
{
|
||||
$employee = Employee::create([
|
||||
'nik' => 'KMH-UPD-001',
|
||||
'name' => 'Rian Hidayat',
|
||||
'employee_type' => 'Karyawan',
|
||||
'unit_kerja' => 'Umum',
|
||||
'division' => 'Operasional',
|
||||
'position' => 'Staff',
|
||||
'is_operator' => false,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($this->hseAdmin)
|
||||
->from(route('hse.employees.index'))
|
||||
->post(route('hse.employees.update', $employee->id), [
|
||||
'unit_kerja' => 'Klinik & Keselamatan Kerja',
|
||||
'is_operator' => '0',
|
||||
]);
|
||||
|
||||
$response->assertSessionHasNoErrors();
|
||||
|
||||
$employee->refresh();
|
||||
$this->assertEquals('Klinik & Keselamatan Kerja', $employee->unit_kerja);
|
||||
}
|
||||
|
||||
public function test_hse_employees_edit_page_renders_flexible_unit_kerja_input(): void
|
||||
{
|
||||
$employee = Employee::create([
|
||||
'nik' => 'KMH-EDIT-PAGE',
|
||||
'name' => 'Dewi Sartika',
|
||||
'employee_type' => 'Karyawan',
|
||||
'unit_kerja' => 'Laboratorium Kimia',
|
||||
'division' => 'Operasional',
|
||||
'position' => 'Analis',
|
||||
'is_operator' => false,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($this->hseAdmin)
|
||||
->get(route('hse.employees.edit', $employee->id));
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertViewHas('unitKerjaList');
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertStringContainsString('name="unit_kerja" list="unitKerjaSuggestions"', $content);
|
||||
$this->assertStringContainsString('value="Laboratorium Kimia"', $content);
|
||||
$this->assertStringContainsString('<datalist id="unitKerjaSuggestions">', $content);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user