mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 13:38:13 +00:00
fix: updating cargo types prop
This commit is contained in:
@@ -135,14 +135,16 @@ onMounted(() => {
|
||||
vehiclesStore.vehiclesTable.find((v) => v.vehicleRef.id == vehiclesStore.selectedVehicleId)?.vehicleRef ?? null;
|
||||
|
||||
if (currentVehicleRef.value) {
|
||||
const lastProps = vehiclesStore.lastVehicleUpdateProps;
|
||||
|
||||
vehicleValues.name = currentVehicleRef.value.name || '';
|
||||
vehicleValues.cabinName = currentVehicleRef.value.cabinName || '';
|
||||
vehicleValues.type = currentVehicleRef.value.type || '';
|
||||
vehicleValues.vehicleGroupsId = currentVehicleRef.value.vehicleGroupsId || 0;
|
||||
vehicleValues.hidden = currentVehicleRef.value.hidden;
|
||||
vehicleValues.cabinName = lastProps.cabinName || currentVehicleRef.value.cabinName;
|
||||
vehicleValues.type = lastProps.type || currentVehicleRef.value.type || '';
|
||||
vehicleValues.vehicleGroupsId = lastProps.vehicleGroupsId || currentVehicleRef.value.vehicleGroupsId || 0;
|
||||
vehicleValues.hidden = lastProps.hidden || currentVehicleRef.value.hidden;
|
||||
vehicleValues.restrictions = {
|
||||
sponsorOnly: currentVehicleRef.value.restrictions?.sponsorOnly ?? null,
|
||||
teamOnly: currentVehicleRef.value.restrictions?.teamOnly ?? false,
|
||||
sponsorOnly: lastProps.restrictions?.sponsorOnly ?? currentVehicleRef.value.restrictions?.sponsorOnly ?? null,
|
||||
teamOnly: lastProps.restrictions?.teamOnly ?? currentVehicleRef.value.restrictions?.teamOnly ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -197,6 +199,8 @@ async function updateVehicle() {
|
||||
oldGroup._count.vehicles -= 1;
|
||||
newGroup._count.vehicles += 1;
|
||||
|
||||
vehiclesStore.lastVehicleUpdateProps = updatedData;
|
||||
|
||||
alert('Zaktualizowano pojazd: ' + updatedData.name);
|
||||
} catch (error) {
|
||||
alert(handleAPIErrors(error));
|
||||
|
||||
@@ -72,7 +72,9 @@
|
||||
<input type="checkbox" id="include-cargo-types" v-model="includeCargoTypes" />
|
||||
<label for="include-cargo-types">Ładunki (wagon):</label>
|
||||
<br />
|
||||
<textarea name="" id="">{{ JSON.stringify(vehicleGroupValues.cargoTypes) }}</textarea>
|
||||
<textarea name="cargo-types-textarea" id="cargo-types-textarea" v-model="cargoTypesJsonString">{{
|
||||
JSON.stringify(vehicleGroupValues.cargoTypes)
|
||||
}}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="details-mass-speeds">
|
||||
@@ -80,7 +82,7 @@
|
||||
<label for="include-mass-speeds">Dopuszczalne masy:</label>
|
||||
(JSON: {{ isMassSpeedsJsonValid ? 'poprawny' : 'niepoprawny' }})
|
||||
<br />
|
||||
<textarea name="" id="" v-model="massSpeedsJsonString">{{
|
||||
<textarea name="mass-speeds-textarea" id="mass-speeds-textarea" v-model="massSpeedsJsonString">{{
|
||||
JSON.stringify(vehicleGroupValues.massSpeeds)
|
||||
}}</textarea>
|
||||
</div>
|
||||
@@ -171,16 +173,18 @@ watch(massSpeedsJsonString, (val) => {
|
||||
function populateVehicleGroupValues(vehicleGroup: IVehicleGroup) {
|
||||
if (!vehicleGroup.locoProps) currentVehicleGroupType.value = 'wagon';
|
||||
|
||||
vehicleGroupValues.name = vehicleGroup.name || '';
|
||||
vehicleGroupValues.length = vehicleGroup.length || 0;
|
||||
vehicleGroupValues.weight = vehicleGroup.weight || 0;
|
||||
vehicleGroupValues.speed = vehicleGroup.speed || 0;
|
||||
vehicleGroupValues.speedLoco = vehicleGroup.speedLoco || null;
|
||||
vehicleGroupValues.speedLoaded = vehicleGroup.speedLoaded || null;
|
||||
const lastProps = vehiclesStore.lastVehicleGroupUpdateProps;
|
||||
|
||||
vehicleGroupValues.name = lastProps.name || vehicleGroup.name || '';
|
||||
vehicleGroupValues.length = lastProps.length || vehicleGroup.length || 0;
|
||||
vehicleGroupValues.weight = lastProps.weight || vehicleGroup.weight || 0;
|
||||
vehicleGroupValues.speed = lastProps.speed || vehicleGroup.speed || 0;
|
||||
vehicleGroupValues.speedLoco = lastProps.speedLoco || vehicleGroup.speedLoco || null;
|
||||
vehicleGroupValues.speedLoaded = lastProps.speedLoaded || vehicleGroup.speedLoaded || null;
|
||||
|
||||
vehicleGroupValues.locoProps = {
|
||||
coldStart: vehicleGroup.locoProps?.coldStart ?? false,
|
||||
doubleManned: vehicleGroup.locoProps?.doubleManned ?? false,
|
||||
coldStart: lastProps.locoProps?.coldStart ?? vehicleGroup.locoProps?.coldStart ?? false,
|
||||
doubleManned: lastProps.locoProps?.doubleManned ?? vehicleGroup.locoProps?.doubleManned ?? false,
|
||||
};
|
||||
|
||||
vehicleGroupValues.cargoTypes = [];
|
||||
|
||||
Reference in New Issue
Block a user