mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
chore(journal): added dispatcher filtering by duty id
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
export namespace Journal {
|
||||
export type DispatcherSearchKey =
|
||||
| 'search-duty-id'
|
||||
| 'search-dispatcher'
|
||||
| 'search-station'
|
||||
| 'search-date-from'
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
:to="
|
||||
'trainNo' in entry.value
|
||||
? `/journal/timetables?search-train=%23${entry.value.id}`
|
||||
: `/journal/dispatchers?search-dispatcher=${entry.value.dispatcherName}`
|
||||
: `/journal/dispatchers?search-duty-id=${entry.value.id}`
|
||||
"
|
||||
>
|
||||
<!-- Date -->
|
||||
@@ -209,7 +209,7 @@ function toggleFilter(filterType: JournalEntryType) {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 1em;
|
||||
padding: 0 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.menu-btn {
|
||||
|
||||
@@ -51,6 +51,7 @@ import JournalStats from '../components/JournalView/JournalStats.vue';
|
||||
import { useApiStore } from '../store/apiStore';
|
||||
|
||||
interface DispatchersQueryParams {
|
||||
dutyId?: number;
|
||||
dispatcherName?: string;
|
||||
stationName?: string;
|
||||
stationHash?: string;
|
||||
@@ -114,12 +115,13 @@ export default defineComponent({
|
||||
const sorterActive: Journal.DispatcherSorter = reactive({ id: 'timestampFrom', dir: -1 });
|
||||
const journalFilterActive = ref({});
|
||||
|
||||
const searchersValues = reactive({
|
||||
const searchersValues = reactive<Record<Journal.DispatcherSearchKey, string>>({
|
||||
'search-duty-id': '',
|
||||
'search-dispatcher': '',
|
||||
'search-station': '',
|
||||
'search-date-from': '',
|
||||
'search-date-to': ''
|
||||
} as Journal.DispatcherSearchType);
|
||||
});
|
||||
|
||||
provide('sorterActive', sorterActive);
|
||||
provide('journalFilterActive', journalFilterActive);
|
||||
@@ -171,6 +173,7 @@ export default defineComponent({
|
||||
handleRouteParams() {
|
||||
this.$router.push({
|
||||
query: {
|
||||
'search-duty-id': this.searchersValues['search-duty-id'] || undefined,
|
||||
'search-date-from': this.searchersValues['search-date-from'] || undefined,
|
||||
'search-date-to': this.searchersValues['search-date-to'] || undefined,
|
||||
'search-station': this.searchersValues['search-station'] || undefined,
|
||||
@@ -194,7 +197,8 @@ export default defineComponent({
|
||||
this.setOptions(query as any);
|
||||
},
|
||||
|
||||
setOptions(options: { [key: string]: string }) {
|
||||
setOptions(options: Record<string, string>) {
|
||||
this.searchersValues['search-duty-id'] = options['search-duty-id'] ?? '';
|
||||
this.searchersValues['search-date-from'] = options['search-date-from'] ?? '';
|
||||
this.searchersValues['search-date-to'] = options['search-date-to'] ?? '';
|
||||
this.searchersValues['search-station'] = options['search-station'] ?? '';
|
||||
@@ -231,6 +235,7 @@ export default defineComponent({
|
||||
async fetchHistoryData() {
|
||||
const queryParams: DispatchersQueryParams = {};
|
||||
|
||||
const dutyId = this.searchersValues['search-duty-id'].trim() || undefined;
|
||||
const dispatcherName = this.searchersValues['search-dispatcher'].trim() || undefined;
|
||||
const stationName = this.searchersValues['search-station'].trim() || undefined;
|
||||
const dateFromString = this.searchersValues['search-date-from'].trim() || undefined;
|
||||
@@ -251,6 +256,7 @@ export default defineComponent({
|
||||
dateToISO = dateTo.toISOString();
|
||||
}
|
||||
|
||||
queryParams['dutyId'] = Number(dutyId) || undefined;
|
||||
queryParams['dispatcherName'] = dispatcherName;
|
||||
|
||||
queryParams['dateFrom'] = dateFromISO;
|
||||
|
||||
Reference in New Issue
Block a user