mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-05 04:28:10 +00:00
Karta losowania: usprawniono podgląd wagonów
This commit is contained in:
@@ -47,14 +47,10 @@
|
|||||||
<span class="preview-message" v-if="!randomFocusedWagonVariant"
|
<span class="preview-message" v-if="!randomFocusedWagonVariant"
|
||||||
>WYBIERZ POJAZD LUB WAGON, BY ZOBACZYĆ JEGO PODGLĄD</span
|
>WYBIERZ POJAZD LUB WAGON, BY ZOBACZYĆ JEGO PODGLĄD</span
|
||||||
>
|
>
|
||||||
<span class="preview-message info" v-else
|
<span class="preview-message info" v-else>
|
||||||
>{{ randomFocusedWagonVariant.type }} (1 z {{ focusedCarWagon!.availableCars.length }})</span
|
{{ randomFocusedWagonVariant.type }} (1 z {{ focusedCarWagon!.availableCars.length }})
|
||||||
>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <b class="text--accent" v-if="focusedCar">
|
|
||||||
{{ focusedCar.type.split('_')[0] }} {{ focusedCar.type.split('_')[2] }}
|
|
||||||
</b> -->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -197,6 +193,20 @@ export default defineComponent({
|
|||||||
randomFocusedWagonVariant: undefined as ICarWagon | undefined,
|
randomFocusedWagonVariant: undefined as ICarWagon | undefined,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
'focusedCarWagon.availableCars': {
|
||||||
|
handler(cars?: RandomStockCarWagon['availableCars'], prevCars?: RandomStockCarWagon['availableCars']) {
|
||||||
|
const prevAvailableCarsStr = prevCars?.map((car) => car.type).join(',') || '';
|
||||||
|
const availableCarsStr = cars?.map((car) => car.type).join(',') || '';
|
||||||
|
|
||||||
|
if (prevAvailableCarsStr != availableCarsStr) {
|
||||||
|
this.randomFocusedWagonVariant =
|
||||||
|
this.focusedCarWagon?.availableCars[~~(Math.random() * this.focusedCarWagon.availableCars.length)];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
allCarOptionsList() {
|
allCarOptionsList() {
|
||||||
const list: string[] = [];
|
const list: string[] = [];
|
||||||
@@ -235,15 +245,12 @@ export default defineComponent({
|
|||||||
carWagon.chosenCargo = undefined;
|
carWagon.chosenCargo = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onCarWagonTypeFocus(carWagon);
|
// this.onCarWagonTypeFocus(carWagon);
|
||||||
},
|
},
|
||||||
|
|
||||||
onCarWagonTypeFocus(carWagon: RandomStockCarWagon) {
|
onCarWagonTypeFocus(carWagon: RandomStockCarWagon) {
|
||||||
const prevVariantsCount = this.focusedCarWagon?.availableCars.length || 0;
|
const prevVariantsCount = this.focusedCarWagon?.availableCars.length || 0;
|
||||||
|
|
||||||
console.log(prevVariantsCount);
|
|
||||||
|
|
||||||
|
|
||||||
this.focusedCarWagon = carWagon;
|
this.focusedCarWagon = carWagon;
|
||||||
|
|
||||||
if (prevVariantsCount != carWagon.availableCars.length)
|
if (prevVariantsCount != carWagon.availableCars.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user