mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 13:38:13 +00:00
chore: added removing vehicles
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
<td style="width: 100px">Tylko sponsorzy do</td>
|
<td style="width: 100px">Tylko sponsorzy do</td>
|
||||||
<td style="width: 100px">Tylko zespół</td>
|
<td style="width: 100px">Tylko zespół</td>
|
||||||
<td style="width: 50px">Ukryty</td>
|
<td style="width: 50px">Ukryty</td>
|
||||||
|
<td style="width: 50px">Usuń</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@
|
|||||||
<td class="editable" @click="editRowPrimitive(row, VehicleEditRowKey.HIDDEN)">
|
<td class="editable" @click="editRowPrimitive(row, VehicleEditRowKey.HIDDEN)">
|
||||||
{{ row.vehicleRef.hidden ? '✅' : '❌' }}
|
{{ row.vehicleRef.hidden ? '✅' : '❌' }}
|
||||||
</td>
|
</td>
|
||||||
|
<td @click="removeVehicle(row.vehicleRef.id)"><img src="/icon-trash.svg" alt="remove" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -75,7 +77,7 @@ const vehiclesTableComp = computed(() => {
|
|||||||
|
|
||||||
async function editRowPrimitive(row: IVehicleTableRow, editKey: VehicleEditRowKey) {
|
async function editRowPrimitive(row: IVehicleTableRow, editKey: VehicleEditRowKey) {
|
||||||
if (!(editKey in row.vehicleRef)) return;
|
if (!(editKey in row.vehicleRef)) return;
|
||||||
|
|
||||||
let rowValue = row.vehicleRef[editKey];
|
let rowValue = row.vehicleRef[editKey];
|
||||||
|
|
||||||
if (typeof rowValue === 'string' || typeof rowValue === 'undefined' || rowValue == null) {
|
if (typeof rowValue === 'string' || typeof rowValue === 'undefined' || rowValue == null) {
|
||||||
@@ -154,6 +156,14 @@ async function addVehicleRow() {
|
|||||||
vehicleSearchInput.value = createdVehicleData.name;
|
vehicleSearchInput.value = createdVehicleData.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function removeVehicle(id: number) {
|
||||||
|
const removedVehicleData = await vehiclesStore.removeVehicle(id);
|
||||||
|
|
||||||
|
if (removedVehicleData) {
|
||||||
|
vehiclesStore.vehiclesTable = vehiclesStore.vehiclesTable.filter((v) => v.vehicleRef.id != id);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style></style>
|
||||||
|
|||||||
@@ -83,5 +83,17 @@ export const useVehiclesStore = defineStore('vehiclesStore', {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async removeVehicle(vehicleId: number) {
|
||||||
|
try {
|
||||||
|
const response = await client.delete<IVehicleAPI>(`/manager/vehicles/${vehicleId}`);
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user