reaktywne filtry URL w dzienniku RJ

This commit is contained in:
2023-12-17 16:10:13 +01:00
parent f4be32aa39
commit e8ed36df16
7 changed files with 141 additions and 71 deletions
+17 -10
View File
@@ -166,6 +166,15 @@ export default defineComponent({
},
methods: {
handleRouteParams() {
this.$router.push({
query: {
'search-date': this.searchersValues['search-date'] || undefined,
'search-station': this.searchersValues['search-station'] || undefined,
'search-dispatcher': this.searchersValues['search-dispatcher'] || undefined
}
});
},
handleScroll(e: Event) {
const listElement = e.target as HTMLElement;
const scrollTop = listElement.scrollTop;
@@ -178,21 +187,19 @@ export default defineComponent({
},
handleQueries(query: LocationQuery) {
const queryKeys = Object.keys(query);
if (queryKeys.includes('sceneryName')) this.setSearchers('', `${query.sceneryName}`, '');
if (queryKeys.includes('dispatcherName'))
this.setSearchers('', '', `${query.dispatcherName}`);
// if (queryKeys.includes('sceneryName')) this.setSearchers('', `${query.sceneryName}`, '');
// if (queryKeys.includes('dispatcherName'))
// this.setSearchers('', '', `${query.dispatcherName}`);
},
setSearchers(date: string, station: string, dispatcher: string) {
this.searchersValues['search-date'] = date;
this.searchersValues['search-station'] = station;
this.searchersValues['search-dispatcher'] = dispatcher;
setSearchers(searchers: { [key: string]: string }) {
this.searchersValues['search-date'] = searchers['search-date'] ?? '';
this.searchersValues['search-station'] = searchers['search-station'] ?? '';
this.searchersValues['search-dispatcher'] = searchers['search-dispatcher'] ?? '';
},
resetOptions() {
this.setSearchers('', '', '');
this.setSearchers({});
this.sorterActive.id = 'timestampFrom';
this.fetchHistoryData();