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)">
|
<td class="editable" @click="selectRowVehicleGroup(row)">
|
||||||
<select
|
<select
|
||||||
v-if="currentEditingGroupId == row.vehicleRef.id"
|
v-if="currentEditingGroupId == row.vehicleRef.id"
|
||||||
@blur="currentEditingGroupId = -1"
|
@blur="(e) => editVehicleGroup(e, row)"
|
||||||
@change="(e) => editVehicleGroup(e, row)"
|
|
||||||
:id="`select-group-${row.vehicleRef.id}`"
|
:id="`select-group-${row.vehicleRef.id}`"
|
||||||
ref="select-group"
|
ref="select-group"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@@ -176,13 +175,18 @@ async function selectRowVehicleGroup(row: IVehicleTableRow) {
|
|||||||
async function editVehicleGroup(e: Event, row: IVehicleTableRow) {
|
async function editVehicleGroup(e: Event, row: IVehicleTableRow) {
|
||||||
const id = (e.target as HTMLSelectElement).value;
|
const id = (e.target as HTMLSelectElement).value;
|
||||||
|
|
||||||
const updatedData = await vehiclesStore.updateVehicle(row.vehicleRef.id, 'vehicleGroupId', +id);
|
|
||||||
|
|
||||||
if (updatedData) {
|
if (row.vehicleRef.group.id !== +id) {
|
||||||
row.vehicleRef.group = vehiclesStore.vehicleGroupsTable.find(
|
const updatedData = await vehiclesStore.updateVehicle(row.vehicleRef.id, 'vehicleGroupId', +id);
|
||||||
(g) => g.vehicleGroupRef.id == updatedData.vehicleGroupsId,
|
|
||||||
)!.vehicleGroupRef;
|
if (updatedData) {
|
||||||
|
row.vehicleRef.group = vehiclesStore.vehicleGroupsTable.find(
|
||||||
|
(g) => g.vehicleGroupRef.id == updatedData.vehicleGroupsId,
|
||||||
|
)!.vehicleGroupRef;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentEditingGroupId.value = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addVehicleRow() {
|
async function addVehicleRow() {
|
||||||
|
|||||||
Reference in New Issue
Block a user