From 1e92c64ae645714a29b5c1cb99cb6fd3c4aa70a4 Mon Sep 17 00:00:00 2001 From: Spythere Date: Thu, 6 Jul 2023 22:14:40 +0200 Subject: [PATCH] feature: tabela z pojazdami i wagonami --- src/components/sections/StockSection.vue | 7 +- src/components/tabs/WikiListTab.vue | 174 +++++++++++++++++++++++ src/mixins/stockPreviewMixin.ts | 30 ++-- src/store.ts | 2 +- src/types.ts | 4 +- 5 files changed, 204 insertions(+), 13 deletions(-) create mode 100644 src/components/tabs/WikiListTab.vue diff --git a/src/components/sections/StockSection.vue b/src/components/sections/StockSection.vue index d6dfb39..483e849 100644 --- a/src/components/sections/StockSection.vue +++ b/src/components/sections/StockSection.vue @@ -25,12 +25,14 @@ import { useStore } from '../../store'; import StockListTab from '../tabs/StockListTab.vue'; import StockGeneratorTab from '../tabs/StockGeneratorTab.vue'; import NumberGeneratorTab from '../tabs/NumberGeneratorTab.vue'; +import WikiListTab from '../tabs/WikiListTab.vue'; const store = useStore(); type SectionMode = typeof store.stockSectionMode; const sectionModes: { [key: string]: SectionMode } = { SKŁAD: 'stock-list', + POJAZDY: 'wiki-list', 'GNR NUMERU': 'number-generator', 'GNR SKŁADU': 'stock-generator', }; @@ -40,6 +42,9 @@ const chosenSectionComponent = computed(() => { case 'stock-list': return StockListTab; + case 'wiki-list': + return WikiListTab; + case 'stock-generator': return StockGeneratorTab; @@ -83,7 +88,7 @@ function chooseSection(sectionId: SectionMode) { .section_modes { display: grid; - grid-template-columns: repeat(3, 1fr); + grid-template-columns: repeat(4, 1fr); gap: 0.5em; margin-bottom: 0.5em; diff --git a/src/components/tabs/WikiListTab.vue b/src/components/tabs/WikiListTab.vue new file mode 100644 index 0000000..ac72c6b --- /dev/null +++ b/src/components/tabs/WikiListTab.vue @@ -0,0 +1,174 @@ + + + + + diff --git a/src/mixins/stockPreviewMixin.ts b/src/mixins/stockPreviewMixin.ts index 844025c..30a8781 100644 --- a/src/mixins/stockPreviewMixin.ts +++ b/src/mixins/stockPreviewMixin.ts @@ -1,6 +1,6 @@ import { defineComponent } from 'vue'; import { useStore } from '../store'; -import { IStock, Vehicle } from '../types'; +import { ICarWagon, ILocomotive, IStock, Vehicle } from '../types'; export default defineComponent({ setup() { @@ -48,7 +48,7 @@ export default defineComponent({ }); }, - previewStock(stock: IStock) { + previewStock(stock: IStock) { if (this.store.chosenVehicle?.imageSrc != stock.imgSrc) this.store.imageLoading = true; if (stock.isLoco) { @@ -67,14 +67,26 @@ export default defineComponent({ } }, + previewLocomotive(loco: ILocomotive) { + this.store.chosenLoco = loco; + this.store.chosenVehicle = loco; + this.store.chosenLocoPower = loco.power; + }, + + previewCarWagon(carWagon: ICarWagon) { + this.store.chosenCar = carWagon; + this.store.chosenCarUseType = carWagon.useType; + this.store.chosenVehicle = carWagon; + + this.store.chosenCargo = null; + }, + resetPreview() { - this.store.chosenVehicle = null; - this.store.chosenCar = null; - this.store.chosenCargo = null; - this.store.chosenLoco = null; - } + this.store.chosenVehicle = null; + this.store.chosenCar = null; + this.store.chosenCargo = null; + this.store.chosenLoco = null; + }, }, }); - - diff --git a/src/store.ts b/src/store.ts index c35932c..2cf714e 100644 --- a/src/store.ts +++ b/src/store.ts @@ -38,7 +38,7 @@ export const useStore = defineStore({ vehiclePreviewSrc: '', - stockSectionMode: 'stock-list', + stockSectionMode: 'wiki-list', isRandomizerCardOpen: false, isRealStockListCardOpen: false, diff --git a/src/types.ts b/src/types.ts index 711fc89..d1bad05 100644 --- a/src/types.ts +++ b/src/types.ts @@ -27,7 +27,7 @@ export interface IStore { isRandomizerCardOpen: boolean; isRealStockListCardOpen: boolean; - stockSectionMode: 'stock-list' | 'stock-generator' | 'number-generator'; + stockSectionMode: 'stock-list' | 'stock-generator' | 'number-generator' | 'wiki-list'; stockData?: IStockData; } @@ -42,7 +42,7 @@ export interface IStockProps { export interface IStockData { version: string; - + generator: { passenger: any; cargo: {