feature/projects-all-the-way-down #3323
|
@ -11,7 +11,10 @@
|
|||
@search="findProjects"
|
||||
>
|
||||
<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>
|
||||
</Multiselect>
|
||||
</template>
|
||||
|
@ -24,6 +27,7 @@ import {useI18n} from 'vue-i18n'
|
|||
import type {IProject} from '@/modelTypes/IProject'
|
||||
|
||||
import {useProjectStore} from '@/stores/projects'
|
||||
import {getProjectTitle, getParentProjects} from '@/helpers/getProjectTitle'
|
||||
|
||||
import ProjectModel from '@/models/project'
|
||||
|
||||
|
|
|
@ -1,14 +1,28 @@
|
|||
import {i18n} from '@/i18n'
|
||||
import type {IProject} from '@/modelTypes/IProject'
|
||||
import {useProjectStore} from '@/stores/projects'
|
||||
|
||||
dpschen marked this conversation as resolved
Outdated
|
||||
export function getProjectTitle(project: IProject) {
|
||||
if (project.id === -1) {
|
||||
return i18n.global.t('project.pseudo.favorites.title')
|
||||
}
|
||||
|
||||
|
||||
if (project.title === 'Inbox') {
|
||||
return i18n.global.t('project.inboxTitle')
|
||||
}
|
||||
|
||||
|
||||
return project.title
|
||||
}
|
||||
|
||||
export function getParentProjects(project: IProject, projectStore): IProject[] {
|
||||
konrad marked this conversation as resolved
Outdated
dpschen
commented
This should either be in a new helper (see the name of this file) or both should be part of the project store. This should either be in a new helper (see the name of this file) or both should be part of the project store.
konrad
commented
Refactored it and moved to the projects store. Refactored it and moved to the projects store.
|
||||
let parents = []
|
||||
if (project.parentProjectId) {
|
||||
konrad marked this conversation as resolved
Outdated
dpschen
commented
```ts
if (!project.parentProjectId) {
return [project]
}
const parentProject = projectStore.getProjectById(project.parentProjectId)
return [
...getParentProjects(parentProject, projectStore),
project,
]
```
|
||||
const parentProject = projectStore.getProjectById(project.parentProjectId)
|
||||
parents = getParentProjects(parentProject, projectStore)
|
||||
}
|
||||
|
||||
return [
|
||||
...parents,
|
||||
project,
|
||||
]
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
ref="heading"
|
||||
/>
|
||||
<h6 class="subtitle" v-if="project?.id">
|
||||
<template v-for="p in getAllParentProjects(project)">
|
||||
dpschen
commented
Shouldn't we still show the parent here? Shouldn't we still show the parent here?
konrad
commented
I've changed it now so that is shows this: (each project is clickable individually) For a hierarchy like this: I've changed it now so that is shows this:
![Screenshot_20230328_174428.png](/attachments/35babb55-b48a-49bf-a595-3fcc28da12dc)
(each project is clickable individually)
For a hierarchy like this:
![Screenshot_20230328_174646.png](/attachments/070d677e-d199-45ee-af6b-c0a6b3196681)
dpschen
commented
Can't see these images either Can't see these images either
konrad
commented
This starts to feel like a gitea bug... This starts to feel like a gitea bug...
|
||||
<template v-for="p in getParentProjects(project, projectStore)">
|
||||
dpschen
commented
This won't update dynamically. Should we change the This won't update dynamically. Should we change the `getParentProjects` to a computed `parentProjects` that automatically updates instead?
konrad
commented
I tried to change it but it fails with I tried to change it but it fails with `getAncestors is not a function`. Any idea?
konrad
commented
Actually this does update dynamically when the project changes. I've had a task open, moved the project to another parent project and it updated instantly. Actually this does update dynamically when the project changes. I've had a task open, moved the project to another parent project and it updated instantly.
|
||||
<router-link :to="{ name: 'project.index', params: { projectId: p.id } }">
|
||||
{{ getProjectTitle(p) }}
|
||||
</router-link>
|
||||
|
@ -488,7 +488,7 @@ import TaskSubscription from '@/components/misc/subscription.vue'
|
|||
import CustomTransition from '@/components/misc/CustomTransition.vue'
|
||||
|
||||
import {uploadFile} from '@/helpers/attachments'
|
||||
import {getProjectTitle} from '@/helpers/getProjectTitle'
|
||||
import {getProjectTitle, getParentProjects} from '@/helpers/getProjectTitle'
|
||||
import {scrollIntoView} from '@/helpers/scrollIntoView'
|
||||
|
||||
import {useBaseStore} from '@/stores/base'
|
||||
|
@ -784,19 +784,6 @@ async function setPercentDone(percentDone: number) {
|
|||
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>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
Reference in New Issue
Block a user
Use long var names.
Done.