fix(project): correctly show the number of tasks and projects when deleting a project
This commit is contained in:
parent
12fbde8e84
commit
3b77fff4c9
@ -248,6 +248,7 @@
|
|||||||
"text2": "This includes all tasks and CANNOT BE UNDONE!",
|
"text2": "This includes all tasks and CANNOT BE UNDONE!",
|
||||||
"success": "The project was successfully deleted.",
|
"success": "The project was successfully deleted.",
|
||||||
"tasksToDelete": "This will irrevocably remove approx. {count} tasks.",
|
"tasksToDelete": "This will irrevocably remove approx. {count} tasks.",
|
||||||
|
"tasksAndChildProjectsToDelete": "This will irrevocably remove approx. {tasks} tasks and {projects} projects.",
|
||||||
"noTasksToDelete": "This project does not contain any tasks, it should be safe to delete."
|
"noTasksToDelete": "This project does not contain any tasks, it should be safe to delete."
|
||||||
},
|
},
|
||||||
"duplicate": {
|
"duplicate": {
|
||||||
|
@ -16,9 +16,7 @@
|
|||||||
v-if="totalTasks !== null"
|
v-if="totalTasks !== null"
|
||||||
class="has-text-weight-bold"
|
class="has-text-weight-bold"
|
||||||
>
|
>
|
||||||
{{
|
{{ deleteNotice }}
|
||||||
totalTasks > 0 ? $t('project.delete.tasksToDelete', {count: totalTasks}) : $t('project.delete.noTasksToDelete')
|
|
||||||
}}
|
|
||||||
</p>
|
</p>
|
||||||
<Loading
|
<Loading
|
||||||
v-else
|
v-else
|
||||||
@ -39,9 +37,9 @@ import {useTitle} from '@/composables/useTitle'
|
|||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import {useRoute, useRouter} from 'vue-router'
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
import TaskCollectionService from '@/services/taskCollection'
|
|
||||||
import Loading from '@/components/misc/loading.vue'
|
import Loading from '@/components/misc/loading.vue'
|
||||||
import {useProjectStore} from '@/stores/projects'
|
import {useProjectStore} from '@/stores/projects'
|
||||||
|
import TaskService from '@/services/task'
|
||||||
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
const projectStore = useProjectStore()
|
const projectStore = useProjectStore()
|
||||||
@ -51,6 +49,7 @@ const router = useRouter()
|
|||||||
const totalTasks = ref<number | null>(null)
|
const totalTasks = ref<number | null>(null)
|
||||||
|
|
||||||
const project = computed(() => projectStore.projects[route.params.projectId])
|
const project = computed(() => projectStore.projects[route.params.projectId])
|
||||||
|
const childProjectIds = ref<number[]>([])
|
||||||
|
|
||||||
watchEffect(
|
watchEffect(
|
||||||
() => {
|
() => {
|
||||||
@ -58,15 +57,32 @@ watchEffect(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskCollectionService = new TaskCollectionService()
|
childProjectIds.value = projectStore.getChildProjects(parseInt(route.params.projectId)).map(p => p.id)
|
||||||
taskCollectionService.getAll({projectId: route.params.projectId}).then(() => {
|
if (childProjectIds.value.length === 0) {
|
||||||
totalTasks.value = taskCollectionService.totalPages * taskCollectionService.resultCount
|
childProjectIds.value = [parseInt(route.params.projectId)]
|
||||||
|
}
|
||||||
|
|
||||||
|
const taskService = new TaskService()
|
||||||
|
taskService.getAll({}, {filter: `project in '${childProjectIds.value.join(',')}'`}).then(() => {
|
||||||
|
totalTasks.value = taskService.totalPages * taskService.resultCount
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
useTitle(() => t('project.delete.title', {project: project?.value?.title}))
|
useTitle(() => t('project.delete.title', {project: project?.value?.title}))
|
||||||
|
|
||||||
|
const deleteNotice = computed(() => {
|
||||||
|
if(totalTasks.value && totalTasks.value > 0 && childProjectIds.value.length <= 1) {
|
||||||
|
return t('project.delete.tasksToDelete', {count: totalTasks.value})
|
||||||
|
}
|
||||||
|
|
||||||
|
if(totalTasks.value && totalTasks.value > 0 && childProjectIds.value.length > 1) {
|
||||||
|
return t('project.delete.tasksAndChildProjectsToDelete', {tasks: totalTasks.value, projects: childProjectIds.value.length})
|
||||||
|
}
|
||||||
|
|
||||||
|
return t('project.delete.noTasksToDelete')
|
||||||
|
})
|
||||||
|
|
||||||
async function deleteProject() {
|
async function deleteProject() {
|
||||||
if (!project.value) {
|
if (!project.value) {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user