mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Dodano sugestie wyszukiwania istniejących użytkowników w dziennikach
This commit is contained in:
@@ -7,6 +7,14 @@
|
|||||||
{{ $t('options.filters') }} [F]
|
{{ $t('options.filters') }} [F]
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<datalist id="search-driver">
|
||||||
|
<option v-for="sugg in driverSuggestions" :value="sugg"></option>
|
||||||
|
</datalist>
|
||||||
|
|
||||||
|
<datalist id="search-dispatcher">
|
||||||
|
<option v-for="sugg in dispatcherSuggestions" :value="sugg"></option>
|
||||||
|
</datalist>
|
||||||
|
|
||||||
<transition name="options-anim">
|
<transition name="options-anim">
|
||||||
<div class="options_wrapper" v-if="showOptions">
|
<div class="options_wrapper" v-if="showOptions">
|
||||||
<div class="options_content">
|
<div class="options_content">
|
||||||
@@ -17,23 +25,15 @@
|
|||||||
|
|
||||||
<div class="search-box">
|
<div class="search-box">
|
||||||
<input
|
<input
|
||||||
v-if="propName == 'search-date'"
|
|
||||||
class="search-input"
|
class="search-input"
|
||||||
id="date"
|
|
||||||
type="date"
|
|
||||||
min="2022-02-01"
|
|
||||||
@keydown.enter="onSearchConfirm"
|
|
||||||
v-model="searchersValues[propName]"
|
v-model="searchersValues[propName]"
|
||||||
/>
|
|
||||||
|
|
||||||
<input
|
|
||||||
v-else
|
|
||||||
class="search-input"
|
|
||||||
@keydown.enter="onSearchConfirm"
|
@keydown.enter="onSearchConfirm"
|
||||||
@focus="preventKeyDown = true"
|
@focus="preventKeyDown = true"
|
||||||
@blur="preventKeyDown = false"
|
@blur="preventKeyDown = false"
|
||||||
:placeholder="$t(`options.${propName}`)"
|
:placeholder="$t(`options.${propName}`)"
|
||||||
v-model="searchersValues[propName]"
|
:type="propName == 'search-date' ? 'date' : 'text'"
|
||||||
|
:min="propName == 'search-date' ? '2022-02-01' : undefined"
|
||||||
|
:list="propName.toString()"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button class="search-exit">
|
<button class="search-exit">
|
||||||
@@ -84,10 +84,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, inject, Prop, PropType } from 'vue';
|
import axios from 'axios';
|
||||||
|
import { defineComponent, inject, PropType } from 'vue';
|
||||||
import imageMixin from '../../mixins/imageMixin';
|
import imageMixin from '../../mixins/imageMixin';
|
||||||
import keyMixin from '../../mixins/keyMixin';
|
import keyMixin from '../../mixins/keyMixin';
|
||||||
import { DataStatus } from '../../scripts/enums/DataStatus';
|
import { DataStatus } from '../../scripts/enums/DataStatus';
|
||||||
|
import { URLs } from '../../scripts/utils/apiURLs';
|
||||||
import { JournalTimetableFilter } from '../../types/Journal/JournalTimetablesTypes';
|
import { JournalTimetableFilter } from '../../types/Journal/JournalTimetablesTypes';
|
||||||
import ActionButton from '../Global/ActionButton.vue';
|
import ActionButton from '../Global/ActionButton.vue';
|
||||||
import SelectBox from '../Global/SelectBox.vue';
|
import SelectBox from '../Global/SelectBox.vue';
|
||||||
@@ -117,6 +119,12 @@ export default defineComponent({
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showOptions: false,
|
showOptions: false,
|
||||||
|
|
||||||
|
driverSuggestions: [] as string[],
|
||||||
|
dispatcherSuggestions: [] as string[],
|
||||||
|
|
||||||
|
searchTimeout: 0,
|
||||||
|
|
||||||
DataStatus,
|
DataStatus,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -138,6 +146,51 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
async 'searchersValues.search-driver'(value: string | undefined) {
|
||||||
|
clearTimeout(this.searchTimeout);
|
||||||
|
|
||||||
|
if (!value || value == '') return;
|
||||||
|
if (value.length < 3) return;
|
||||||
|
|
||||||
|
this.searchTimeout = setTimeout(async () => {
|
||||||
|
try {
|
||||||
|
const driverSuggestions: string[] = await (
|
||||||
|
await axios.get(`${URLs.stacjownikAPI}/api/getDriverSuggestions?name=${value}`)
|
||||||
|
).data;
|
||||||
|
|
||||||
|
this.driverSuggestions = driverSuggestions;
|
||||||
|
} catch (error) {
|
||||||
|
this.driverSuggestions = [];
|
||||||
|
}
|
||||||
|
}, 1500);
|
||||||
|
|
||||||
|
// this.loadingDriverSuggestions = true;
|
||||||
|
|
||||||
|
// this.loadingDriverSuggestions = false;
|
||||||
|
// this.nextSearchTimestamp = Date.now() + 100;
|
||||||
|
},
|
||||||
|
|
||||||
|
async 'searchersValues.search-dispatcher'(value: string | undefined) {
|
||||||
|
clearTimeout(this.searchTimeout);
|
||||||
|
|
||||||
|
if (!value || value == '') return;
|
||||||
|
if (value.length < 3) return;
|
||||||
|
|
||||||
|
this.searchTimeout = setTimeout(async () => {
|
||||||
|
try {
|
||||||
|
const dispatcherSuggestions: string[] = await (
|
||||||
|
await axios.get(`${URLs.stacjownikAPI}/api/getDispatcherSuggestions?name=${value}`)
|
||||||
|
).data;
|
||||||
|
|
||||||
|
this.dispatcherSuggestions = dispatcherSuggestions;
|
||||||
|
} catch (error) {
|
||||||
|
this.dispatcherSuggestions = [];
|
||||||
|
}
|
||||||
|
}, 1500);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
// Override keyMixin function
|
// Override keyMixin function
|
||||||
onKeyDownFunction() {
|
onKeyDownFunction() {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="journal-timetables">
|
<section class="journal-timetables">
|
||||||
|
|
||||||
<div class="journal_wrapper">
|
<div class="journal_wrapper">
|
||||||
<JournalOptions
|
<JournalOptions
|
||||||
@on-search-confirm="searchHistory"
|
@on-search-confirm="searchHistory"
|
||||||
@on-options-reset="resetOptions"
|
@on-options-reset="resetOptions"
|
||||||
:sorter-option-ids="['timetableId', 'beginDate', 'distance', 'total-stops']"
|
:sorter-option-ids="['timetableId', 'beginDate', 'distance', 'total-stops']"
|
||||||
:filters="journalTimetableFilters"
|
:filters="journalTimetableFilters"
|
||||||
:data-status="dataStatus"
|
:data-status="dataStatus"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DriverStats />
|
<DriverStats />
|
||||||
@@ -106,7 +105,7 @@ export default defineComponent({
|
|||||||
const searchersValues = reactive({
|
const searchersValues = reactive({
|
||||||
'search-train': '',
|
'search-train': '',
|
||||||
'search-driver': '',
|
'search-driver': '',
|
||||||
'search-author': '',
|
'search-dispatcher': '',
|
||||||
'search-date': '',
|
'search-date': '',
|
||||||
} as JorunalTimetableSearchType);
|
} as JorunalTimetableSearchType);
|
||||||
|
|
||||||
@@ -158,7 +157,7 @@ export default defineComponent({
|
|||||||
this.searchersValues['search-date'] = '';
|
this.searchersValues['search-date'] = '';
|
||||||
this.searchersValues['search-driver'] = '';
|
this.searchersValues['search-driver'] = '';
|
||||||
this.searchersValues['search-train'] = '';
|
this.searchersValues['search-train'] = '';
|
||||||
this.searchersValues['search-author'] = '';
|
this.searchersValues['search-dispatcher'] = '';
|
||||||
|
|
||||||
this.journalFilterActive = this.journalTimetableFilters[0];
|
this.journalFilterActive = this.journalTimetableFilters[0];
|
||||||
this.sorterActive.id = 'timetableId';
|
this.sorterActive.id = 'timetableId';
|
||||||
@@ -208,7 +207,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const driverName = props.searchers?.['search-driver'].trim();
|
const driverName = props.searchers?.['search-driver'].trim();
|
||||||
const trainNo = props.searchers?.['search-train'].trim();
|
const trainNo = props.searchers?.['search-train'].trim();
|
||||||
const authorName = props.searchers?.['search-author'].trim();
|
const authorName = props.searchers?.['search-dispatcher'].trim();
|
||||||
|
|
||||||
const dateString = props.searchers?.['search-date'].trim();
|
const dateString = props.searchers?.['search-date'].trim();
|
||||||
const timestampFrom = dateString ? Date.parse(new Date(dateString).toISOString()) - 120 * 60 * 1000 : undefined;
|
const timestampFrom = dateString ? Date.parse(new Date(dateString).toISOString()) - 120 * 60 * 1000 : undefined;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { JournalFilterType } from '../../scripts/enums/JournalFilterType';
|
import { JournalFilterType } from '../../scripts/enums/JournalFilterType';
|
||||||
|
|
||||||
export type JorunalTimetableSearchType = {
|
export type JorunalTimetableSearchType = {
|
||||||
[key in 'search-driver' | 'search-train' | 'search-date' | 'search-author']: string;
|
[key in 'search-driver' | 'search-train' | 'search-date' | 'search-dispatcher']: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface JournalTimetableFilter {
|
export interface JournalTimetableFilter {
|
||||||
|
|||||||
Reference in New Issue
Block a user