feat(qma): route heavy equipment update in unit management directly to transfer form
This commit is contained in:
@@ -118,8 +118,10 @@ class UnitTransferController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Tampilkan formulir pembuatan transfer unit alat berat baru.
|
* Tampilkan formulir pembuatan transfer unit alat berat baru.
|
||||||
*/
|
*/
|
||||||
public function create(): View
|
public function create(Request $request): View
|
||||||
{
|
{
|
||||||
|
$selectedVehicleId = $request->filled('vehicle_id') ? (int) $request->input('vehicle_id') : null;
|
||||||
|
|
||||||
// 1. Daftar unit alat berat yang bisa dipindahkan
|
// 1. Daftar unit alat berat yang bisa dipindahkan
|
||||||
$heavyUnits = Vehicle::trackableUnits()
|
$heavyUnits = Vehicle::trackableUnits()
|
||||||
->where('category', 'unit_support')
|
->where('category', 'unit_support')
|
||||||
@@ -150,7 +152,8 @@ class UnitTransferController extends Controller
|
|||||||
'transporterUnits',
|
'transporterUnits',
|
||||||
'drivers',
|
'drivers',
|
||||||
'locationSuggestions',
|
'locationSuggestions',
|
||||||
'defaultDocNumber'
|
'defaultDocNumber',
|
||||||
|
'selectedVehicleId'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -396,10 +396,19 @@
|
|||||||
<div class="flex items-center justify-center space-x-1.5">
|
<div class="flex items-center justify-center space-x-1.5">
|
||||||
<!-- Tombol Update Posisi -->
|
<!-- Tombol Update Posisi -->
|
||||||
@can('qma.vehicles.edit')
|
@can('qma.vehicles.edit')
|
||||||
|
@if($u->isUnitSupport())
|
||||||
|
<a href="{{ route('qma.unit_transfers.create', ['vehicle_id' => $u->id]) }}"
|
||||||
|
class="inline-flex items-center space-x-1 text-emerald-700 hover:text-emerald-900 bg-emerald-50 hover:bg-emerald-100 px-2.5 py-1.5 rounded-lg transition font-bold text-[11px] cursor-pointer"
|
||||||
|
title="Transfer Pemindahan Alat Berat">
|
||||||
|
<i class="fa-solid fa-truck-moving text-xs"></i>
|
||||||
|
<span>Update</span>
|
||||||
|
</a>
|
||||||
|
@else
|
||||||
<button type="button"
|
<button type="button"
|
||||||
data-unit="{{ json_encode([
|
data-unit="{{ json_encode([
|
||||||
'id' => $u->id,
|
'id' => $u->id,
|
||||||
'code' => $u->code,
|
'code' => $u->code,
|
||||||
|
'category' => $u->category,
|
||||||
'brand_type' => $u->brand_type,
|
'brand_type' => $u->brand_type,
|
||||||
'license_plate' => $u->license_plate,
|
'license_plate' => $u->license_plate,
|
||||||
'serial_number' => $u->serial_number,
|
'serial_number' => $u->serial_number,
|
||||||
@@ -414,6 +423,7 @@
|
|||||||
<i class="fa-solid fa-location-pen text-xs"></i>
|
<i class="fa-solid fa-location-pen text-xs"></i>
|
||||||
<span>Update</span>
|
<span>Update</span>
|
||||||
</button>
|
</button>
|
||||||
|
@endif
|
||||||
@endcan
|
@endcan
|
||||||
|
|
||||||
<!-- Tombol Riwayat Posisi -->
|
<!-- Tombol Riwayat Posisi -->
|
||||||
@@ -889,6 +899,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openUpdateLocationModal(unit) {
|
function openUpdateLocationModal(unit) {
|
||||||
|
if (unit.category === 'unit_support') {
|
||||||
|
window.location.href = `/qma/unit-transfers/create?vehicle_id=${unit.id}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const modal = document.getElementById('updateLocationModal');
|
const modal = document.getElementById('updateLocationModal');
|
||||||
const form = document.getElementById('updateLocationForm');
|
const form = document.getElementById('updateLocationForm');
|
||||||
form.action = `/qma/unit-management/${unit.id}/location`;
|
form.action = `/qma/unit-management/${unit.id}/location`;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
required
|
required
|
||||||
onchange="onHeavyUnitSelected(this)"
|
onchange="onHeavyUnitSelected(this)"
|
||||||
class="w-full px-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-800 font-semibold">
|
class="w-full px-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-800 font-semibold">
|
||||||
<option value="" disabled {{ old('vehicle_id') ? '' : 'selected' }}>-- Pilih Unit Alat Berat / Support Unit --</option>
|
<option value="" disabled {{ old('vehicle_id', $selectedVehicleId) ? '' : 'selected' }}>-- Pilih Unit Alat Berat / Support Unit --</option>
|
||||||
@foreach($heavyUnits as $unit)
|
@foreach($heavyUnits as $unit)
|
||||||
<option value="{{ $unit->id }}"
|
<option value="{{ $unit->id }}"
|
||||||
data-code="{{ $unit->code }}"
|
data-code="{{ $unit->code }}"
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
data-location="{{ $unit->location ?: 'Site Kerinci' }}"
|
data-location="{{ $unit->location ?: 'Site Kerinci' }}"
|
||||||
data-site-status="{{ $unit->site_status ?? 'inside_site' }}"
|
data-site-status="{{ $unit->site_status ?? 'inside_site' }}"
|
||||||
data-photo="{{ $unit->photo_url }}"
|
data-photo="{{ $unit->photo_url }}"
|
||||||
{{ old('vehicle_id') == $unit->id ? 'selected' : '' }}>
|
{{ old('vehicle_id', $selectedVehicleId) == $unit->id ? 'selected' : '' }}>
|
||||||
{{ $unit->code }} - {{ $unit->brand_type }} (Lokasi Saat Ini: {{ $unit->location ?: 'Site Kerinci' }})
|
{{ $unit->code }} - {{ $unit->brand_type }} (Lokasi Saat Ini: {{ $unit->location ?: 'Site Kerinci' }})
|
||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class QmaUnitManagementTest extends TestCase
|
|||||||
$response = $this->actingAs($this->qmaAdmin)->get(route('qma.unit_management.index'));
|
$response = $this->actingAs($this->qmaAdmin)->get(route('qma.unit_management.index'));
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
$response->assertSee('Manajemen Unit');
|
$response->assertSee('Posisi Unit');
|
||||||
$response->assertSee('LV-TEST-01');
|
$response->assertSee('LV-TEST-01');
|
||||||
$response->assertSee('EX-TEST-01');
|
$response->assertSee('EX-TEST-01');
|
||||||
$response->assertSee('Main Dam');
|
$response->assertSee('Main Dam');
|
||||||
@@ -119,7 +119,7 @@ class QmaUnitManagementTest extends TestCase
|
|||||||
$response->assertSee('Di Luar Site');
|
$response->assertSee('Di Luar Site');
|
||||||
$response->assertSee('openUpdateLocationModalFromBtn');
|
$response->assertSee('openUpdateLocationModalFromBtn');
|
||||||
$response->assertSee('openHistoryModal');
|
$response->assertSee('openHistoryModal');
|
||||||
$response->assertSee('data-unit=');
|
$response->assertSee(route('qma.unit_transfers.create', ['vehicle_id' => $support->id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -292,4 +292,16 @@ class QmaUnitTransferTest extends TestCase
|
|||||||
$response->assertRedirect(route('qma.unit_transfers.index'));
|
$response->assertRedirect(route('qma.unit_transfers.index'));
|
||||||
$this->assertDatabaseMissing('unit_transfers', ['id' => $transfer->id]);
|
$this->assertDatabaseMissing('unit_transfers', ['id' => $transfer->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form pembuatan transfer unit otomatis memilih alat berat jika parameter vehicle_id disertakan.
|
||||||
|
*/
|
||||||
|
public function test_create_transfer_form_preselects_heavy_unit_when_vehicle_id_provided(): void
|
||||||
|
{
|
||||||
|
$response = $this->actingAs($this->qmaAdmin)->get(route('qma.unit_transfers.create', ['vehicle_id' => $this->heavyEquipment->id]));
|
||||||
|
|
||||||
|
$response->assertOk();
|
||||||
|
$response->assertSee('value="' . $this->heavyEquipment->id . '"', false);
|
||||||
|
$response->assertSee('selected', false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user