feat: show all parent projects in project search
This commit is contained in:
parent
63ba2982c9
commit
6a8c656dbb
@ -11,7 +11,10 @@
|
|||||||
@search="findProjects"
|
@search="findProjects"
|
||||||
>
|
>
|
||||||
<template #searchResult="{option}">
|
<template #searchResult="{option}">
|
||||||
{{ (option as IProject).title }}
|
<span class="has-text-grey">
|
||||||
|
{{ getParentProjects(option, projectStore).filter(p => p.id !== option.id).map(p => getProjectTitle(p) ).join(' > ') }} >
|
||||||
|
</span>
|
||||||
|
{{ getProjectTitle(option) }}
|
||||||
</template>
|
</template>
|
||||||
</Multiselect>
|
</Multiselect>
|
||||||
</template>
|
</template>
|
||||||
@ -24,6 +27,7 @@ import {useI18n} from 'vue-i18n'
|
|||||||
import type {IProject} from '@/modelTypes/IProject'
|
import type {IProject} from '@/modelTypes/IProject'
|
||||||
|
|
||||||
import {useProjectStore} from '@/stores/projects'
|
import {useProjectStore} from '@/stores/projects'
|
||||||
|
import {getProjectTitle, getParentProjects} from '@/helpers/getProjectTitle'
|
||||||
|
|
||||||
import ProjectModel from '@/models/project'
|
import ProjectModel from '@/models/project'
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {i18n} from '@/i18n'
|
import {i18n} from '@/i18n'
|
||||||
import type {IProject} from '@/modelTypes/IProject'
|
import type {IProject} from '@/modelTypes/IProject'
|
||||||
|
import {useProjectStore} from '@/stores/projects'
|
||||||
|
|
||||||
export function getProjectTitle(project: IProject) {
|
export function getProjectTitle(project: IProject) {
|
||||||
if (project.id === -1) {
|
if (project.id === -1) {
|
||||||
@ -12,3 +13,16 @@ export function getProjectTitle(project: IProject) {
|
|||||||
|
|
||||||
return project.title
|
return project.title
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getParentProjects(project: IProject, projectStore): IProject[] {
|
||||||
|
let parents = []
|
||||||
|
if (project.parentProjectId) {
|
||||||
|
const parentProject = projectStore.getProjectById(project.parentProjectId)
|
||||||
|
parents = getParentProjects(parentProject, projectStore)
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
...parents,
|
||||||
|
project,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
ref="heading"
|
ref="heading"
|
||||||
/>
|
/>
|
||||||
<h6 class="subtitle" v-if="project?.id">
|
<h6 class="subtitle" v-if="project?.id">
|
||||||
<template v-for="p in getAllParentProjects(project)">
|
<template v-for="p in getParentProjects(project, projectStore)">
|
||||||
<router-link :to="{ name: 'project.index', params: { projectId: p.id } }">
|
<router-link :to="{ name: 'project.index', params: { projectId: p.id } }">
|
||||||
{{ getProjectTitle(p) }}
|
{{ getProjectTitle(p) }}
|
||||||
</router-link>
|
</router-link>
|
||||||
@ -488,7 +488,7 @@ import TaskSubscription from '@/components/misc/subscription.vue'
|
|||||||
import CustomTransition from '@/components/misc/CustomTransition.vue'
|
import CustomTransition from '@/components/misc/CustomTransition.vue'
|
||||||
|
|
||||||
import {uploadFile} from '@/helpers/attachments'
|
import {uploadFile} from '@/helpers/attachments'
|
||||||
import {getProjectTitle} from '@/helpers/getProjectTitle'
|
import {getProjectTitle, getParentProjects} from '@/helpers/getProjectTitle'
|
||||||
import {scrollIntoView} from '@/helpers/scrollIntoView'
|
import {scrollIntoView} from '@/helpers/scrollIntoView'
|
||||||
|
|
||||||
import {useBaseStore} from '@/stores/base'
|
import {useBaseStore} from '@/stores/base'
|
||||||
@ -784,19 +784,6 @@ async function setPercentDone(percentDone: number) {
|
|||||||
task: newTask,
|
task: newTask,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllParentProjects(project: IProject): IProject[] {
|
|
||||||
let parents = []
|
|
||||||
if (project.parentProjectId) {
|
|
||||||
const parentProject = projectStore.getProjectById(project.parentProjectId)
|
|
||||||
parents = getAllParentProjects(parentProject)
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
...parents,
|
|
||||||
project,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user