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
|
<select-box
|
||||||
:title="$t('trains.option-distance')"
|
:title="$t('trains.option-distance')"
|
||||||
:itemList="translatedSorterOptions"
|
:itemList="translatedSorterOptions"
|
||||||
:defaultItemIndex="3"
|
:defaultItemIndex="0"
|
||||||
:prefix="$t('trains.sorter-prefix')"
|
:prefix="$t('trains.sorter-prefix')"
|
||||||
@selected="changeSorter"
|
@selected="changeSorter"
|
||||||
/>
|
/>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, inject, Ref } from 'vue';
|
import { computed, defineComponent, inject } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import SelectBox from '../Global/SelectBox.vue';
|
import SelectBox from '../Global/SelectBox.vue';
|
||||||
|
|
||||||
@@ -41,6 +41,14 @@ export default defineComponent({
|
|||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const sorterOptions = [
|
const sorterOptions = [
|
||||||
|
{
|
||||||
|
id: 'distance',
|
||||||
|
value: 'kilometraż',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'progress',
|
||||||
|
value: 'przebyta trasa',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'mass',
|
id: 'mass',
|
||||||
value: 'masa',
|
value: 'masa',
|
||||||
@@ -53,10 +61,6 @@ export default defineComponent({
|
|||||||
id: 'length',
|
id: 'length',
|
||||||
value: 'długość',
|
value: 'długość',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'distance',
|
|
||||||
value: 'kilometraż',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'timetable',
|
id: 'timetable',
|
||||||
value: 'numer pociągu',
|
value: 'numer pociągu',
|
||||||
|
|||||||
@@ -125,6 +125,7 @@
|
|||||||
"option-length": "length",
|
"option-length": "length",
|
||||||
"option-distance": "distance",
|
"option-distance": "distance",
|
||||||
"option-timetable": "train no.",
|
"option-timetable": "train no.",
|
||||||
|
"option-progress": "route progress",
|
||||||
"sorter-prefix": "Sort: ",
|
"sorter-prefix": "Sort: ",
|
||||||
"search-train": "Train no.",
|
"search-train": "Train no.",
|
||||||
"search-driver": "Driver name",
|
"search-driver": "Driver name",
|
||||||
|
|||||||
@@ -125,6 +125,7 @@
|
|||||||
"option-length": "długość",
|
"option-length": "długość",
|
||||||
"option-distance": "kilometraż",
|
"option-distance": "kilometraż",
|
||||||
"option-timetable": "nr pociągu",
|
"option-timetable": "nr pociągu",
|
||||||
|
"option-progress": "przebyta trasa",
|
||||||
"sorter-prefix": "Sortuj: ",
|
"sorter-prefix": "Sortuj: ",
|
||||||
"search-train": "Numer pociągu",
|
"search-train": "Numer pociągu",
|
||||||
"search-driver": "Nick maszynisty",
|
"search-driver": "Nick maszynisty",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<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 { DataStatus } from '@/scripts/enums/DataStatus';
|
||||||
import Train from '@/scripts/interfaces/Train';
|
import Train from '@/scripts/interfaces/Train';
|
||||||
@@ -24,6 +24,13 @@ import TrainOptions from '@/components/TrainsView/TrainOptions.vue';
|
|||||||
|
|
||||||
import { useStore } from '@/store';
|
import { useStore } from '@/store';
|
||||||
import { GETTERS } from '@/constants/storeConstants';
|
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 = (
|
const filteredTrainList = (
|
||||||
trainList: Train[],
|
trainList: Train[],
|
||||||
@@ -48,6 +55,14 @@ const filteredTrainList = (
|
|||||||
|
|
||||||
return -sorterActive.dir;
|
return -sorterActive.dir;
|
||||||
|
|
||||||
|
case 'progress':
|
||||||
|
if (
|
||||||
|
confirmedPercentage(a.timetableData?.followingStops) > confirmedPercentage(b.timetableData?.followingStops)
|
||||||
|
)
|
||||||
|
return sorterActive.dir;
|
||||||
|
|
||||||
|
return -sorterActive.dir;
|
||||||
|
|
||||||
case 'speed':
|
case 'speed':
|
||||||
if (a.speed > b.speed) return sorterActive.dir;
|
if (a.speed > b.speed) return sorterActive.dir;
|
||||||
return -sorterActive.dir;
|
return -sorterActive.dir;
|
||||||
|
|||||||
Reference in New Issue
Block a user