summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorNicu Tofan <nicu.tofan@gmail.com>2018-06-26 02:13:31 +0300
committerNicu Tofan <nicu.tofan@gmail.com>2018-06-26 14:32:51 +0300
commitc0ffd6c20f2a04bd1436ea2f0953f1c3c8afe145 (patch)
tree991e195f99639c69479381c4a72c17b6da1ba115 /models
parent94a52080cff14f7587c0ee837c1fca131cd6aff0 (diff)
downloadwekan-c0ffd6c20f2a04bd1436ea2f0953f1c3c8afe145.tar.gz
wekan-c0ffd6c20f2a04bd1436ea2f0953f1c3c8afe145.tar.bz2
wekan-c0ffd6c20f2a04bd1436ea2f0953f1c3c8afe145.zip
Show parent in card (no links, yet)
Diffstat (limited to 'models')
-rw-r--r--models/boards.js16
-rw-r--r--models/cards.js53
2 files changed, 69 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js
index b5b0b0fc..2d80a56a 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -165,6 +165,18 @@ Boards.attachSchema(new SimpleSchema({
type: Boolean,
defaultValue: true,
},
+ presentParentTask: {
+ type: String,
+ allowedValues: [
+ 'prefix-with-full-path',
+ 'prefix-with-parent',
+ 'subtext-with-full-path',
+ 'subtext-with-parent',
+ 'no-parent',
+ ],
+ optional: true,
+ defaultValue: 'no-parent',
+ },
}));
@@ -489,6 +501,10 @@ Boards.mutations({
setSubtasksDefaultListId(subtasksDefaultListId) {
return { $set: { subtasksDefaultListId } };
},
+
+ setPresentParentTask(presentParentTask) {
+ return { $set: { presentParentTask } };
+ },
});
if (Meteor.isServer) {
diff --git a/models/cards.js b/models/cards.js
index 8d7a93d0..323ec407 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -326,6 +326,59 @@ Cards.helpers({
return Cards.findOne(this.parentId);
},
+ parentCardName() {
+ if (this.parentId === '') {
+ return '';
+ }
+ return Cards.findOne(this.parentId).title;
+ },
+
+ parentListId() {
+ const result = [];
+ let crtParentId = this.parentId;
+ while (crtParentId !== '') {
+ const crt = Cards.findOne(crtParentId);
+ if ((crt === null) || (crt === undefined)) {
+ // maybe it has been deleted
+ break;
+ }
+ if (crtParentId in result) {
+ // circular reference
+ break;
+ }
+ result.unshift(crtParentId);
+ crtParentId = crt.parentId;
+ }
+ return result;
+ },
+
+ parentList() {
+ const resultId = [];
+ const result = [];
+ let crtParentId = this.parentId;
+ while (crtParentId !== '') {
+ const crt = Cards.findOne(crtParentId);
+ if ((crt === null) || (crt === undefined)) {
+ // maybe it has been deleted
+ break;
+ }
+ if (crtParentId in resultId) {
+ // circular reference
+ break;
+ }
+ resultId.unshift(crtParentId);
+ result.unshift(crt);
+ crtParentId = crt.parentId;
+ }
+ return result;
+ },
+
+ parentString(sep) {
+ return this.parentList().map(function(elem){
+ return elem.title;
+ }).join(sep);
+ },
+
isTopLevel() {
return this.parentId === '';
},