feat: don't open task detail in modal for list and table view

This commit is contained in:
Dominik Pschenitschni 2022-01-19 23:58:54 +01:00
parent 3d420c3770
commit de626eab31
Signed by untrusted user: dpschen
GPG Key ID: B257AC0149F43A77
5 changed files with 32 additions and 30 deletions

View File

@ -1,8 +1,12 @@
<template> <template>
<div> <div>
<a @click="$store.commit('menuActive', false)" class="menu-hide-button" v-if="menuActive"> <BaseButton
v-if="menuActive"
@click="$store.commit('menuActive', false)"
class="menu-hide-button"
>
<icon icon="times" /> <icon icon="times" />
</a> </BaseButton>
<div <div
:class="{'has-background': background}" :class="{'has-background': background}"
:style="{'background-image': background && `url(${background})`}" :style="{'background-image': background && `url(${background})`}"
@ -16,7 +20,11 @@
]" ]"
class="app-content" class="app-content"
> >
<a @click="$store.commit('menuActive', false)" class="mobile-overlay" v-if="menuActive"></a> <BaseButton
v-if="menuActive"
@click="$store.commit('menuActive', false)"
class="mobile-overlay"
/>
<quick-actions/> <quick-actions/>
@ -28,7 +36,9 @@
</router-view> </router-view>
<transition name="modal"> <transition name="modal">
<component v-if="currentModal" :is="currentModal" /> <TaskDetailViewModal v-if="currentModal" >
<component :is="currentModal" />
</TaskDetailViewModal>
</transition> </transition>
<a <a
@ -52,25 +62,23 @@ import {useEventListener} from '@vueuse/core'
import {CURRENT_LIST, KEYBOARD_SHORTCUTS_ACTIVE, MENU_ACTIVE} from '@/store/mutation-types' import {CURRENT_LIST, KEYBOARD_SHORTCUTS_ACTIVE, MENU_ACTIVE} from '@/store/mutation-types'
import Navigation from '@/components/home/navigation.vue' import Navigation from '@/components/home/navigation.vue'
import QuickActions from '@/components/quick-actions/quick-actions.vue' import QuickActions from '@/components/quick-actions/quick-actions.vue'
import TaskDetailViewModal from '@/views/tasks/TaskDetailViewModal.vue'
import BaseButton from '@/components/base/BaseButton.vue'
function useRouteWithModal() { function useRouteWithModal() {
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const historyState = computed(() => route.fullPath && window.history.state) const backdropView = computed(() => route.fullPath && window.history.state.backdropView)
const routeWithModal = computed(() => { const routeWithModal = computed(() => {
if (historyState.value.backdropView) { return backdropView.value
return router.resolve(historyState.value.backdropView) ? router.resolve(backdropView.value)
} else { : route
return route
}
}) })
const currentModal = shallowRef<VNode>() const currentModal = shallowRef<VNode>()
watchEffect(() => { watchEffect(() => {
const hasBackdropView = historyState.value.backdropView if (!backdropView.value) {
if (!hasBackdropView) {
currentModal.value = undefined currentModal.value = undefined
return return
} }

View File

@ -170,7 +170,8 @@ export default {
return { return {
name: 'task.detail', name: 'task.detail',
params: { id: this.task.id }, params: { id: this.task.id },
state: { backdropView: this.$router.currentRoute.value.fullPath }, // TODO: re-enable opening task detail in modal
// state: { backdropView: this.$router.currentRoute.value.fullPath },
} }
}, },
}, },

View File

@ -16,7 +16,7 @@ import DataExportDownload from '../views/user/DataExportDownload.vue'
import ShowTasksInRangeComponent from '../views/tasks/ShowTasksInRange.vue' import ShowTasksInRangeComponent from '../views/tasks/ShowTasksInRange.vue'
import LinkShareAuthComponent from '../views/sharing/LinkSharingAuth.vue' import LinkShareAuthComponent from '../views/sharing/LinkSharingAuth.vue'
import ListNamespaces from '../views/namespaces/ListNamespaces.vue' import ListNamespaces from '../views/namespaces/ListNamespaces.vue'
import TaskDetailViewModal from '../views/tasks/TaskDetailViewModal.vue' import TaskDetailView from '../views/tasks/TaskDetailView.vue'
// Team Handling // Team Handling
import ListTeamsComponent from '../views/teams/ListTeams.vue' import ListTeamsComponent from '../views/teams/ListTeams.vue'
// Label Handling // Label Handling
@ -242,7 +242,7 @@ const router = createRouter({
{ {
path: '/tasks/:id', path: '/tasks/:id',
name: 'task.detail', name: 'task.detail',
component: TaskDetailViewModal, component: TaskDetailView,
props: route => ({ taskId: parseInt(route.params.id as string) }), props: route => ({ taskId: parseInt(route.params.id as string) }),
}, },
{ {

View File

@ -181,7 +181,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { toRef, computed, Ref } from 'vue' import { toRef, computed, Ref } from 'vue'
import { useRouter } from 'vue-router'
import { useStorage } from '@vueuse/core' import { useStorage } from '@vueuse/core'
@ -273,14 +272,15 @@ function sort(property : keyof SortBy) {
} }
} }
const router = useRouter() // TODO: re-enable opening task detail in modal
// const router = useRouter()
const taskDetailRoutes = computed(() => Object.fromEntries( const taskDetailRoutes = computed(() => Object.fromEntries(
tasks.value.map(({id}) => ([ tasks.value.map(({id}) => ([
id, id,
{ {
name: 'task.detail', name: 'task.detail',
params: { id }, params: { id },
state: { backdropView: router.currentRoute.value.fullPath }, // state: { backdropView: router.currentRoute.value.fullPath },
}, },
])), ])),
)) ))

View File

@ -4,10 +4,10 @@
variant="scrolling" variant="scrolling"
class="task-detail-view-modal" class="task-detail-view-modal"
> >
<a @click="close()" class="close"> <BaseButton @click="close()" class="close">
<icon icon="times"/> <icon icon="times"/>
</a> </BaseButton>
<task-detail-view :task-id="props.taskId"/> <slot />
</modal> </modal>
</template> </template>
@ -15,14 +15,7 @@
import {computed} from 'vue' import {computed} from 'vue'
import {useRouter, useRoute} from 'vue-router' import {useRouter, useRoute} from 'vue-router'
import TaskDetailView from './TaskDetailView.vue' import BaseButton from '@/components/base/BaseButton.vue'
const props = defineProps({
taskId: {
type: Number,
required: true,
},
})
const route = useRoute() const route = useRoute()
const historyState = computed(() => route.fullPath && window.history.state) const historyState = computed(() => route.fullPath && window.history.state)