From 05fc1860a3542af696bb5ec7fb816d47da1b1007 Mon Sep 17 00:00:00 2001 From: Spythere Date: Sat, 21 May 2022 17:43:29 +0200 Subject: [PATCH] =?UTF-8?q?Poprawiono=20list=C4=99=20uwag=20eksploatacyjny?= =?UTF-8?q?ch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TrainsView/TrainInfoExtended.vue | 2 +- src/components/TrainsView/TrainInfoSimple.vue | 2 +- src/mixins/trainInfoMixin.ts | 17 ++++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/TrainsView/TrainInfoExtended.vue b/src/components/TrainsView/TrainInfoExtended.vue index 4f39a61..9158135 100644 --- a/src/components/TrainsView/TrainInfoExtended.vue +++ b/src/components/TrainsView/TrainInfoExtended.vue @@ -59,7 +59,7 @@
- {{ $t('trains.comment') }} {{ getSceneriesWithComments(train.timetableData).join(',') }} + {{ $t('trains.comment') }} {{ getSceneriesWithComments(train.timetableData) }}
diff --git a/src/components/TrainsView/TrainInfoSimple.vue b/src/components/TrainsView/TrainInfoSimple.vue index a0b8c87..6b2e527 100644 --- a/src/components/TrainsView/TrainInfoSimple.vue +++ b/src/components/TrainsView/TrainInfoSimple.vue @@ -29,7 +29,7 @@ v-if="getSceneriesWithComments(train.timetableData).length > 0" class="image-warning" :src="icons.warning" - :title="`${$t('trains.timetable-comments')} (${getSceneriesWithComments(train.timetableData).join(',')})`" + :title="`${$t('trains.timetable-comments')} (${getSceneriesWithComments(train.timetableData)})`" /> diff --git a/src/mixins/trainInfoMixin.ts b/src/mixins/trainInfoMixin.ts index f19ca60..f56d29d 100644 --- a/src/mixins/trainInfoMixin.ts +++ b/src/mixins/trainInfoMixin.ts @@ -42,7 +42,7 @@ export default defineComponent({ ], }, }), - + methods: { displayStopList(stops: TrainStop[]): string | undefined { if (!stops) return ''; @@ -91,13 +91,16 @@ export default defineComponent({ }, getSceneriesWithComments(timetableData: Train['timetableData']) { - return ( - timetableData?.followingStops.reduce((acc, stop) => { - if (stop.comments) acc.push(stop.stopNameRAW); + const commentList = timetableData?.followingStops.reduce((acc, stop, i) => { + if (stop.comments) acc.push(stop.stopNameRAW); - return acc; - }, [] as string[]) || [] - ); + return acc; + }, [] as string[]) || [] + + const moreCount = commentList.length - 10; + + + return commentList.slice(0,10).join(", ") + (moreCount > 0 ? `... (+${moreCount})` : ''); }, displayDistance(distance: number) {