mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 11:45:34 +00:00
stockObject & static handling hotfixes
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
type="image/jpeg"
|
type="image/jpeg"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<img v-else src="images/placeholder.jpg" alt="placeholder" />
|
<img v-else src="/images/placeholder.jpg" alt="placeholder" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="train-image__info" v-if="store.chosenVehicle">
|
<div class="train-image__info" v-if="store.chosenVehicle">
|
||||||
|
|||||||
+15
-21
@@ -1,7 +1,7 @@
|
|||||||
import { defineComponent } from "vue";
|
import { defineComponent } from 'vue';
|
||||||
import { useStore } from "../store";
|
import { useStore } from '../store';
|
||||||
import { ICargo, ICarWagon, ILocomotive, IStock, Vehicle } from "../types";
|
import { ICargo, ICarWagon, ILocomotive, IStock, Vehicle } from '../types';
|
||||||
import { isLocomotive } from "../utils/vehicleUtils";
|
import { isLocomotive } from '../utils/vehicleUtils';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
setup() {
|
setup() {
|
||||||
@@ -31,6 +31,7 @@ export default defineComponent({
|
|||||||
useType: isLoco ? vehicle.power : vehicle.useType,
|
useType: isLoco ? vehicle.power : vehicle.useType,
|
||||||
isSponsorsOnly: vehicle.isSponsorsOnly,
|
isSponsorsOnly: vehicle.isSponsorsOnly,
|
||||||
constructionType: vehicle.constructionType,
|
constructionType: vehicle.constructionType,
|
||||||
|
sponsorsOnlyTimestamp: vehicle.sponsorsOnlyTimestamp,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -39,16 +40,14 @@ export default defineComponent({
|
|||||||
|
|
||||||
const stock = this.getStockObject(vehicle, cargo);
|
const stock = this.getStockObject(vehicle, cargo);
|
||||||
|
|
||||||
if (stock.isLoco && !this.store.stockList[0]?.isLoco)
|
if (stock.isLoco && !this.store.stockList[0]?.isLoco) this.store.stockList.unshift(stock);
|
||||||
this.store.stockList.unshift(stock);
|
|
||||||
else this.store.stockList.push(stock);
|
else this.store.stockList.push(stock);
|
||||||
},
|
},
|
||||||
|
|
||||||
addLocomotive(loco: ILocomotive) {
|
addLocomotive(loco: ILocomotive) {
|
||||||
const stockObj = this.getStockObject(loco);
|
const stockObj = this.getStockObject(loco);
|
||||||
|
|
||||||
if (this.store.stockList.length > 0 && !this.store.stockList[0].isLoco)
|
if (this.store.stockList.length > 0 && !this.store.stockList[0].isLoco) this.store.stockList.unshift(stockObj);
|
||||||
this.store.stockList.unshift(stockObj);
|
|
||||||
else this.store.stockList.push(stockObj);
|
else this.store.stockList.push(stockObj);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadStockFromString(stockString: string) {
|
loadStockFromString(stockString: string) {
|
||||||
const stockArray = stockString.trim().split(";");
|
const stockArray = stockString.trim().split(';');
|
||||||
|
|
||||||
this.store.stockList.length = 0;
|
this.store.stockList.length = 0;
|
||||||
this.store.chosenVehicle = null;
|
this.store.chosenVehicle = null;
|
||||||
@@ -75,23 +74,18 @@ export default defineComponent({
|
|||||||
let vehicleCargo: ICargo | null = null;
|
let vehicleCargo: ICargo | null = null;
|
||||||
|
|
||||||
if (/^(EU|EP|ET|SM|EN|2EN|SN)/.test(type)) {
|
if (/^(EU|EP|ET|SM|EN|2EN|SN)/.test(type)) {
|
||||||
const [locoType, coldStart] = type.split(",");
|
const [locoType, coldStart] = type.split(',');
|
||||||
vehicle =
|
vehicle = this.store.locoDataList.find((loco) => loco.type == locoType) || null;
|
||||||
this.store.locoDataList.find((loco) => loco.type == locoType) ||
|
|
||||||
null;
|
|
||||||
|
|
||||||
if (i == 0 && coldStart == "c") this.store.isColdStart = true;
|
if (i == 0 && coldStart == 'c') this.store.isColdStart = true;
|
||||||
} else {
|
} else {
|
||||||
const [carType, cargo] = type.split(":");
|
const [carType, cargo] = type.split(':');
|
||||||
vehicle =
|
vehicle = this.store.carDataList.find((car) => car.type == carType) || null;
|
||||||
this.store.carDataList.find((car) => car.type == carType) || null;
|
|
||||||
|
|
||||||
if (cargo)
|
if (cargo) vehicleCargo = vehicle?.cargoList.find((c) => c.id == cargo) || null;
|
||||||
vehicleCargo =
|
|
||||||
vehicle?.cargoList.find((c) => c.id == cargo) || null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vehicle) console.log("Brak pojazdu:", type);
|
if (!vehicle) console.log('Brak pojazdu:', type);
|
||||||
|
|
||||||
this.addVehicle(vehicle, vehicleCargo);
|
this.addVehicle(vehicle, vehicleCargo);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user