summaryrefslogtreecommitdiffstats
path: root/models/cards.js
diff options
context:
space:
mode:
authorAndrés Manelli <andresmanelli@gmail.com>2018-05-02 14:20:55 -0300
committerAndrés Manelli <andresmanelli@gmail.com>2018-08-11 00:16:31 +0200
commit6adfcb35138259c5969e63d20a68cd6f9e8c393c (patch)
tree5292cdbfecdaa74a03c304bde4e05c838666f476 /models/cards.js
parentbce22425280248eda01132ccc58c9f5beefb712a (diff)
downloadwekan-6adfcb35138259c5969e63d20a68cd6f9e8c393c.tar.gz
wekan-6adfcb35138259c5969e63d20a68cd6f9e8c393c.tar.bz2
wekan-6adfcb35138259c5969e63d20a68cd6f9e8c393c.zip
Refactor imported -> linked in models
Diffstat (limited to 'models/cards.js')
-rw-r--r--models/cards.js194
1 files changed, 97 insertions, 97 deletions
diff --git a/models/cards.js b/models/cards.js
index c6e80ea8..2c0da093 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -136,7 +136,7 @@ Cards.attachSchema(new SimpleSchema({
type: {
type: String,
},
- importedId: {
+ linkedId: {
type: String,
optional: true,
},
@@ -185,26 +185,26 @@ Cards.helpers({
},
activities() {
- if (this.isImportedCard()) {
- return Activities.find({cardId: this.importedId}, {sort: {createdAt: -1}});
- } else if (this.isImportedBoard()) {
- return Activities.find({boardId: this.importedId}, {sort: {createdAt: -1}});
+ if (this.isLinkedCard()) {
+ return Activities.find({cardId: this.linkedId}, {sort: {createdAt: -1}});
+ } else if (this.isLinkedBoard()) {
+ return Activities.find({boardId: this.linkedId}, {sort: {createdAt: -1}});
} else {
return Activities.find({cardId: this._id}, {sort: {createdAt: -1}});
}
},
comments() {
- if (this.isImportedCard()) {
- return CardComments.find({cardId: this.importedId}, {sort: {createdAt: -1}});
+ if (this.isLinkedCard()) {
+ return CardComments.find({cardId: this.linkedId}, {sort: {createdAt: -1}});
} else {
return CardComments.find({cardId: this._id}, {sort: {createdAt: -1}});
}
},
attachments() {
- if (this.isImportedCard()) {
- return Attachments.find({cardId: this.importedId}, {sort: {uploadedAt: -1}});
+ if (this.isLinkedCard()) {
+ return Attachments.find({cardId: this.linkedId}, {sort: {uploadedAt: -1}});
} else {
return Attachments.find({cardId: this._id}, {sort: {uploadedAt: -1}});
}
@@ -218,8 +218,8 @@ Cards.helpers({
},
checklists() {
- if (this.isImportedCard()) {
- return Checklists.find({cardId: this.importedId}, {sort: { sort: 1 } });
+ if (this.isLinkedCard()) {
+ return Checklists.find({cardId: this.linkedId}, {sort: { sort: 1 } });
} else {
return Checklists.find({cardId: this._id}, {sort: { sort: 1 } });
}
@@ -412,23 +412,23 @@ Cards.helpers({
return this.parentId === '';
},
- isImportedCard() {
- return this.type === 'cardType-importedCard';
+ isLinkedCard() {
+ return this.type === 'cardType-linkedCard';
},
- isImportedBoard() {
- return this.type === 'cardType-importedBoard';
+ isLinkedBoard() {
+ return this.type === 'cardType-linkedBoard';
},
- isImported() {
- return this.isImportedCard() || this.isImportedBoard();
+ isLinked() {
+ return this.isLinkedCard() || this.isLinkedBoard();
},
setDescription(description) {
- if (this.isImportedCard()) {
- return Cards.update({_id: this.importedId}, {$set: {description}});
- } else if (this.isImportedBoard()) {
- return Boards.update({_id: this.importedId}, {$set: {description}});
+ if (this.isLinkedCard()) {
+ return Cards.update({_id: this.linkedId}, {$set: {description}});
+ } else if (this.isLinkedBoard()) {
+ return Boards.update({_id: this.linkedId}, {$set: {description}});
} else {
return Cards.update(
{_id: this._id},
@@ -438,14 +438,14 @@ Cards.helpers({
},
getDescription() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({_id: this.importedId});
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({_id: this.linkedId});
if (card && card.description)
return card.description;
else
return null;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({_id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({_id: this.linkedId});
if (board && board.description)
return board.description;
else
@@ -458,11 +458,11 @@ Cards.helpers({
},
getMembers() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({_id: this.importedId});
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({_id: this.linkedId});
return card.members;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({_id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({_id: this.linkedId});
return board.activeMembers().map((member) => {
return member.userId;
});
@@ -472,13 +472,13 @@ Cards.helpers({
},
assignMember(memberId) {
- if (this.isImportedCard()) {
+ if (this.isLinkedCard()) {
return Cards.update(
- { _id: this.importedId },
+ { _id: this.linkedId },
{ $addToSet: { members: memberId }}
);
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({_id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({_id: this.linkedId});
return board.addMember(memberId);
} else {
return Cards.update(
@@ -489,13 +489,13 @@ Cards.helpers({
},
unassignMember(memberId) {
- if (this.isImportedCard()) {
+ if (this.isLinkedCard()) {
return Cards.update(
- { _id: this.importedId },
+ { _id: this.linkedId },
{ $pull: { members: memberId }}
);
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({_id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({_id: this.linkedId});
return board.removeMember(memberId);
} else {
return Cards.update(
@@ -514,8 +514,8 @@ Cards.helpers({
},
getReceived() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({_id: this.importedId});
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({_id: this.linkedId});
return card.receivedAt;
} else {
return this.receivedAt;
@@ -523,9 +523,9 @@ Cards.helpers({
},
setReceived(receivedAt) {
- if (this.isImportedCard()) {
+ if (this.isLinkedCard()) {
return Cards.update(
- {_id: this.importedId},
+ {_id: this.linkedId},
{$set: {receivedAt}}
);
} else {
@@ -537,11 +537,11 @@ Cards.helpers({
},
getStart() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({_id: this.importedId});
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({_id: this.linkedId});
return card.startAt;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({_id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({_id: this.linkedId});
return board.startAt;
} else {
return this.startAt;
@@ -549,14 +549,14 @@ Cards.helpers({
},
setStart(startAt) {
- if (this.isImportedCard()) {
+ if (this.isLinkedCard()) {
return Cards.update(
- { _id: this.importedId },
+ { _id: this.linkedId },
{$set: {startAt}}
);
- } else if (this.isImportedBoard()) {
+ } else if (this.isLinkedBoard()) {
return Boards.update(
- {_id: this.importedId},
+ {_id: this.linkedId},
{$set: {startAt}}
);
} else {
@@ -568,11 +568,11 @@ Cards.helpers({
},
getDue() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({_id: this.importedId});
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({_id: this.linkedId});
return card.dueAt;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({_id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({_id: this.linkedId});
return board.dueAt;
} else {
return this.dueAt;
@@ -580,14 +580,14 @@ Cards.helpers({
},
setDue(dueAt) {
- if (this.isImportedCard()) {
+ if (this.isLinkedCard()) {
return Cards.update(
- { _id: this.importedId },
+ { _id: this.linkedId },
{$set: {dueAt}}
);
- } else if (this.isImportedBoard()) {
+ } else if (this.isLinkedBoard()) {
return Boards.update(
- {_id: this.importedId},
+ {_id: this.linkedId},
{$set: {dueAt}}
);
} else {
@@ -599,11 +599,11 @@ Cards.helpers({
},
getEnd() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({_id: this.importedId});
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({_id: this.linkedId});
return card.endAt;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({_id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({_id: this.linkedId});
return board.endAt;
} else {
return this.endAt;
@@ -611,14 +611,14 @@ Cards.helpers({
},
setEnd(endAt) {
- if (this.isImportedCard()) {
+ if (this.isLinkedCard()) {
return Cards.update(
- { _id: this.importedId },
+ { _id: this.linkedId },
{$set: {endAt}}
);
- } else if (this.isImportedBoard()) {
+ } else if (this.isLinkedBoard()) {
return Boards.update(
- {_id: this.importedId},
+ {_id: this.linkedId},
{$set: {endAt}}
);
} else {
@@ -630,11 +630,11 @@ Cards.helpers({
},
getIsOvertime() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({ _id: this.importedId });
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({ _id: this.linkedId });
return card.isOvertime;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({ _id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({ _id: this.linkedId});
return board.isOvertime;
} else {
return this.isOvertime;
@@ -642,14 +642,14 @@ Cards.helpers({
},
setIsOvertime(isOvertime) {
- if (this.isImportedCard()) {
+ if (this.isLinkedCard()) {
return Cards.update(
- { _id: this.importedId },
+ { _id: this.linkedId },
{$set: {isOvertime}}
);
- } else if (this.isImportedBoard()) {
+ } else if (this.isLinkedBoard()) {
return Boards.update(
- {_id: this.importedId},
+ {_id: this.linkedId},
{$set: {isOvertime}}
);
} else {
@@ -661,11 +661,11 @@ Cards.helpers({
},
getSpentTime() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({ _id: this.importedId });
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({ _id: this.linkedId });
return card.spentTime;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({ _id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({ _id: this.linkedId});
return board.spentTime;
} else {
return this.spentTime;
@@ -673,14 +673,14 @@ Cards.helpers({
},
setSpentTime(spentTime) {
- if (this.isImportedCard()) {
+ if (this.isLinkedCard()) {
return Cards.update(
- { _id: this.importedId },
+ { _id: this.linkedId },
{$set: {spentTime}}
);
- } else if (this.isImportedBoard()) {
+ } else if (this.isLinkedBoard()) {
return Boards.update(
- {_id: this.importedId},
+ {_id: this.linkedId},
{$set: {spentTime}}
);
} else {
@@ -692,11 +692,11 @@ Cards.helpers({
},
getTitle() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({ _id: this.importedId });
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({ _id: this.linkedId });
return card.title;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({ _id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({ _id: this.linkedId});
return board.title;
} else {
return this.title;
@@ -704,12 +704,12 @@ Cards.helpers({
},
getBoardTitle() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({ _id: this.importedId });
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({ _id: this.linkedId });
const board = Boards.findOne({ _id: card.boardId });
return board.title;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({ _id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({ _id: this.linkedId});
return board.title;
} else {
const board = Boards.findOne({ _id: this.boardId });
@@ -718,14 +718,14 @@ Cards.helpers({
},
setTitle(title) {
- if (this.isImportedCard()) {
+ if (this.isLinkedCard()) {
return Cards.update(
- { _id: this.importedId },
+ { _id: this.linkedId },
{$set: {title}}
);
- } else if (this.isImportedBoard()) {
+ } else if (this.isLinkedBoard()) {
return Boards.update(
- {_id: this.importedId},
+ {_id: this.linkedId},
{$set: {title}}
);
} else {
@@ -737,11 +737,11 @@ Cards.helpers({
},
getArchived() {
- if (this.isImportedCard()) {
- const card = Cards.findOne({ _id: this.importedId });
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({ _id: this.linkedId });
return card.archived;
- } else if (this.isImportedBoard()) {
- const board = Boards.findOne({ _id: this.importedId});
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({ _id: this.linkedId});
return board.archived;
} else {
return this.archived;