Dokończenie widoku dziennika RJ

This commit is contained in:
2022-09-04 01:04:04 +02:00
parent b90ac6c09e
commit 82bbfcdf70
2 changed files with 191 additions and 129 deletions
+124 -64
View File
@@ -32,45 +32,47 @@
<ul v-else> <ul v-else>
<transition-group name="journal-list-anim"> <transition-group name="journal-list-anim">
<li <li
v-for="{ timetable, sceneryList } in computedTimetableHistory" v-for="{ timetable, sceneryList, ...item } in computedTimetableHistory"
class="journal_item" class="journal_item"
:key="timetable.timetableId" :key="timetable.timetableId"
> >
<div class="journal_item-info"> <div class="journal_item-info">
<div style="margin-bottom: 0.5em"> <div class="info-top">
<b class="info-date">{{ localeDay(timetable.beginDate, $i18n.locale) }}</b> <span
<b tabindex="0"
class="info-status" @click="showTimetable(timetable)"
:class="{ @keydown.enter="showTimetable(timetable)"
fulfilled: style="cursor: pointer"
timetable.fulfilled || timetable.currentDistance >= timetable.routeDistance * 0.9,
terminated: timetable.terminated && !timetable.fulfilled,
active: !timetable.terminated,
}"
> >
{{ <b class="text--primary">{{ timetable.trainCategoryCode }}&nbsp;</b>
!timetable.terminated <b>{{ timetable.trainNo }}</b>
? $t('journal.timetable-active') | <span>{{ timetable.driverName }}</span> |
: timetable.fulfilled || timetable.currentDistance >= timetable.routeDistance * 0.9 <span class="text--grayed">#{{ timetable.timetableId }}</span>
? $t('journal.timetable-fulfilled') </span>
: `${$t('journal.timetable-abandoned')} ${localeTime(timetable.endDate, $i18n.locale)}`
}} <span>
</b> <b class="info-date">{{ localeDay(timetable.beginDate, $i18n.locale) }}</b>
<b
class="info-status"
:class="{
fulfilled:
timetable.fulfilled || timetable.currentDistance >= timetable.routeDistance * 0.9,
terminated: timetable.terminated && !timetable.fulfilled,
active: !timetable.terminated,
}"
>
{{
!timetable.terminated
? $t('journal.timetable-active')
: timetable.fulfilled || timetable.currentDistance >= timetable.routeDistance * 0.9
? $t('journal.timetable-fulfilled')
: `${$t('journal.timetable-abandoned')} ${localeTime(timetable.endDate, $i18n.locale)}`
}}
</b>
</span>
</div> </div>
<span <div class="info-route">
tabindex="0"
@click="showTimetable(timetable)"
@keydown.enter="showTimetable(timetable)"
style="cursor: pointer"
>
<b class="text--primary">{{ timetable.trainCategoryCode }}&nbsp;</b>
<b>{{ timetable.trainNo }}</b>
| <span>{{ timetable.driverName }}</span> |
<span class="text--grayed">#{{ timetable.timetableId }}</span>
</span>
<div style="margin-top: 0.25em">
<b>{{ timetable.route.replace('|', ' - ') }}</b> <b>{{ timetable.route.replace('|', ' - ') }}</b>
</div> </div>
@@ -93,20 +95,8 @@
</span> </span>
</div> </div>
<div style="margin-top: 1em"> <!-- Status RJ -->
<!-- Nick dyżurnego --> <div style="margin: 0.5em 0">
<div v-if="timetable.authorName">
<b class="text--grayed">{{ $t('journal.dispatcher-name') }}&nbsp;</b>
<router-link
class="dispatcher-link"
:to="`/journal/dispatchers?dispatcherName=${timetable.authorName}`"
>
<b>{{ timetable.authorName }}</b>
</router-link>
</div>
</div>
<div style="margin-top: 1em">
<span> <span>
<b>{{ $t('journal.route-length') }}</b> <b>{{ $t('journal.route-length') }}</b>
{{ !timetable.fulfilled ? timetable.currentDistance + ' /' : '' }} {{ !timetable.fulfilled ? timetable.currentDistance + ' /' : '' }}
@@ -119,10 +109,36 @@
{{ timetable.allStopsCount }} {{ timetable.allStopsCount }}
</span> </span>
</div> </div>
</div>
<div class="journal_item-stock" v-if="timetable.stockString"> <!-- Nick dyżurnego -->
{{ timetable.stockString}} <div v-if="timetable.authorName">
<b class="text--grayed">{{ $t('journal.dispatcher-name') }}&nbsp;</b>
<router-link
class="dispatcher-link"
:to="`/journal/dispatchers?dispatcherName=${timetable.authorName}`"
>
<b>{{ timetable.authorName }}</b>
</router-link>
</div>
<button class="btn--option btn--show" @click="item.showStock.value = !item.showStock.value">
{{ item.showStock.value ? 'UKRYJ' : 'POKAŻ' }} SKŁAD
<img :src="getIcon(`arrow-${item.showStock.value ? 'asc' : 'desc'}`)" alt="Arrow" />
</button>
<div class="info-extended" v-show="item.showStock.value">
<ul class="stock-list" v-if="timetable.stockString">
<li v-for="(car, i) in timetable.stockString.split(';')" :key="i">
<img
@error="onImageError"
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${car.split(':')[0]}.png`"
:alt="car"
/>
<div>{{ car.replace(/_/g, ' ').split(':')[0] }}</div>
</li>
</ul>
</div>
</div> </div>
</li> </li>
</transition-group> </transition-group>
@@ -155,12 +171,13 @@ import { useStore } from '../../store/store';
import JournalOptions from './JournalOptions.vue'; import JournalOptions from './JournalOptions.vue';
import { JournalTimetableSearcher } from '../../types/JournalTimetablesTypes'; import { JournalTimetableSearcher } from '../../types/JournalTimetablesTypes';
import modalTrainMixin from '../../mixins/modalTrainMixin'; import modalTrainMixin from '../../mixins/modalTrainMixin';
import imageMixin from '../../mixins/imageMixin';
const TIMETABLES_API_URL = `${URLs.stacjownikAPI}/api/getTimetables`; const TIMETABLES_API_URL = `${URLs.stacjownikAPI}/api/getTimetables`;
export default defineComponent({ export default defineComponent({
components: { DriverStats, Loading, JournalOptions }, components: { DriverStats, Loading, JournalOptions },
mixins: [dateMixin, routerMixin, modalTrainMixin], mixins: [dateMixin, routerMixin, modalTrainMixin, imageMixin],
name: 'JournalTimetables', name: 'JournalTimetables',
@@ -248,6 +265,7 @@ export default defineComponent({
return this.timetableHistory.map((timetable) => ({ return this.timetableHistory.map((timetable) => ({
timetable, timetable,
sceneryList: this.getSceneryList(timetable), sceneryList: this.getSceneryList(timetable),
showStock: ref(false),
})); }));
}, },
}, },
@@ -300,6 +318,11 @@ export default defineComponent({
}); });
}, },
onImageError(e: Event) {
const imageEl = e.target as HTMLImageElement;
imageEl.src = this.getImage('unknown.png');
},
handleScroll() { handleScroll() {
this.showReturnButton = window.scrollY > window.innerHeight; this.showReturnButton = window.scrollY > window.innerHeight;
@@ -427,22 +450,10 @@ export default defineComponent({
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../styles/JournalSection.scss'; @import '../../styles/JournalSection.scss';
@import '../../styles/variables.scss'; @import '../../styles/responsive.scss';
.journal_item {
&-stock {
overflow: auto;
}
}
.info { .info {
&-date { &-date {
padding: 0.05em 0.35em; margin-right: 0.5em;
background-color: lightcyan;
color: black;
} }
&-status { &-status {
@@ -461,6 +472,30 @@ export default defineComponent({
background-color: lightblue; background-color: lightblue;
} }
} }
&-top {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
&-route {
margin: 0.25em 0;
}
}
ul.stock-list {
display: flex;
align-items: flex-end;
overflow: auto;
padding-bottom: 0.5em;
margin-top: 1em;
li > div {
text-align: center;
color: #aaa;
font-size: 0.9em;
}
} }
.scenery-list { .scenery-list {
@@ -469,4 +504,29 @@ export default defineComponent({
color: #a3eba3; color: #a3eba3;
} }
} }
.btn--show {
display: flex;
margin-top: 0.5em;
font-weight: bold;
img {
height: 1.3em;
}
}
@include smallScreen {
.info-top {
flex-direction: column;
span {
margin: 0.1em auto;
}
}
.info-route {
display: flex;
justify-content: center;
}
}
</style> </style>
+67 -65
View File
@@ -1,65 +1,67 @@
@import 'responsive.scss'; @import 'responsive.scss';
// Animations // Animations
.warning { .warning {
&-enter-from, &-enter-from,
&-leave-to { &-leave-to {
opacity: 0; opacity: 0;
} }
&-enter-active { &-enter-active {
transition: all 150ms ease-out; transition: all 150ms ease-out;
} }
&-leave-active { &-leave-active {
transition: all 150ms ease-out; transition: all 150ms ease-out;
} }
} }
//Styles //Styles
.journal-wrapper { .journal-wrapper {
width: 1350px; max-width: 1350px;
padding: 1em 0; width: 100%;
}
padding: 1em 0;
.journal_warning { }
text-align: center;
font-size: 1.3em; .journal_warning {
text-align: center;
&.error { font-size: 1.3em;
background-color: var(--clr-error);
} &.error {
} background-color: var(--clr-error);
}
.schedule-dates > * { }
margin-right: 0.25em;
} .schedule-dates > * {
margin-right: 0.25em;
.journal_item, }
.journal_warning {
background: #202020; .journal_item,
padding: 1em; .journal_warning {
margin: 1em 0; background: #202020;
} padding: 1em;
margin: 1em 0;
.journal_top-bar { }
display: flex;
justify-content: space-between; .journal_top-bar {
align-items: center; display: flex;
} justify-content: space-between;
align-items: center;
button.btn { }
padding: 0.5em 0.7em;
} button.btn {
padding: 0.5em 0.7em;
@include smallScreen() { }
.journal-wrapper {
font-size: 1.25em; @include smallScreen() {
} .journal-wrapper {
font-size: 1.25em;
.journal_top-bar { }
justify-content: center;
flex-wrap: wrap; .journal_top-bar {
} justify-content: center;
} flex-wrap: wrap;
}
}