Skip to content

Commit

Permalink
Added search type to fields and moved state to query params
Browse files Browse the repository at this point in the history
  • Loading branch information
Ejden committed Sep 12, 2024
1 parent a5f1b74 commit 4b6f819
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 11 additions & 3 deletions hermes-console/src/views/group-topics/GroupTopicsView.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<script setup lang="ts">
import { computed } from 'vue';
import {computed, watch} from 'vue';

Check failure on line 2 in hermes-console/src/views/group-topics/GroupTopicsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `import·{computed,·watch` with `··import·{·computed,·watch·`

Check failure on line 2 in hermes-console/src/views/group-topics/GroupTopicsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `import·{computed,·watch` with `··import·{·computed,·watch·`
import { isAdmin, isAny } from '@/utils/roles-util';
import { ref } from 'vue';
import { useDialog } from '@/composables/dialog/use-dialog/useDialog';
import { useGroups } from '@/composables/groups/use-groups/useGroups';
import { useI18n } from 'vue-i18n';
import { useRoles } from '@/composables/roles/use-roles/useRoles';
import { useRouter } from 'vue-router';
import {useRoute, useRouter} from 'vue-router';

Check failure on line 9 in hermes-console/src/views/group-topics/GroupTopicsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `import·{useRoute,·useRouter` with `··import·{·useRoute,·useRouter·`

Check failure on line 9 in hermes-console/src/views/group-topics/GroupTopicsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `import·{useRoute,·useRouter` with `··import·{·useRoute,·useRouter·`
import ConfirmationDialog from '@/components/confirmation-dialog/ConfirmationDialog.vue';
import ConsoleAlert from '@/components/console-alert/ConsoleAlert.vue';
import GroupTopicsListing from '@/views/group-topics/group-topics-listing/GroupTopicsListing.vue';
import LoadingSpinner from '@/components/loading-spinner/LoadingSpinner.vue';
import TopicForm from '@/views/topic/topic-form/TopicForm.vue';
const router = useRouter();
const route = useRoute();
const params = router.currentRoute.value.params as Record<string, string>;
const { groupId } = params;
const { t } = useI18n();
const { groups, loading, error, removeGroup } = useGroups();
const filter = ref<string>();
const filter = ref<string>(route.query.q as string || '');

Check failure on line 24 in hermes-console/src/views/group-topics/GroupTopicsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `route.query.q·as·string` with `(route.query.q·as·string)`

Check failure on line 24 in hermes-console/src/views/group-topics/GroupTopicsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `route.query.q·as·string` with `(route.query.q·as·string)`
const roles = useRoles(null, null).roles;
Expand Down Expand Up @@ -75,6 +76,12 @@
href: `/ui/groups/${groupId}`,
},
];
const updateQueryParams = () => {
router.push({ query: { ...route.query, q: filter.value } } );

Check failure on line 81 in hermes-console/src/views/group-topics/GroupTopicsView.vue

View workflow job for this annotation

GitHub Actions / build

Delete `·`

Check failure on line 81 in hermes-console/src/views/group-topics/GroupTopicsView.vue

View workflow job for this annotation

GitHub Actions / build

Delete `·`
};
watch(filter, updateQueryParams);
</script>

<template>
Expand Down Expand Up @@ -161,6 +168,7 @@
density="compact"
v-model="filter"
prepend-inner-icon="mdi-magnify"
type="search"
/>
</v-col>
</v-row>
Expand Down
14 changes: 11 additions & 3 deletions hermes-console/src/views/groups/GroupsView.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { isAny } from '@/utils/roles-util';
import { ref } from 'vue';
import {ref, watch} from 'vue';

Check failure on line 3 in hermes-console/src/views/groups/GroupsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `ref,·watch` with `·ref,·watch·`

Check failure on line 3 in hermes-console/src/views/groups/GroupsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `ref,·watch` with `·ref,·watch·`
import { useGroups } from '@/composables/groups/use-groups/useGroups';
import { useI18n } from 'vue-i18n';
import { useRoles } from '@/composables/roles/use-roles/useRoles';
import { useRouter } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import ConsoleAlert from '@/components/console-alert/ConsoleAlert.vue';
import GroupForm from '@/views/groups/group-form/GroupForm.vue';
import GroupListing from '@/views/groups/group-listing/GroupListing.vue';
Expand All @@ -13,10 +13,11 @@
const { groups, loading, error, createGroup } = useGroups();
const { t } = useI18n();
const router = useRouter();
const route = useRoute();
const roles = useRoles(null, null)?.roles;
const filter = ref<string>();
const filter = ref<string>(route.query.q as string || '');

Check failure on line 20 in hermes-console/src/views/groups/GroupsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `route.query.q·as·string` with `(route.query.q·as·string)`

Check failure on line 20 in hermes-console/src/views/groups/GroupsView.vue

View workflow job for this annotation

GitHub Actions / build

Replace `route.query.q·as·string` with `(route.query.q·as·string)`
const createGroupDialogOpen = ref(false);
const breadcrumbsItems = [
{
Expand All @@ -35,6 +36,12 @@
router.go(0);
}
};
const updateQueryParams = () => {
router.push({ query: { ...route.query, q: filter.value } } );

Check failure on line 41 in hermes-console/src/views/groups/GroupsView.vue

View workflow job for this annotation

GitHub Actions / build

Delete `·`

Check failure on line 41 in hermes-console/src/views/groups/GroupsView.vue

View workflow job for this annotation

GitHub Actions / build

Delete `·`
};
watch(filter, updateQueryParams);
</script>

<template>
Expand Down Expand Up @@ -82,6 +89,7 @@
density="compact"
v-model="filter"
prepend-inner-icon="mdi-magnify"
type="search"
/>
</v-col>
</v-row>
Expand Down

0 comments on commit 4b6f819

Please sign in to comment.