Skip to content

Commit 4b6f819

Browse files
committed
Added search type to fields and moved state to query params
1 parent a5f1b74 commit 4b6f819

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

hermes-console/src/views/group-topics/GroupTopicsView.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
<script setup lang="ts">
2-
import { computed } from 'vue';
2+
import {computed, watch} from 'vue';
33
import { isAdmin, isAny } from '@/utils/roles-util';
44
import { ref } from 'vue';
55
import { useDialog } from '@/composables/dialog/use-dialog/useDialog';
66
import { useGroups } from '@/composables/groups/use-groups/useGroups';
77
import { useI18n } from 'vue-i18n';
88
import { useRoles } from '@/composables/roles/use-roles/useRoles';
9-
import { useRouter } from 'vue-router';
9+
import {useRoute, useRouter} from 'vue-router';
1010
import ConfirmationDialog from '@/components/confirmation-dialog/ConfirmationDialog.vue';
1111
import ConsoleAlert from '@/components/console-alert/ConsoleAlert.vue';
1212
import GroupTopicsListing from '@/views/group-topics/group-topics-listing/GroupTopicsListing.vue';
1313
import LoadingSpinner from '@/components/loading-spinner/LoadingSpinner.vue';
1414
import TopicForm from '@/views/topic/topic-form/TopicForm.vue';
1515
1616
const router = useRouter();
17+
const route = useRoute();
1718
const params = router.currentRoute.value.params as Record<string, string>;
1819
const { groupId } = params;
1920
const { t } = useI18n();
2021
2122
const { groups, loading, error, removeGroup } = useGroups();
2223
23-
const filter = ref<string>();
24+
const filter = ref<string>(route.query.q as string || '');
2425
2526
const roles = useRoles(null, null).roles;
2627
@@ -75,6 +76,12 @@
7576
href: `/ui/groups/${groupId}`,
7677
},
7778
];
79+
80+
const updateQueryParams = () => {
81+
router.push({ query: { ...route.query, q: filter.value } } );
82+
};
83+
84+
watch(filter, updateQueryParams);
7885
</script>
7986

8087
<template>
@@ -161,6 +168,7 @@
161168
density="compact"
162169
v-model="filter"
163170
prepend-inner-icon="mdi-magnify"
171+
type="search"
164172
/>
165173
</v-col>
166174
</v-row>

hermes-console/src/views/groups/GroupsView.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script setup lang="ts">
22
import { isAny } from '@/utils/roles-util';
3-
import { ref } from 'vue';
3+
import {ref, watch} from 'vue';
44
import { useGroups } from '@/composables/groups/use-groups/useGroups';
55
import { useI18n } from 'vue-i18n';
66
import { useRoles } from '@/composables/roles/use-roles/useRoles';
7-
import { useRouter } from 'vue-router';
7+
import { useRoute, useRouter } from 'vue-router';
88
import ConsoleAlert from '@/components/console-alert/ConsoleAlert.vue';
99
import GroupForm from '@/views/groups/group-form/GroupForm.vue';
1010
import GroupListing from '@/views/groups/group-listing/GroupListing.vue';
@@ -13,10 +13,11 @@
1313
const { groups, loading, error, createGroup } = useGroups();
1414
const { t } = useI18n();
1515
const router = useRouter();
16+
const route = useRoute();
1617
1718
const roles = useRoles(null, null)?.roles;
1819
19-
const filter = ref<string>();
20+
const filter = ref<string>(route.query.q as string || '');
2021
const createGroupDialogOpen = ref(false);
2122
const breadcrumbsItems = [
2223
{
@@ -35,6 +36,12 @@
3536
router.go(0);
3637
}
3738
};
39+
40+
const updateQueryParams = () => {
41+
router.push({ query: { ...route.query, q: filter.value } } );
42+
};
43+
44+
watch(filter, updateQueryParams);
3845
</script>
3946

4047
<template>
@@ -82,6 +89,7 @@
8289
density="compact"
8390
v-model="filter"
8491
prepend-inner-icon="mdi-magnify"
92+
type="search"
8593
/>
8694
</v-col>
8795
</v-row>

0 commit comments

Comments
 (0)