mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 05:28:13 +00:00
chore: added posting update to API on select blur
This commit is contained in:
@@ -39,8 +39,7 @@
|
||||
<td class="editable" @click="selectRowVehicleGroup(row)">
|
||||
<select
|
||||
v-if="currentEditingGroupId == row.vehicleRef.id"
|
||||
@blur="currentEditingGroupId = -1"
|
||||
@change="(e) => editVehicleGroup(e, row)"
|
||||
@blur="(e) => editVehicleGroup(e, row)"
|
||||
:id="`select-group-${row.vehicleRef.id}`"
|
||||
ref="select-group"
|
||||
style="width: 100%"
|
||||
@@ -176,13 +175,18 @@ async function selectRowVehicleGroup(row: IVehicleTableRow) {
|
||||
async function editVehicleGroup(e: Event, row: IVehicleTableRow) {
|
||||
const id = (e.target as HTMLSelectElement).value;
|
||||
|
||||
const updatedData = await vehiclesStore.updateVehicle(row.vehicleRef.id, 'vehicleGroupId', +id);
|
||||
|
||||
if (updatedData) {
|
||||
row.vehicleRef.group = vehiclesStore.vehicleGroupsTable.find(
|
||||
(g) => g.vehicleGroupRef.id == updatedData.vehicleGroupsId,
|
||||
)!.vehicleGroupRef;
|
||||
if (row.vehicleRef.group.id !== +id) {
|
||||
const updatedData = await vehiclesStore.updateVehicle(row.vehicleRef.id, 'vehicleGroupId', +id);
|
||||
|
||||
if (updatedData) {
|
||||
row.vehicleRef.group = vehiclesStore.vehicleGroupsTable.find(
|
||||
(g) => g.vehicleGroupRef.id == updatedData.vehicleGroupsId,
|
||||
)!.vehicleGroupRef;
|
||||
}
|
||||
}
|
||||
|
||||
currentEditingGroupId.value = -1;
|
||||
}
|
||||
|
||||
async function addVehicleRow() {
|
||||
|
||||
Reference in New Issue
Block a user