add on every page query for location

This commit is contained in:
Tim Gröger 2023-05-02 23:15:32 +02:00
parent 93f88792d0
commit 67d844d6e6
3 changed files with 40 additions and 4 deletions

View File

@ -144,6 +144,7 @@ export default defineComponent({
} }
onBeforeMount(async () => { onBeforeMount(async () => {
await router.replace({ query: { ...route.query, q_tab: 'agendaView' } });
if (!Object.keys(route.query).includes('q_date')) { if (!Object.keys(route.query).includes('q_date')) {
const q_date = date.formatDate(selectedDate.value, 'YYYY-MM-DD'); const q_date = date.formatDate(selectedDate.value, 'YYYY-MM-DD');
await router.replace({ query: { ...route.query, q_date } }); await router.replace({ query: { ...route.query, q_date } });

View File

@ -44,7 +44,8 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, ref } from 'vue'; import { computed, defineComponent, ref, onBeforeMount, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import ManageTypes from '../components/management/ManageTypes.vue'; import ManageTypes from '../components/management/ManageTypes.vue';
import EditEvent from '../components/management/EditEvent.vue'; import EditEvent from '../components/management/EditEvent.vue';
import { hasPermission } from '@flaschengeist/api'; import { hasPermission } from '@flaschengeist/api';
@ -70,6 +71,21 @@ export default defineComponent({
: []), : []),
]); ]);
const route = useRoute();
const router = useRouter();
onBeforeMount(async () => {
if (
(route.query.q_tab && route.query.q_tab === 'create') ||
route.query.q_tab === 'jobtypes' ||
route.query.q_tab === 'eventtypes'
) {
tab.value = route.query.q_tab;
} else {
await router.replace({ query: { q_tab: tab.value } });
}
});
const drawer = ref<boolean>(false); const drawer = ref<boolean>(false);
const tab = ref<string>('create'); const tab = ref<string>('create');
@ -82,6 +98,10 @@ export default defineComponent({
}, },
}); });
watch(tab, async (val) => {
await router.replace({ query: { q_tab: val } });
});
return { return {
showDrawer, showDrawer,
tab, tab,

View File

@ -43,7 +43,8 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, ref, onBeforeMount } from 'vue'; import { computed, defineComponent, ref, onBeforeMount, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import AgendaView from '../components/overview/AgendaView.vue'; import AgendaView from '../components/overview/AgendaView.vue';
import ListView from '../components/overview/ListView.vue'; import ListView from '../components/overview/ListView.vue';
@ -55,8 +56,19 @@ export default defineComponent({
components: { AgendaView, ListView }, components: { AgendaView, ListView },
setup() { setup() {
const store = useEventStore(); const store = useEventStore();
onBeforeMount(() => { const route = useRoute();
const router = useRouter();
const tab = ref<string>('agendaView');
onBeforeMount(async () => {
void store.getJobTypes(); void store.getJobTypes();
if (
Object.keys(route.query).includes('q_tab') &&
(route.query.q_tab === 'listView' || route.query.q_tab === 'agendaView')
) {
tab.value = route.query.q_tab as string;
} else {
await router.replace({ query: { ...route.query, q_tab: tab.value } });
}
}); });
const quasar = useQuasar(); const quasar = useQuasar();
@ -74,7 +86,10 @@ export default defineComponent({
}, },
}); });
const tab = ref<string>('agendaView'); watch(tab, async (val) => {
console.log(val);
await router.replace({ query: { ...route.query, q_tab: val } });
});
return { return {
showDrawer, showDrawer,