mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 05:28:13 +00:00
chore: added creating new vehicles
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
<td style="width: 100px">Grupa</td>
|
||||
<td style="width: 100px">Tylko sponsorzy do</td>
|
||||
<td style="width: 100px">Tylko zespół</td>
|
||||
<td style="width: 50px">Ukryty</td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -47,6 +48,9 @@
|
||||
|
||||
<span v-else>❌</span>
|
||||
</td>
|
||||
<td class="editable" @click="editRowPrimitive(row, VehicleEditRowKey.HIDDEN)">
|
||||
{{ row.vehicleRef.hidden ? '✅' : '❌' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -71,14 +75,24 @@ const vehiclesTableComp = computed(() => {
|
||||
|
||||
async function editRowPrimitive(row: IVehicleTableRow, editKey: VehicleEditRowKey) {
|
||||
if (!(editKey in row.vehicleRef)) return;
|
||||
|
||||
let rowValue = row.vehicleRef[editKey];
|
||||
|
||||
const promptValue = prompt('Zmień wartość:', row.vehicleRef[editKey]);
|
||||
if (promptValue == null) return;
|
||||
if (typeof rowValue === 'string' || typeof rowValue === 'undefined' || rowValue == null) {
|
||||
const promptValue = prompt('Zmień wartość:', rowValue ?? '');
|
||||
if (promptValue == null) return;
|
||||
|
||||
const updatedData = await vehiclesStore.updateVehicle(row.vehicleRef.id, editKey, promptValue);
|
||||
const updatedData = await vehiclesStore.updateVehicle(row.vehicleRef.id, editKey, promptValue);
|
||||
|
||||
if (updatedData) {
|
||||
row.vehicleRef[editKey] = updatedData[editKey]!;
|
||||
if (updatedData) {
|
||||
(row.vehicleRef[editKey] as any) = updatedData[editKey];
|
||||
}
|
||||
} else if (typeof rowValue == 'boolean') {
|
||||
const updatedData = await vehiclesStore.updateVehicle(row.vehicleRef.id, editKey, !rowValue);
|
||||
|
||||
if (updatedData) {
|
||||
(row.vehicleRef[editKey] as any) = updatedData[editKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +134,26 @@ async function editRowRestrictions(row: IVehicleTableRow, editKey: VehicleEditRe
|
||||
}
|
||||
}
|
||||
|
||||
function addVehicleRow() {}
|
||||
async function addVehicleRow() {
|
||||
const createdVehicleData = await vehiclesStore.createVehicle({
|
||||
name: 'Vehicle-' + Date.now(),
|
||||
type: 'loco-electric',
|
||||
hidden: true,
|
||||
vehicleGroupsId: 1,
|
||||
});
|
||||
|
||||
if (createdVehicleData) {
|
||||
vehiclesStore.vehiclesTable.push({
|
||||
vehicleRef: {
|
||||
...createdVehicleData,
|
||||
group: vehiclesStore.vehicleGroupsTable.find((g) => g.vehicleGroupRef.id == createdVehicleData.vehicleGroupsId)!
|
||||
.vehicleGroupRef,
|
||||
},
|
||||
});
|
||||
|
||||
vehicleSearchInput.value = createdVehicleData.name;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
||||
Reference in New Issue
Block a user