mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Dodano sortowanie pociągów wg. postępu
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<select-box
|
||||
:title="$t('trains.option-distance')"
|
||||
:itemList="translatedSorterOptions"
|
||||
:defaultItemIndex="3"
|
||||
:defaultItemIndex="0"
|
||||
:prefix="$t('trains.sorter-prefix')"
|
||||
@selected="changeSorter"
|
||||
/>
|
||||
@@ -25,7 +25,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, inject, Ref } from 'vue';
|
||||
import { computed, defineComponent, inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import SelectBox from '../Global/SelectBox.vue';
|
||||
|
||||
@@ -41,6 +41,14 @@ export default defineComponent({
|
||||
const { t } = useI18n();
|
||||
|
||||
const sorterOptions = [
|
||||
{
|
||||
id: 'distance',
|
||||
value: 'kilometraż',
|
||||
},
|
||||
{
|
||||
id: 'progress',
|
||||
value: 'przebyta trasa',
|
||||
},
|
||||
{
|
||||
id: 'mass',
|
||||
value: 'masa',
|
||||
@@ -53,10 +61,6 @@ export default defineComponent({
|
||||
id: 'length',
|
||||
value: 'długość',
|
||||
},
|
||||
{
|
||||
id: 'distance',
|
||||
value: 'kilometraż',
|
||||
},
|
||||
{
|
||||
id: 'timetable',
|
||||
value: 'numer pociągu',
|
||||
|
||||
@@ -125,6 +125,7 @@
|
||||
"option-length": "length",
|
||||
"option-distance": "distance",
|
||||
"option-timetable": "train no.",
|
||||
"option-progress": "route progress",
|
||||
"sorter-prefix": "Sort: ",
|
||||
"search-train": "Train no.",
|
||||
"search-driver": "Driver name",
|
||||
|
||||
@@ -125,6 +125,7 @@
|
||||
"option-length": "długość",
|
||||
"option-distance": "kilometraż",
|
||||
"option-timetable": "nr pociągu",
|
||||
"option-progress": "przebyta trasa",
|
||||
"sorter-prefix": "Sortuj: ",
|
||||
"search-train": "Numer pociągu",
|
||||
"search-driver": "Nick maszynisty",
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, ComputedRef, defineComponent, provide, reactive, Ref, ref, watch } from 'vue';
|
||||
import { computed, ComputedRef, defineComponent, provide, reactive, ref } from 'vue';
|
||||
|
||||
import { DataStatus } from '@/scripts/enums/DataStatus';
|
||||
import Train from '@/scripts/interfaces/Train';
|
||||
@@ -24,6 +24,13 @@ import TrainOptions from '@/components/TrainsView/TrainOptions.vue';
|
||||
|
||||
import { useStore } from '@/store';
|
||||
import { GETTERS } from '@/constants/storeConstants';
|
||||
import TrainStop from '@/scripts/interfaces/TrainStop';
|
||||
|
||||
const confirmedPercentage = (stops: TrainStop[] | undefined) => {
|
||||
if (!stops) return -1;
|
||||
|
||||
return Number(((stops.filter((stop) => stop.confirmed).length / stops.length) * 100).toFixed(0));
|
||||
};
|
||||
|
||||
const filteredTrainList = (
|
||||
trainList: Train[],
|
||||
@@ -48,6 +55,14 @@ const filteredTrainList = (
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'progress':
|
||||
if (
|
||||
confirmedPercentage(a.timetableData?.followingStops) > confirmedPercentage(b.timetableData?.followingStops)
|
||||
)
|
||||
return sorterActive.dir;
|
||||
|
||||
return -sorterActive.dir;
|
||||
|
||||
case 'speed':
|
||||
if (a.speed > b.speed) return sorterActive.dir;
|
||||
return -sorterActive.dir;
|
||||
|
||||
Reference in New Issue
Block a user