feature: vmax i dł. szlaków

This commit is contained in:
2023-02-11 17:38:57 +01:00
parent 817d48d17a
commit 14ec54d11d
5 changed files with 460 additions and 371 deletions
+4
View File
@@ -87,6 +87,10 @@ html {
margin: 0; margin: 0;
background-color: #1e2341; background-color: #1e2341;
color: white; color: white;
@media screen and (max-width: 600px) {
font-size: calc(0.7vw + 0.7rem);
}
} }
button { button {
+275 -190
View File
@@ -1,191 +1,224 @@
<template> <template>
<div class="bg" @click="closeRoutesModal"></div>
<div class="routes-modal" v-if="store.currentStation"> <div class="routes-modal" v-if="store.currentStation">
<div class="exit" @click="closeRoutesModal"> <div class="modal-content">
<img src="/icon-exit.svg" alt="exit icon" /> <div class="modal-wrapper">
</div> <h1>
Szlaki na scenerii {{ store.currentStation.name }}
<div class="exit" @click="closeRoutesModal">
<img src="/icon-exit.svg" alt="exit icon" />
</div>
</h1>
<div class="modal-wrapper"> <ul class="route-list">
<h1>Szlaki na scenerii {{ store.currentStation.name }}</h1> <li class="route" v-for="(route, i) in computedRouteList" :key="route.routeName + i">
<form action="javascript:void(0);">
<div style="display: flex; justify-content: space-between; align-items: center; gap: 1em">
<span>
Szlak: <input type="text" v-model="route.routeName" />
&nbsp;
<ul class="route-list"> <label :for="`${route.routeName}-internal`" style="display: inline-block">
<li class="route" v-for="(route, i) in computedRouteList" :key="route.routeName + i"> <input
<img @click="removeRoute(i)" class="route-delete" src="/icon-trash.svg" alt="icon trash" /> type="checkbox"
:name="`${route.routeName}-internal`"
:id="`${route.routeName}-internal`"
v-model="route.routeIsInternal"
/>
WEWNĘTRZNY
</label>
</span>
<form action="javascript:void(0);"> <img @click="removeRoute(i)" class="route-delete" src="/icon-trash.svg" alt="icon trash" />
<div>Szlak: <input type="text" v-model="route.routeName" /></div> </div>
<div>
<input
type="checkbox"
:name="`${route.routeName}-internal`"
:id="`${route.routeName}-internal`"
v-model="route.routeIsInternal"
/>
<label :for="`${route.routeName}-internal`">Szlak wewnętrzny</label>
</div>
<div> <div>
<span>Liczba torów: </span> <b>Liczba torów:</b>
<input <label class="radio-choice">
type="radio" <input
:name="`${route.routeName}-tracks`" type="radio"
:id="`${route.routeName}-track1`" :name="`${route.routeName}-tracks`"
:value="Number(1)" :id="`${route.routeName}-track1`"
:checked="route.routeTracks == 1" :value="1"
v-model="route.routeTracks" :checked="route.routeTracks == 1"
/> v-model="route.routeTracks"
<label :for="`${route.routeName}-track1`">1</label> />
<span>1</span>
</label>
<input <label class="radio-choice">
type="radio" <input
:name="`${route.routeName}-tracks`" type="radio"
:id="`${route.routeName}-track2`" :name="`${route.routeName}-tracks`"
:value="Number(2)" :id="`${route.routeName}-track2`"
:checked="route.routeTracks == 2" :value="Number(2)"
v-model="route.routeTracks" :checked="route.routeTracks == 2"
/> v-model="route.routeTracks"
<label :for="`${route.routeName}-track2`">2</label> />
</div> <span>2</span>
<div> </label>
<span>Elektryfikacja: </span> </div>
<div>
<b>Elektryfikacja:</b>
<input <label class="radio-choice">
type="radio" <input
:name="`${route.routeName}-electr`" type="radio"
:id="`${route.routeName}-E`" :name="`${route.routeName}-electr`"
:checked="route.routeElectrification == 'E'" :id="`${route.routeName}-E`"
value="E" :checked="route.routeElectrification == 'E'"
v-model="route.routeElectrification" value="E"
/> v-model="route.routeElectrification"
<label :for="`${route.routeName}-E`">Tak</label> />
<span>Tak</span>
</label>
<input <label class="radio-choice" :for="`${route.routeName}-N`">
type="radio" <input
:name="`${route.routeName}-electr`" type="radio"
:id="`${route.routeName}-N`" :name="`${route.routeName}-electr`"
:checked="route.routeElectrification == 'N'" :id="`${route.routeName}-N`"
value="N" :checked="route.routeElectrification == 'N'"
v-model="route.routeElectrification" value="N"
/> v-model="route.routeElectrification"
<label :for="`${route.routeName}-N`">Nie</label> />
</div> <span>Nie</span>
<div> </label>
<span>Typ blokady: </span> </div>
<div>
<b>Typ blokady:</b>
<input <label class="radio-choice">
type="radio" <input
:name="`${route.routeName}-block`" type="radio"
:id="`${route.routeName}-PBL`" :name="`${route.routeName}-block`"
:checked="route.routeBlockType == 'P'" :id="`${route.routeName}-PBL`"
value="P" :checked="route.routeBlockType == 'P'"
v-model="route.routeBlockType" value="P"
/> v-model="route.routeBlockType"
<label :for="`${route.routeName}-PBL`">PBL</label> /><span>PBL</span>
</label>
<input <label class="radio-choice">
type="radio" <input
:name="`${route.routeName}-block`" type="radio"
:id="`${route.routeName}-SBL`" :name="`${route.routeName}-block`"
:checked="route.routeBlockType == 'S'" :id="`${route.routeName}-SBL`"
value="S" :checked="route.routeBlockType == 'S'"
v-model="route.routeBlockType" value="S"
/> v-model="route.routeBlockType"
<label :for="`${route.routeName}-SBL`">SBL</label> /><span>SBL</span>
</div> </label>
</div>
<div> <div>
<span>Blokada dwukierunkowa: </span> <b>Blokada dwukierunkowa:</b>
<input <label class="radio-choice">
type="radio" <input
:name="`${route.routeName}-2twb`" type="radio"
:id="`${route.routeName}-twb`" :name="`${route.routeName}-2twb`"
:checked="route.routeHasTwoWayBlock" :id="`${route.routeName}-twb`"
:value="true" :checked="route.routeHasTwoWayBlock"
v-model="route.routeHasTwoWayBlock" :value="true"
/> v-model="route.routeHasTwoWayBlock"
<label :for="`${route.routeName}-twb`">Tak</label> /><span>Tak</span>
</label>
<input <label class="radio-choice">
type="radio" <input
:name="`${route.routeName}-2twb`" type="radio"
:id="`${route.routeName}-notwb`" :name="`${route.routeName}-2twb`"
:checked="!route.routeHasTwoWayBlock" :id="`${route.routeName}-notwb`"
:value="false" :checked="!route.routeHasTwoWayBlock"
v-model="route.routeHasTwoWayBlock" :value="false"
/> v-model="route.routeHasTwoWayBlock"
<label :for="`${route.routeName}-notwb`">Nie</label> /><span>Nie</span>
</div> </label>
</form> </div>
</li>
</ul>
</div>
<div class="routes-actions"> <div>Prędkość: <input type="number" v-model="route.routeSpeed" /> km/h</div>
<button @click="saveRoutes">Zapisz</button> <div>Długość: <input type="number" v-model="route.routeLength" /> m</div>
<button @click="addNewRoute">Dodaj szlak</button> </form>
<button @click="closeRoutesModal">Zamknij</button> </li>
</ul>
</div>
<div class="routes-actions">
<button @click="saveRoutes">Zapisz</button>
<button @click="addNewRoute">Dodaj szlak</button>
<button @click="closeRoutesModal">Zamknij</button>
</div>
</div> </div>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { computed, defineComponent, ref } from 'vue';
import changeMixin from '../mixins/changeMixin'; import changeMixin from '../mixins/changeMixin';
import { useStore } from '../store'; import { useStore } from '../store';
export default defineComponent({ export default defineComponent({
setup() { setup() {
return { const store = useStore();
store: useStore(), const currentRoutes = ref('');
}; const routeBackup = ref('');
},
mixins: [changeMixin], const computedRouteList = computed(() => {
if (!store.currentStation) return [];
data: () => ({ if (currentRoutes.value.length == 0) return [];
currentRoutes: '',
routeBackup: '',
}),
computed: { return currentRoutes.value.split(';').map((route) => {
computedRouteList() {
if (!this.store.currentStation) return [];
if (this.currentRoutes.length == 0) return [];
return this.currentRoutes.split(';').map((route) => {
/* /*
Route: !Oc_2EPB Route: !Oc_2EPB:100:3000
! - szlak wewnętrzny (! - tak, brak wykrzyknika - nie) ! - szlak wewnętrzny (! - tak, brak wykrzyknika - nie)
Oc - nazwa scenerii Oc - nazwa scenerii
2 - liczba torów (1 lub 2) 2 - liczba torów (1 lub 2)
E - elektryfikacja (E - tak, N - nie) E - elektryfikacja (E - tak, N - nie)
P - rodzaj blokady (P - PBL, S - SBL) P - rodzaj blokady (P - PBL, S - SBL)
B - blokada dwukierunkowa (B - tak, brak litery - nie) B - blokada dwukierunkowa (B - tak, brak litery - nie)
100 - vmax szlaku
3000 - dł. szlaku
*/ */
const routeProps = route.split('_'); const routeProps = route.split('_');
const routeIsInternal = routeProps[0].startsWith('!'); const routeIsInternal = routeProps[0].startsWith('!');
const routeName = routeIsInternal ? routeProps[0].replace('!', '') : routeProps[0]; 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]; const routeSpecs = routeProps[1];
return { return {
routeName, routeName,
routeTracks: Number(routeSpecs[0]), routeTracks: Number(routeSpecs[0]),
routeElectrification: routeSpecs[1], routeElectrification: routeSpecs[1],
routeBlockType: routeSpecs[2], routeBlockType: routeSpecs[2],
routeHasTwoWayBlock: routeSpecs[3] ? true : false, routeHasTwoWayBlock: routeSpecs[3] == 'B' ? true : false,
routeIsInternal, routeIsInternal,
routeSpeed,
routeLength,
}; };
}); });
}, });
return {
store,
computedRouteList,
currentRoutes,
routeBackup,
};
}, },
mixins: [changeMixin],
data: () => ({}),
mounted() { mounted() {
if (this.store.currentStation) { if (this.store.currentStation) {
this.currentRoutes = this.store.currentStation.routes; this.currentRoutes = this.store.currentStation.routes;
this.routeBackup = this.currentRoutes; this.routeBackup = this.currentRoutes;
} }
// console.log(this.currentRoutes + " git");
}, },
methods: { methods: {
@@ -195,8 +228,8 @@ export default defineComponent({
}, },
addNewRoute() { addNewRoute() {
this.currentRoutes += (this.currentRoutes.length != 0 ? ';' : '') + `-_1EP`; this.currentRoutes += (this.currentRoutes.length != 0 ? ';' : '') + `-_1EP:0:0`;
this.saveRoutes(); // this.saveRoutes();
}, },
removeRoute(index: number) { removeRoute(index: number) {
@@ -205,7 +238,22 @@ export default defineComponent({
.filter((_, i) => i != index) .filter((_, i) => i != index)
.join(';'); .join(';');
this.saveRoutes(); // this.saveRoutes();
},
parseRoutes() {
const routeString = this.computedRouteList
.map(
(route) =>
`${route.routeIsInternal ? '!' : ''}${route.routeName.trim()}_${route.routeTracks}${
route.routeElectrification
}${route.routeBlockType}${route.routeHasTwoWayBlock ? 'B' : ''}:${route.routeSpeed || 0}:${
route.routeLength || 0
}`
)
.join(';');
return routeString;
}, },
saveRoutes() { saveRoutes() {
@@ -213,96 +261,132 @@ export default defineComponent({
if (index == -1) return; if (index == -1) return;
const routeString = this.computedRouteList const routeString = this.parseRoutes();
.map(
(route) =>
`${route.routeIsInternal ? '!' : ''}${route.routeName.trim()}_${route.routeTracks}${
route.routeElectrification
}${route.routeBlockType}${route.routeHasTwoWayBlock ? 'B' : ''}`
)
.join(';');
this.store.stationList[index]['routes'] = routeString;
this.currentRoutes = routeString;
this.addChange(this.store.currentStation!, 'routes', this.routeBackup, routeString); this.addChange(this.store.currentStation!, 'routes', this.routeBackup, routeString);
this.store.stationList[index]['routes'] = routeString;
this.currentRoutes = routeString;
}, },
}, },
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.bg {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 100;
background-color: #00000081;
}
.routes-modal { .routes-modal {
position: fixed; position: fixed;
top: 50%; top: 50%;
left: 50%; left: 50%;
width: 90%; width: 95%;
max-width: 800px; max-width: 800px;
height: 95%; height: 95vh;
overflow: hidden; max-height: 1000px;
padding: 0.5em 0;
display: flex;
flex-direction: column;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
z-index: 100; z-index: 101;
padding: 0.5em 0;
background-color: #333; background-color: #333;
border-radius: 1rem;
input {
display: inline;
margin: 0.25em 0;
color: black;
font-size: 1em;
max-width: 120px;
}
} }
.modal-wrapper { label.radio-choice {
overflow: auto; display: inline-block;
flex-grow: 2; position: relative;
background-color: #333;
margin: 0.25em;
cursor: pointer;
input {
position: absolute;
opacity: 0;
cursor: pointer;
}
span {
display: flex;
padding: 0.25em 0.75em;
}
input:checked + span {
color: gold;
font-weight: bold;
}
input:focus-visible + span {
outline: 1px solid white;
}
} }
.routes-modal h1 { .exit {
img {
vertical-align: text-bottom;
width: 1.4em;
}
cursor: pointer;
}
h1 {
display: flex;
justify-content: space-between;
gap: 0.5em;
position: sticky; position: sticky;
top: 0; top: -1px;
z-index: 100; z-index: 100;
background-color: #333; background-color: #333;
padding: 0.5em 2em; border-radius: 1rem 1rem 0 0;
padding: 0.25em 0.5em;
margin: 0;
font-size: 2em;
text-align: center; text-align: center;
} }
.routes-modal label { .modal-content {
padding: 0; display: grid;
grid-template-rows: 1fr auto;
height: 100%;
} }
.routes-modal .exit { .modal-wrapper {
position: absolute; overflow: auto;
top: 0;
right: 0;
z-index: 101;
cursor: pointer;
margin: 0.5em 1.5em;
} }
.exit img { .routes-modal ul {
width: 2.5em;
}
.routes-modal input {
display: inline;
padding: 0;
margin: 0.5em 0;
color: black;
font-size: 1em;
max-width: 120px;
}
ul {
list-style: none; list-style: none;
padding: 0 1em; padding: 0 1em;
margin: 0; margin: 0;
overflow: auto;
} }
ul li { ul li {
@@ -315,9 +399,6 @@ ul li {
} }
.route-delete { .route-delete {
position: absolute;
top: 0;
right: 0;
margin: 0.5em; margin: 0.5em;
width: 1.15em; width: 1.15em;
@@ -325,15 +406,19 @@ ul li {
} }
.routes-actions { .routes-actions {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 0.5em;
background-color: #333; background-color: #333;
width: 100%; width: 100%;
margin-top: 0.5em;
padding: 0.5em 0; padding: 0.5em 0;
text-align: center; text-align: center;
} }
.routes-actions button { .routes-actions button {
font-size: 1.2em; font-size: 1.2em;
margin: 0;
} }
</style> </style>
+3 -3
View File
@@ -117,7 +117,7 @@ export default defineComponent({
: changeItem[propChange]; : changeItem[propChange];
if (propChange == 'availability') value = getAvailabilityValue(changeItem[propChange] as Availability); if (propChange == 'availability') value = getAvailabilityValue(changeItem[propChange] as Availability);
if (propChange == 'routes') value = this.getRouteNames(changeItem[propChange] as string); if (propChange == 'routes') value = this.getRouteNames(changeItem[propChange] as string, true);
itemChanges.push(`<i>${(HeaderTypes as any)[propChange]}:</i> ${value || '-'}`); itemChanges.push(`<i>${(HeaderTypes as any)[propChange]}:</i> ${value || '-'}`);
} }
@@ -173,7 +173,7 @@ export default defineComponent({
return { ...v }; return { ...v };
}); });
const updateResData = (await this.store.updateSceneriesData(mappedChangeList)).data const updateResData = (await this.store.updateSceneriesData(mappedChangeList)).data;
this.store.changesResponse = updateResData; this.store.changesResponse = updateResData;
this.store.fetchSceneriesData(); this.store.fetchSceneriesData();
@@ -207,7 +207,7 @@ export default defineComponent({
signalType: 'współczesna', signalType: 'współczesna',
controlType: 'SCS', controlType: 'SCS',
SUP: false, SUP: false,
routes: 'Test_1EPB"', routes: 'Test_1EPB:0:0',
checkpoints: '', checkpoints: '',
authors: '', authors: '',
availability: 'default', availability: 'default',
+8 -4
View File
@@ -3,18 +3,22 @@ import { SceneryRowItem } from '../types/types';
export default defineComponent({ export default defineComponent({
methods: { methods: {
getRouteNames(routes: SceneryRowItem['routes']) { getRouteNames(routes: SceneryRowItem['routes'], showAdditional = false) {
return routes return routes
.split(';') .split(';')
.map((route) => { .map((route) => {
// !Oc_2EPB // !Oc_2EPB
const [_, speed, length] = route.split(':');
const props1 = route.split('_')[0]; const props1 = route.split('_')[0];
const props2 = route.split('_')[1]; const props2 = route.split('_')[1];
const isInternal = props1.startsWith('!'); const isInternal = props1.startsWith('!');
const name = isInternal ? props1.replace('!', '') : props1; const name = isInternal ? props1.replace('!', '') : props1;
return `${isInternal ? '<u>' + name + '</u>' : name} <span style='color: #aaa'>(${props2[0]}/${props2[1]}/${ return `<span ${speed != '0' && length != '0' ? 'class="text--accent"' : ''}>${
props2[2] isInternal ? '<u>' + name + '</u>' : name
}${props2[3] ? '/B' : ''})</span>`; }</span> <span style='color: #aaa'>(${props2[0]}/${props2[1]}/${props2[2]}${props2[3] == 'B' ? '/B' : ''}${
speed && showAdditional ? '/' + speed : ''
}${length && showAdditional ? '/' + length : ''})</span>`;
}) })
.join(', '); .join(', ');
}, },
+3 -7
View File
@@ -19,7 +19,9 @@
<tr v-for="(station, row) in sortedStationList" tabindex="0"> <tr v-for="(station, row) in sortedStationList" tabindex="0">
<td v-for="(value, propName) in headerNameList" @click="changeProperty(station, row, propName as string)"> <td v-for="(value, propName) in headerNameList" @click="changeProperty(station, row, propName as string)">
<span v-if="propName === 'url'" :style="station.url ? 'color: gold' : 'color: gray;'">URL</span> <span v-if="propName === 'url'" :style="station.url ? 'color: gold' : 'color: gray;'">URL</span>
<span v-else-if="propName === 'projectUrl'" :style="station.projectUrl ? 'color: gold' : 'color: gray;'">URL</span> <span v-else-if="propName === 'projectUrl'" :style="station.projectUrl ? 'color: gold' : 'color: gray;'"
>URL</span
>
<span v-else-if="propName === 'checkpoints'">{{ station[propName] ? 'POKAŻ' : 'DODAJ' }}</span> <span v-else-if="propName === 'checkpoints'">{{ station[propName] ? 'POKAŻ' : 'DODAJ' }}</span>
@@ -240,10 +242,4 @@ td img {
height: 1.45em; height: 1.45em;
vertical-align: middle; vertical-align: middle;
} }
@media screen and (max-width: 550px) {
table {
font-size: 0.85em;
}
}
</style> </style>