feature/projects-all-the-way-down #3323

Merged
konrad merged 123 commits from feature/projects-all-the-way-down into main 2023-05-30 10:09:40 +00:00
3 changed files with 23 additions and 18 deletions
Showing only changes of commit 6a8c656dbb - Show all commits

View File

@ -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(' &gt; ') }} &gt;
</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'

View File

@ -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

Use long var names.

Use long var names.

Done.

Done.
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

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.

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
if (!project.parentProjectId) {
	return [project]
}

const parentProject = projectStore.getProjectById(project.parentProjectId)

return [
	...getParentProjects(parentProject, projectStore),
	project,
]
```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,
]
}

View File

@ -14,7 +14,7 @@
ref="heading"
/>
<h6 class="subtitle" v-if="project?.id">
<template v-for="p in getAllParentProjects(project)">

Shouldn't we still show the parent here?

Shouldn't we still show the parent here?

I've changed it now so that is shows this:

Screenshot_20230328_174428.png

(each project is clickable individually)

For a hierarchy like this:

Screenshot_20230328_174646.png

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)

Can't see these images either

Can't see these images either

Again 404?

Again 404?

This starts to feel like a gitea bug...

This starts to feel like a gitea bug...
<template v-for="p in getParentProjects(project, projectStore)">

This won't update dynamically. Should we change the getParentProjects to a computed parentProjects that automatically updates instead?

This won't update dynamically. Should we change the `getParentProjects` to a computed `parentProjects` that automatically updates instead?

I tried to change it but it fails with getAncestors is not a function. Any idea?

I tried to change it but it fails with `getAncestors is not a function`. Any idea?

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>