mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 05:28:13 +00:00
feature: routesInfo update
This commit is contained in:
+40
-100
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="bg" @click="closeRoutesModal"></div>
|
||||
<div class="routes-modal" v-if="store.currentStation">
|
||||
<div class="routes-modal" v-if="store.currentStation" @keydown.esc="closeRoutesModal" tabindex="0" ref="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-wrapper">
|
||||
<h1>
|
||||
@@ -11,7 +11,7 @@
|
||||
</h1>
|
||||
|
||||
<ul class="route-list">
|
||||
<li class="route" v-for="(route, i) in computedRouteList" :key="route.routeName + i">
|
||||
<li class="route" v-for="(route, i) in currentRoutes" :key="i">
|
||||
<form action="javascript:void(0);">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; gap: 1em">
|
||||
<span>
|
||||
@@ -23,7 +23,7 @@
|
||||
type="checkbox"
|
||||
:name="`${route.routeName}-internal`"
|
||||
:id="`${route.routeName}-internal`"
|
||||
v-model="route.routeIsInternal"
|
||||
v-model="route.isInternal"
|
||||
/>
|
||||
WEWNĘTRZNY
|
||||
</label>
|
||||
@@ -66,9 +66,9 @@
|
||||
type="radio"
|
||||
:name="`${route.routeName}-electr`"
|
||||
:id="`${route.routeName}-E`"
|
||||
:checked="route.routeElectrification == 'E'"
|
||||
:checked="route.isElectric"
|
||||
v-model="route.isElectric"
|
||||
value="E"
|
||||
v-model="route.routeElectrification"
|
||||
/>
|
||||
<span>Tak</span>
|
||||
</label>
|
||||
@@ -78,9 +78,9 @@
|
||||
type="radio"
|
||||
:name="`${route.routeName}-electr`"
|
||||
:id="`${route.routeName}-N`"
|
||||
:checked="route.routeElectrification == 'N'"
|
||||
:checked="!route.isElectric"
|
||||
v-model="route.isElectric"
|
||||
value="N"
|
||||
v-model="route.routeElectrification"
|
||||
/>
|
||||
<span>Nie</span>
|
||||
</label>
|
||||
@@ -93,9 +93,9 @@
|
||||
type="radio"
|
||||
:name="`${route.routeName}-block`"
|
||||
:id="`${route.routeName}-PBL`"
|
||||
:checked="route.routeBlockType == 'P'"
|
||||
:checked="!route.isRouteSBL"
|
||||
v-model="route.isRouteSBL"
|
||||
value="P"
|
||||
v-model="route.routeBlockType"
|
||||
/><span>PBL</span>
|
||||
</label>
|
||||
|
||||
@@ -104,39 +104,13 @@
|
||||
type="radio"
|
||||
:name="`${route.routeName}-block`"
|
||||
:id="`${route.routeName}-SBL`"
|
||||
:checked="route.routeBlockType == 'S'"
|
||||
:checked="route.isRouteSBL"
|
||||
v-model="route.isRouteSBL"
|
||||
value="S"
|
||||
v-model="route.routeBlockType"
|
||||
/><span>SBL</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<b>Blokada dwukierunkowa:</b>
|
||||
|
||||
<label class="radio-choice">
|
||||
<input
|
||||
type="radio"
|
||||
:name="`${route.routeName}-2twb`"
|
||||
:id="`${route.routeName}-twb`"
|
||||
:checked="route.routeHasTwoWayBlock"
|
||||
:value="true"
|
||||
v-model="route.routeHasTwoWayBlock"
|
||||
/><span>Tak</span>
|
||||
</label>
|
||||
|
||||
<label class="radio-choice">
|
||||
<input
|
||||
type="radio"
|
||||
:name="`${route.routeName}-2twb`"
|
||||
:id="`${route.routeName}-notwb`"
|
||||
:checked="!route.routeHasTwoWayBlock"
|
||||
:value="false"
|
||||
v-model="route.routeHasTwoWayBlock"
|
||||
/><span>Nie</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>Prędkość: <input type="number" v-model="route.routeSpeed" /> km/h</div>
|
||||
<div>Długość: <input type="number" v-model="route.routeLength" /> m</div>
|
||||
</form>
|
||||
@@ -154,59 +128,21 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, ref } from 'vue';
|
||||
import { Ref, computed, defineComponent, ref } from 'vue';
|
||||
import changeMixin from '../mixins/changeMixin';
|
||||
import { useStore } from '../store';
|
||||
import { SceneryRoutesInfo } from '../types/types';
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
const store = useStore();
|
||||
const currentRoutes = ref('');
|
||||
const routeBackup = ref('');
|
||||
|
||||
const computedRouteList = computed(() => {
|
||||
if (!store.currentStation) return [];
|
||||
|
||||
if (currentRoutes.value.length == 0) return [];
|
||||
|
||||
return currentRoutes.value.split(';').map((route) => {
|
||||
/*
|
||||
Route: !Oc_2EPB:100:3000
|
||||
! - szlak wewnętrzny (! - tak, brak wykrzyknika - nie)
|
||||
Oc - nazwa scenerii
|
||||
2 - liczba torów (1 lub 2)
|
||||
E - elektryfikacja (E - tak, N - nie)
|
||||
P - rodzaj blokady (P - PBL, S - SBL)
|
||||
B - blokada dwukierunkowa (B - tak, brak litery - nie)
|
||||
100 - vmax szlaku
|
||||
3000 - dł. szlaku
|
||||
*/
|
||||
const routeProps = route.split('_');
|
||||
const routeIsInternal = routeProps[0].startsWith('!');
|
||||
const routeName = routeIsInternal ? routeProps[0].replace('!', '') : routeProps[0];
|
||||
const routeSpeed = Number(route.split(':')[1]) || 0;
|
||||
const routeLength = Number(route.split(':')[2]) || 0;
|
||||
|
||||
const routeSpecs = routeProps[1];
|
||||
|
||||
return {
|
||||
routeName,
|
||||
routeTracks: Number(routeSpecs[0]),
|
||||
routeElectrification: routeSpecs[1],
|
||||
routeBlockType: routeSpecs[2],
|
||||
routeHasTwoWayBlock: routeSpecs[3] == 'B' ? true : false,
|
||||
routeIsInternal,
|
||||
routeSpeed,
|
||||
routeLength,
|
||||
};
|
||||
});
|
||||
});
|
||||
const currentRoutes: Ref<SceneryRoutesInfo[]> = ref([]);
|
||||
const routeBackup: Ref<SceneryRoutesInfo[]> = ref([]);
|
||||
|
||||
return {
|
||||
store,
|
||||
computedRouteList,
|
||||
currentRoutes,
|
||||
routeBackup,
|
||||
currentRoutes,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -216,40 +152,44 @@ export default defineComponent({
|
||||
|
||||
mounted() {
|
||||
if (this.store.currentStation) {
|
||||
this.currentRoutes = this.store.currentStation.routes;
|
||||
this.routeBackup = this.currentRoutes;
|
||||
// unrefed copy of routesInfo object
|
||||
this.currentRoutes = JSON.parse(JSON.stringify(this.store.currentStation.routesInfo));
|
||||
this.routeBackup = [...this.store.currentStation.routesInfo];
|
||||
|
||||
(this.$refs['modal'] as HTMLElement).focus();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
closeRoutesModal() {
|
||||
this.store.currentStation = null;
|
||||
this.currentRoutes = '';
|
||||
},
|
||||
|
||||
addNewRoute() {
|
||||
this.currentRoutes += (this.currentRoutes.length != 0 ? ';' : '') + `-_1EP:0:0`;
|
||||
// this.saveRoutes();
|
||||
this.currentRoutes.push({
|
||||
routeName: '-',
|
||||
isElectric: true,
|
||||
isInternal: false,
|
||||
isRouteSBL: false,
|
||||
routeLength: 0,
|
||||
routeSpeed: 0,
|
||||
routeTracks: 1,
|
||||
});
|
||||
this.saveRoutes();
|
||||
},
|
||||
|
||||
removeRoute(index: number) {
|
||||
this.currentRoutes = this.currentRoutes
|
||||
.split(';')
|
||||
.filter((_, i) => i != index)
|
||||
.join(';');
|
||||
|
||||
// this.saveRoutes();
|
||||
this.currentRoutes = this.currentRoutes.filter((_, i) => i !== index);
|
||||
this.saveRoutes();
|
||||
},
|
||||
|
||||
parseRoutes() {
|
||||
const routeString = this.computedRouteList
|
||||
const routeString = this.store.currentStation?.routesInfo
|
||||
.map(
|
||||
(route) =>
|
||||
`${route.routeIsInternal ? '!' : ''}${route.routeName.trim()}_${route.routeTracks}${
|
||||
route.routeElectrification
|
||||
}${route.routeBlockType}${route.routeHasTwoWayBlock ? 'B' : ''}:${route.routeSpeed || 0}:${
|
||||
route.routeLength || 0
|
||||
}`
|
||||
`${route.isInternal ? '!' : ''}${route.routeName.trim()}_${route.routeTracks}${
|
||||
route.isElectric ? 'E' : 'N'
|
||||
}${route.isRouteSBL ? 'S' : 'P'}:${route.routeSpeed || 0}:${route.routeLength || 0}`
|
||||
)
|
||||
.join(';');
|
||||
|
||||
@@ -263,9 +203,9 @@ export default defineComponent({
|
||||
|
||||
const routeString = this.parseRoutes();
|
||||
|
||||
this.addChange(this.store.currentStation!, 'routes', this.routeBackup, routeString);
|
||||
this.store.stationList[index]['routes'] = routeString;
|
||||
this.currentRoutes = routeString;
|
||||
this.addChange(this.store.currentStation!, 'routesInfo', this.routeBackup, this.currentRoutes);
|
||||
this.store.stationList[index]['routesInfo'] = this.currentRoutes;
|
||||
// this.currentRoutes.push(this.cur)
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import routesMixin from '../mixins/routesMixin';
|
||||
import { useStore } from '../store';
|
||||
import { AuthState, Availability, ChangeProp, HeaderTypes, SceneryRowItem } from '../types/types';
|
||||
import { AuthState, Availability, ChangeProp, HeaderTypes, SceneryRoutesInfo, SceneryRowItem } from '../types/types';
|
||||
import { getAvailabilityValue } from '../types/typeUitls';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -122,7 +122,7 @@ export default defineComponent({
|
||||
: changeItem[propChange];
|
||||
|
||||
if (propChange == 'availability') value = getAvailabilityValue(changeItem[propChange] as Availability);
|
||||
if (propChange == 'routes') value = this.getRouteNames(changeItem[propChange] as string, true);
|
||||
if (propChange == 'routesInfo') value = this.getRouteNames(changeItem[propChange] as SceneryRoutesInfo[]);
|
||||
|
||||
itemChanges.push(`<i>${(HeaderTypes as any)[propChange]}:</i> ${value || '-'}`);
|
||||
}
|
||||
@@ -215,6 +215,17 @@ export default defineComponent({
|
||||
controlType: 'SCS',
|
||||
SUP: false,
|
||||
routes: 'Test_1EPB:0:0',
|
||||
routesInfo: [
|
||||
{
|
||||
isElectric: true,
|
||||
isInternal: false,
|
||||
isRouteSBL: false,
|
||||
routeLength: 0,
|
||||
routeSpeed: 0,
|
||||
routeTracks: 1,
|
||||
routeName: 'Test',
|
||||
},
|
||||
],
|
||||
checkpoints: '',
|
||||
authors: '',
|
||||
availability: 'default',
|
||||
|
||||
Reference in New Issue
Block a user