From 53ee60163304854619afdff412d897b6f5afa19f Mon Sep 17 00:00:00 2001 From: Spythere Date: Mon, 1 Dec 2025 01:21:02 +0100 Subject: [PATCH] chore: vehicle groups editing --- .../VehiclesManager/VehicleEditModal.vue | 66 ++-- .../VehiclesManager/VehicleGroupEditModal.vue | 326 ++++++++++++++++++ .../VehiclesManager/VehicleGroupsTable.vue | 85 ++--- .../VehiclesManager/VehiclesTable.vue | 25 +- src/stores/vehicles.store.ts | 1 + 5 files changed, 378 insertions(+), 125 deletions(-) create mode 100644 src/components/VehiclesManager/VehicleGroupEditModal.vue diff --git a/src/components/VehiclesManager/VehicleEditModal.vue b/src/components/VehiclesManager/VehicleEditModal.vue index 74ed28d..0d1d2b5 100644 --- a/src/components/VehiclesManager/VehicleEditModal.vue +++ b/src/components/VehiclesManager/VehicleEditModal.vue @@ -1,14 +1,10 @@ + + diff --git a/src/components/VehiclesManager/VehicleGroupsTable.vue b/src/components/VehiclesManager/VehicleGroupsTable.vue index 9c942f8..04d5d1c 100644 --- a/src/components/VehiclesManager/VehicleGroupsTable.vue +++ b/src/components/VehiclesManager/VehicleGroupsTable.vue @@ -18,24 +18,10 @@ wyników + +
- - - + - - - - - - - - - - - -
{{ row.vehicleGroupRef.id }} + {{ row.vehicleGroupRef.name }} + {{ row.vehicleGroupRef.length }} + {{ row.vehicleGroupRef.weight }} + {{ row.vehicleGroupRef.speed }} + {{ row.vehicleGroupRef.speedLoco }} + {{ row.vehicleGroupRef.speedLoaded }} + {{ row.vehicleGroupRef._count.vehicles }} + {{ row.vehicleGroupRef.locoProps?.coldStart ? '✅' : '❌' }} + {{ row.vehicleGroupRef.locoProps?.doubleManned ? '✅' : '❌' }} + {{ row.vehicleGroupRef.massSpeeds ? 'WPISANE' : 'BRAK' }} - remove -
@@ -112,6 +98,7 @@ import { computed, onMounted, ref, watch } from 'vue'; import { useVehiclesStore } from '../../stores/vehicles.store'; import { LucideArrowDown, LucideArrowUp, LucidePlus, LucideX } from 'lucide-vue-next'; import { IVehicleGroup, IVehicleGroupTableRow, VehicleGroupEditRowKey } from '../../types/vehicles.types'; +import VehicleGroupEditModal from './VehicleGroupEditModal.vue'; interface TableHeader { id: string; @@ -142,7 +129,6 @@ const headers: TableHeader[] = [ { id: 'coldStart', elementWidth: 75, title: 'Zimny start', sortable: true }, { id: 'doubleManned', elementWidth: 75, title: 'Podwójna obsada', sortable: true }, { id: 'massSpeeds', elementWidth: 100, title: 'Prędkości wg masy', sortable: false }, - { id: 'remove', elementWidth: 75, title: 'Usuń', sortable: false }, ]; const vehiclesStore = useVehiclesStore(); @@ -183,27 +169,8 @@ function sortTableBy(id: string) { activeSortKey.value = id; } -async function editRowPrimitive(row: IVehicleGroupTableRow, editKey: VehicleGroupEditRowKey) { - if (!(editKey in row.vehicleGroupRef)) return; - - let rowValue = row.vehicleGroupRef[editKey]; - - if (typeof rowValue === 'string' || typeof rowValue === 'undefined' || rowValue == null) { - const promptValue = prompt('Zmień wartość:', rowValue ?? ''); - if (promptValue == null) return; - - const updatedData = await vehiclesStore.updateVehicleGroup(row.vehicleGroupRef.id, editKey, promptValue); - - if (updatedData) { - (row.vehicleGroupRef[editKey] as any) = updatedData[editKey]; - } - } else if (typeof rowValue == 'boolean') { - const updatedData = await vehiclesStore.updateVehicleGroup(row.vehicleGroupRef.id, editKey, !rowValue); - - if (updatedData) { - (row.vehicleGroupRef[editKey] as any) = updatedData[editKey]; - } - } +function openEditModal(vehicleId: number) { + vehiclesStore.selectedVehicleGroupId = vehicleId; } async function addVehicleGroupRow() { @@ -227,18 +194,6 @@ async function addVehicleGroupRow() { vehicleGroupSearchInput.value = data.name; } } - -async function removeVehicleGroupRow(id: number) { - const confirmRemove = confirm('Czy na pewno chcesz usunąć ten pojazd?'); - - if (!confirmRemove) return; - - const removedData = await vehiclesStore.removeVehicle(id); - - if (removedData) { - vehiclesStore.vehicleGroupsTable = vehiclesStore.vehicleGroupsTable.filter((v) => v.vehicleGroupRef.id != id); - } -} diff --git a/src/components/VehiclesManager/VehiclesTable.vue b/src/components/VehiclesManager/VehiclesTable.vue index e65d5d8..a2e6b4a 100644 --- a/src/components/VehiclesManager/VehiclesTable.vue +++ b/src/components/VehiclesManager/VehiclesTable.vue @@ -57,22 +57,6 @@ - - {{ row.vehicleRef.group.name }} @@ -95,10 +79,6 @@ {{ row.vehicleRef.hidden ? '✅' : '❌' }} - - - remove - @@ -106,9 +86,9 @@