refactor: revamped vehicle manager adjusted for new API, improved file structure

This commit is contained in:
2025-11-24 02:13:47 +01:00
parent a176e46eef
commit 8c7449a7e3
8 changed files with 396 additions and 271 deletions
+20 -54
View File
@@ -19,9 +19,15 @@
<tbody>
<tr v-for="(station, row) in sceneriesStore.sortedStationList" tabindex="0">
<td v-for="{ id: propName } in headers" @click="changeProperty(station, row, propName as string)" :class="propName">
<td
v-for="{ id: propName } in headers"
@click="changeProperty(station, row, propName as string)"
:class="propName"
>
<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>
@@ -141,7 +147,9 @@ export default defineComponent({
return;
}
const stationListRow = this.sceneriesStore.stationList.findIndex((station) => station.name == this.sceneriesStore.sortedStationList[row].name);
const stationListRow = this.sceneriesStore.stationList.findIndex(
(station) => station.name == this.sceneriesStore.sortedStationList[row].name,
);
if (stationListRow == -1) return;
const oldValue = (this.sceneriesStore.stationList[stationListRow] as any)[propertyName];
@@ -152,15 +160,21 @@ export default defineComponent({
return;
}
let newValue = prompt(`Zmień wartość dla rubryki ${this.headers.find((h) => h.id === propertyName)?.value ?? ''}`, oldValue || '');
let newValue = prompt(
`Zmień wartość dla rubryki ${this.headers.find((h) => h.id === propertyName)?.value ?? ''}`,
oldValue || '',
);
if (newValue == null) return;
(this.sceneriesStore.stationList[stationListRow] as any)[propertyName] = typeof oldValue === 'number' ? parseInt(newValue) : newValue;
(this.sceneriesStore.stationList[stationListRow] as any)[propertyName] =
typeof oldValue === 'number' ? parseInt(newValue) : newValue;
// this.$set(this.stationList[stationListRow], propertyName, parseInt(newValue));
this.addChange(station, propertyName, oldValue, typeof oldValue === 'number' ? parseInt(newValue) : newValue);
},
changeCheckpoints(row: number) {
const stationListRow = this.sceneriesStore.stationList.findIndex((station) => station.name == this.sceneriesStore.sortedStationList[row].name);
const stationListRow = this.sceneriesStore.stationList.findIndex(
(station) => station.name == this.sceneriesStore.sortedStationList[row].name,
);
if (stationListRow == -1) return;
const oldCheckpoints = this.sceneriesStore.stationList[stationListRow].checkpoints;
@@ -200,33 +214,6 @@ export default defineComponent({
width: 100%;
}
table {
table-layout: fixed;
text-align: center;
color: white;
position: relative;
border-collapse: collapse;
width: 100%;
}
table thead {
position: sticky;
top: 0;
}
table thead td {
padding: 0.4rem 0.45rem;
background-color: #151b24;
color: white;
top: 0;
}
table tbody tr {
background-color: #2c394b;
transition: background-color 100ms;
text-overflow: ellipsis;
}
table tr.current {
outline: 1px solid white;
}
@@ -235,25 +222,4 @@ table td.routes {
font-size: 0.9em;
min-width: 150px;
}
table tr:nth-child(even) {
background-color: #334756;
}
table tr:hover {
background-color: #1a293b;
cursor: pointer;
}
table tbody tr td {
padding: 0.3rem 0.5rem;
border: 1px solid #2c2c2c;
overflow: hidden;
text-overflow: ellipsis;
}
td img {
height: 1.45em;
vertical-align: middle;
}
</style>