From 1c34a9cf382494f66715dfc84250f45b93a188a6 Mon Sep 17 00:00:00 2001 From: Spythere Date: Sun, 16 Jan 2022 00:50:46 +0100 Subject: [PATCH] =?UTF-8?q?Paginacja=20listy=20poci=C4=85g=C3=B3w:=20popra?= =?UTF-8?q?wki,=20dost=C4=99pno=C5=9B=C4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TrainsView/TrainTable.vue | 73 ++++++++++++++---------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/src/components/TrainsView/TrainTable.vue b/src/components/TrainsView/TrainTable.vue index 57f74f7..5898e8e 100644 --- a/src/components/TrainsView/TrainTable.vue +++ b/src/components/TrainsView/TrainTable.vue @@ -151,24 +151,47 @@
- - << + + 1< - + < - + {{ currentPage + 1 }} - + > - - >> + + >{{ paginatorPageCount }}
@@ -251,7 +274,6 @@ export default defineComponent({ setup(props) { const store = useStore(); - const elList: Ref<(HTMLElement | null)[]> = ref([]); const timetableDataStatus: ComputedRef = computed(() => store.getters[GETTERS.timetableDataStatus]); @@ -274,8 +296,11 @@ export default defineComponent({ currentPage.value = 0; }); + watch(paginatorPageCount, (value) => { + if (currentPage.value >= value) currentPage.value = paginatorPageCount.value - 1; + }); + return { - elList, searchedTrain, searchedDriver, chosenSchedule, @@ -318,10 +343,6 @@ export default defineComponent({ }, 10); }, - registerReference(el: HTMLElement, timetableId: number | undefined) { - if (timetableId) this.elList[timetableId.toString()] = el; - }, - showTrainTimetable(trainNo: number, timetableId: number | undefined) { if (!timetableId && this.trains.length == 1) this.searchedTrain = ''; if (!timetableId) return; @@ -329,19 +350,6 @@ export default defineComponent({ this.searchedTrain = this.searchedTrain == trainNo.toString() && this.chosenSchedule != 0 ? '' : trainNo.toString(); this.chosenSchedule = this.chosenSchedule == timetableId ? 0 : timetableId; - - this.scrollToTimetable(timetableId); - }, - - scrollToTimetable(timetableId: number) { - setTimeout(() => { - const currentEl = this.elList[timetableId.toString()]; - - currentEl?.scrollIntoView({ - behavior: 'smooth', - block: 'center', - }); - }, 200); }, onImageError(e: Event) { @@ -394,7 +402,7 @@ export default defineComponent({ }, changePageTo(index: number) { - this.currentPage = index < 0 ? 0 : index % this.paginatorPageCount; + this.currentPage = index < 0 ? 0 : index >= this.paginatorPageCount ? this.paginatorPageCount - 1 : index; }, }, }); @@ -647,8 +655,13 @@ img.train-image { cursor: pointer; - &.current { - background-color: salmon; + &.disabled { + outline: 2px solid lightgray; + color: lightgray; + } + + &:focus { + outline: 2px solid white; } } }