diff --git a/src/router/index.ts b/src/router/index.ts index d00b6d4c4..228c13fbf 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -11,6 +11,7 @@ import {LINK_SHARE_HASH_PREFIX} from '@/constants/linkShareHash' import {useProjectStore} from '@/stores/projects' import {useAuthStore} from '@/stores/auth' import {useBaseStore} from '@/stores/base' +import {useTaskStore} from '@/stores/tasks' import HomeComponent from '@/views/Home.vue' import NotFoundComponent from '@/views/404.vue' @@ -207,6 +208,34 @@ const router = createRouter({ component: TaskDetailView, props: route => ({ taskId: Number(route.params.id as string) }), }, + { + path: '/tasks/create', + name: 'task.create', + beforeEnter: async (to, from, next) => { + const taskStore = useTaskStore() + const authStore = useAuthStore() + // Need to get settings populated first! + await authStore.checkAuth() + + const defaultProjectId = authStore.settings.defaultProjectId + if(!defaultProjectId) { + return false + } + + const title = to.query.title || 'Share' + const description = to.query.description || '' + + const task = await taskStore.createNewTask({ + title, + description, + projectId: defaultProjectId, + }) + + // After Task creation succeeds, redirect to show the task. + return next({name: 'task.detail', params: {id: task.id}}) + }, + component: TaskDetailView, + }, { path: '/tasks/by/upcoming', name: 'tasks.range', diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts index 3ea876dc5..920a9bbb5 100644 --- a/src/stores/tasks.ts +++ b/src/stores/tasks.ts @@ -399,6 +399,7 @@ export const useTaskStore = defineStore('task', () => { async function createNewTask({ title, + description, bucketId, projectId, position, @@ -435,6 +436,7 @@ export const useTaskStore = defineStore('task', () => { const task = new TaskModel({ title: cleanedTitle, + description: description, projectId: foundProjectId, dueDate, priority: parsedTask.priority, diff --git a/vite.config.ts b/vite.config.ts index d1eaf6771..b7d3f2032 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -202,6 +202,15 @@ export default defineConfig(({mode}) => { url: '/teams', }, ], + share_target: { + action: '/tasks/create', + enctype: 'application/x-www-form-urlencoded', + method: 'GET', + params: { + title: 'title', + text: 'description', + }, + }, }, }), viteSentry(getSentryConfig(env)),