mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
Poprawiono działanie filtrów historii rozkładów
This commit is contained in:
@@ -2,29 +2,22 @@
|
|||||||
<div class="select-box">
|
<div class="select-box">
|
||||||
<div class="select-box_content">
|
<div class="select-box_content">
|
||||||
<button class="selected" @click="toggleBox">
|
<button class="selected" @click="toggleBox">
|
||||||
{{ computedSelectedItem.value }}
|
<span class="text--primary">{{prefix}}</span> {{ computedSelectedItem.value }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<ul class="options" :ref="(el) => (listRef = el)">
|
<ul class="options" :ref="(el) => (listRef = el)">
|
||||||
<li class="option" v-for="(item, i) in itemList" :key="item.id">
|
<li class="option" v-for="(item, i) in itemList" :key="item.id">
|
||||||
<transition
|
<transition
|
||||||
name="unfold"
|
name="unfold"
|
||||||
:style="`
|
:style="
|
||||||
|
`
|
||||||
--delay-in: ${i * 55}ms;
|
--delay-in: ${i * 55}ms;
|
||||||
--delay-out: ${(itemList.length - 1 - i) * 55}ms`"
|
--delay-out: ${(itemList.length - 1 - i) * 55}ms`
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<label :for="item.id" v-if="listOpen">
|
<label :for="item.id" v-if="listOpen">
|
||||||
<input
|
<input type="button" :id="item.id" name="select-box" @click="selectOption(item)" />
|
||||||
type="button"
|
<span :style="computedSelectedItem.id == item.id ? 'color: gold;' : ''">
|
||||||
:id="item.id"
|
|
||||||
name="select-box"
|
|
||||||
@click="selectOption(item)"
|
|
||||||
/>
|
|
||||||
<span
|
|
||||||
:style="
|
|
||||||
computedSelectedItem.id == item.id ? 'color: gold;' : ''
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ item.value }}
|
{{ item.value }}
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
@@ -40,7 +33,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, Ref, ref } from "@vue/runtime-core";
|
import { computed, defineComponent, Ref, ref } from '@vue/runtime-core';
|
||||||
|
|
||||||
interface Item {
|
interface Item {
|
||||||
id: string | number;
|
id: string | number;
|
||||||
@@ -48,7 +41,7 @@ interface Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
emits: ["selected"],
|
emits: ['selected'],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
itemList: {
|
itemList: {
|
||||||
@@ -60,11 +53,16 @@ export default defineComponent({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
prefix: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
ascIcon: require("@/assets/icon-arrow-asc.svg"),
|
ascIcon: require('@/assets/icon-arrow-asc.svg'),
|
||||||
descIcon: require("@/assets/icon-arrow-desc.svg"),
|
descIcon: require('@/assets/icon-arrow-desc.svg'),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
setup(props) {
|
setup(props) {
|
||||||
@@ -77,10 +75,7 @@ export default defineComponent({
|
|||||||
let selectedItem: Ref<Item> = ref(props.itemList[props.defaultItemIndex]);
|
let selectedItem: Ref<Item> = ref(props.itemList[props.defaultItemIndex]);
|
||||||
|
|
||||||
const computedSelectedItem = computed(() => {
|
const computedSelectedItem = computed(() => {
|
||||||
return (
|
return props.itemList.find((item) => item.id === selectedItem.value.id) || props.itemList[props.defaultItemIndex];
|
||||||
props.itemList.find((item) => item.id === selectedItem.value.id) ||
|
|
||||||
props.itemList[props.defaultItemIndex]
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -98,7 +93,7 @@ export default defineComponent({
|
|||||||
this.selectedItem = item;
|
this.selectedItem = item;
|
||||||
this.listOpen = false;
|
this.listOpen = false;
|
||||||
|
|
||||||
this.$emit("selected", item);
|
this.$emit('selected', item);
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleBox(e: Event) {
|
toggleBox(e: Event) {
|
||||||
@@ -116,7 +111,7 @@ export default defineComponent({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "../../styles/variables.scss";
|
@import '../../styles/variables.scss';
|
||||||
|
|
||||||
.unfold {
|
.unfold {
|
||||||
&-enter-from,
|
&-enter-from,
|
||||||
@@ -244,4 +239,4 @@ li.option {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,12 +4,11 @@
|
|||||||
<div class="options_content">
|
<div class="options_content">
|
||||||
<div class="content_select">
|
<div class="content_select">
|
||||||
<select-box
|
<select-box
|
||||||
:title="$t('journal.option-distance')"
|
|
||||||
:itemList="translatedSorterOptions"
|
:itemList="translatedSorterOptions"
|
||||||
:defaultItemIndex="0"
|
:defaultItemIndex="0"
|
||||||
@selected="changeSorter"
|
@selected="changeSorter"
|
||||||
|
:prefix="$t('journal.sort-prefix')"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content_search">
|
<div class="content_search">
|
||||||
@@ -61,7 +60,7 @@ export default defineComponent({
|
|||||||
setup() {
|
setup() {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const sorterOptions = ['distance', 'total-stops'];
|
const sorterOptions = ['date', 'distance', 'total-stops'];
|
||||||
|
|
||||||
const translatedSorterOptions = computed(() =>
|
const translatedSorterOptions = computed(() =>
|
||||||
sorterOptions.map((id) => ({
|
sorterOptions.map((id) => ({
|
||||||
@@ -83,11 +82,11 @@ export default defineComponent({
|
|||||||
changeSorter(item: { id: string | number; value: string }) {
|
changeSorter(item: { id: string | number; value: string }) {
|
||||||
this.sorterActive.id = item.id;
|
this.sorterActive.id = item.id;
|
||||||
this.sorterActive.dir = -1;
|
this.sorterActive.dir = -1;
|
||||||
|
|
||||||
|
this.$emit('changedOptions');
|
||||||
},
|
},
|
||||||
|
|
||||||
search() {
|
search() {
|
||||||
console.log('gituwa');
|
|
||||||
|
|
||||||
this.$emit('changedOptions');
|
this.$emit('changedOptions');
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -118,7 +117,6 @@ export default defineComponent({
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
|
||||||
@include smallScreen() {
|
@include smallScreen() {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
@@ -129,14 +127,13 @@ export default defineComponent({
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
|
||||||
.content_search, .content_select {
|
.content_search,
|
||||||
|
.content_select {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@include smallScreen() {
|
@include smallScreen() {
|
||||||
padding: 0 1em;
|
padding: 0 1em;
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -147,9 +147,12 @@
|
|||||||
|
|
||||||
"search-train": "Train no.",
|
"search-train": "Train no.",
|
||||||
"search-driver": "Driver name",
|
"search-driver": "Driver name",
|
||||||
|
|
||||||
|
"sort-prefix": "Sort: ",
|
||||||
|
|
||||||
"option-distance": "distance",
|
"option-distance": "distance",
|
||||||
"option-total-stops": "total stops"
|
"option-total-stops": "total stops",
|
||||||
|
"option-date": "date"
|
||||||
},
|
},
|
||||||
"scenery": {
|
"scenery": {
|
||||||
"users": "PLAYERS ONLINE",
|
"users": "PLAYERS ONLINE",
|
||||||
|
|||||||
+4
-1
@@ -148,8 +148,11 @@
|
|||||||
"search-train": "Numer pociągu",
|
"search-train": "Numer pociągu",
|
||||||
"search-driver": "Nick maszynisty",
|
"search-driver": "Nick maszynisty",
|
||||||
|
|
||||||
|
"sort-prefix": "Sortuj: ",
|
||||||
|
|
||||||
"option-distance": "kilometraż",
|
"option-distance": "kilometraż",
|
||||||
"option-total-stops": "stacje"
|
"option-total-stops": "stacje",
|
||||||
|
"option-date": "data"
|
||||||
},
|
},
|
||||||
"scenery": {
|
"scenery": {
|
||||||
"users": "GRACZE ONLINE",
|
"users": "GRACZE ONLINE",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
<b
|
<b
|
||||||
class="history_item-status"
|
class="history_item-status"
|
||||||
:class="{
|
:class="{
|
||||||
fulfilled: item.fulfilled,
|
fulfilled: item.fulfilled || item.currentDistance >= item.routeDistance * 0.9,
|
||||||
terminated: item.terminated && !item.fulfilled,
|
terminated: item.terminated && !item.fulfilled,
|
||||||
active: !item.terminated,
|
active: !item.terminated,
|
||||||
}"
|
}"
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
{{
|
{{
|
||||||
!item.terminated
|
!item.terminated
|
||||||
? $t('history.timetable-active')
|
? $t('history.timetable-active')
|
||||||
: item.fulfilled
|
: (item.fulfilled || item.currentDistance >= item.routeDistance * 0.9)
|
||||||
? $t('history.timetable-fulfilled')
|
? $t('history.timetable-fulfilled')
|
||||||
: $t('history.timetable-abandoned')
|
: $t('history.timetable-abandoned')
|
||||||
}}
|
}}
|
||||||
@@ -185,7 +185,7 @@ export default defineComponent({
|
|||||||
error: null,
|
error: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const sorterActive = ref({ id: 'distance', dir: -1 });
|
const sorterActive = ref({ id: 'date', dir: -1 });
|
||||||
const searchedDriver = ref('');
|
const searchedDriver = ref('');
|
||||||
const searchedTrain = ref('');
|
const searchedTrain = ref('');
|
||||||
|
|
||||||
@@ -251,7 +251,12 @@ export default defineComponent({
|
|||||||
if (props.searchedDriver) queries.push(`driver=${props.searchedDriver}`);
|
if (props.searchedDriver) queries.push(`driver=${props.searchedDriver}`);
|
||||||
if (props.searchedTrain) queries.push(`train=${props.searchedTrain}`);
|
if (props.searchedTrain) queries.push(`train=${props.searchedTrain}`);
|
||||||
|
|
||||||
console.log(this.sorterActive);
|
// Z API: const SORT_TYPES = ['allStopsCount', 'endDate', 'beginDate', 'routeDistance'];
|
||||||
|
if (this.sorterActive.id == 'distance') queries.push("sortBy=routeDistance");
|
||||||
|
else if (this.sorterActive.id == 'total-stops') queries.push("sortBy=allStopsCount");
|
||||||
|
|
||||||
|
console.log(queries);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const responseData: APIResponse | null = await (await axios.get(`${API_URL}?${queries.join('&')}`)).data;
|
const responseData: APIResponse | null = await (await axios.get(`${API_URL}?${queries.join('&')}`)).data;
|
||||||
|
|||||||
Reference in New Issue
Block a user