-
-
-
-
- {{
- $store.getters['lists/getListById'](t.listId) === null ? '' : $store.getters['lists/getListById'](t.listId).title
- }} >
-
- {{ t.title }}
+
{{ $t('task.relation.noneYet') }}
@@ -110,10 +122,10 @@
v-if="showDeleteModal"
>
{{ $t('task.relation.delete') }}
-
+
{{ $t('task.relation.deleteText1') }}
- {{ $t('task.relation.deleteText2') }}
+ {{ $t('task.relation.deleteText2') }}
@@ -183,6 +195,19 @@ export default {
showCreate() {
return Object.keys(this.relatedTasks).length === 0 || this.showNewRelationForm
},
+ namespace() {
+ return this.$store.getters['namespaces/getListAndNamespaceById'](this.listId, true)?.namespace
+ },
+ mappedRelatedTasks() {
+ return Object.entries(this.relatedTasks).map(([kind, tasks]) => ({
+ title: this.$tc(`task.relation.kinds.${kind}`, tasks.length),
+ tasks: this.mapRelatedTasks(tasks),
+ kind,
+ }))
+ },
+ mappedFoundTasks() {
+ return this.mapRelatedTasks(this.foundTasks.filter(t => t.id !== this.taskId))
+ },
},
methods: {
async findTasks(query) {
@@ -217,15 +242,14 @@ export default {
try {
await this.taskRelationService.delete(rel)
- Object.entries(this.relatedTasks).some(([relationKind, t]) => {
- const found = typeof this.relatedTasks[relationKind][t] !== 'undefined' &&
- this.relatedTasks[relationKind][t].id === this.relationToDelete.otherTaskId &&
- relationKind === this.relationToDelete.relationKind
- if (!found) return false
+ const kind = this.relationToDelete.relationKind
+ for (const t in this.relatedTasks[kind]) {
+ if (this.relatedTasks[kind][t].id === this.relationToDelete.otherTaskId) {
+ this.relatedTasks[kind].splice(t, 1)
- this.relatedTasks[relationKind].splice(t, 1)
- return true
- })
+ break
+ }
+ }
this.saved = true
setTimeout(() => {
@@ -245,13 +269,34 @@ export default {
relationKindTitle(kind, length) {
return this.$tc(`task.relation.kinds.${kind}`, length)
},
+
+ mapRelatedTasks(tasks) {
+ return tasks
+ .map(task => {
+ // by doing this here once we can save a lot of duplicate calls in the template
+ const {
+ list,
+ namespace,
+ } = this.$store.getters['namespaces/getListAndNamespaceById'](task.listId, true)
+
+ return {
+ ...task,
+ differentNamespace:
+ (namespace !== null &&
+ namespace.id !== this.namespace.id &&
+ namespace?.title) || null,
+ differentList:
+ (list !== null &&
+ task.listId !== this.listId &&
+ list?.title) || null,
+ }
+ })
+ },
},
}
\ No newline at end of file
diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json
index 93434886..11319b16 100644
--- a/src/i18n/lang/en.json
+++ b/src/i18n/lang/en.json
@@ -656,6 +656,7 @@
"searchPlaceholder": "Type search for a new task to add as related…",
"createPlaceholder": "Add this as new related task",
"differentList": "This task belongs to a different list.",
+ "differentNamespace": "This task belongs to a different namespace.",
"noneYet": "No task relations yet.",
"delete": "Delete Task Relation",
"deleteText1": "Are you sure you want to delete this task relation?",
diff --git a/src/store/modules/namespaces.js b/src/store/modules/namespaces.js
index cb78f560..553f236f 100644
--- a/src/store/modules/namespaces.js
+++ b/src/store/modules/namespaces.js
@@ -76,8 +76,13 @@ export default {
},
},
getters: {
- getListAndNamespaceById: state => listId => {
+ getListAndNamespaceById: state => (listId, ignorePseudoNamespaces = false) => {
for (const n in state.namespaces) {
+
+ if(ignorePseudoNamespaces && state.namespaces[n].id < 0) {
+ continue
+ }
+
for (const l in state.namespaces[n].lists) {
if (state.namespaces[n].lists[l].id === listId) {
return {