summaryrefslogtreecommitdiffstats
path: root/models/cards.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/cards.js')
-rw-r--r--models/cards.js21
1 files changed, 8 insertions, 13 deletions
diff --git a/models/cards.js b/models/cards.js
index 757772f3..6d5e23cc 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -412,14 +412,10 @@ Cards.helpers({
const _id = Cards.insert(this);
// Copy attachments
- oldCard.attachments().forEach((file) => {
- Meteor.call('cloneAttachment', file,
- {
- meta: {
- cardId: _id
- }
- }
- );
+ oldCard.attachments().forEach(att => {
+ att.cardId = _id;
+ delete att._id;
+ return Attachments.insert(att);
});
// copy checklists
@@ -522,15 +518,14 @@ Cards.helpers({
attachments() {
if (this.isLinkedCard()) {
return Attachments.find(
- { 'meta.cardId': this.linkedId },
+ { cardId: this.linkedId },
{ sort: { uploadedAt: -1 } },
);
} else {
- let ret = Attachments.find(
- { 'meta.cardId': this._id },
+ return Attachments.find(
+ { cardId: this._id },
{ sort: { uploadedAt: -1 } },
);
- return ret;
}
},
@@ -539,7 +534,7 @@ Cards.helpers({
const cover = Attachments.findOne(this.coverId);
// if we return a cover before it is fully stored, we will get errors when we try to display it
// todo XXX we could return a default "upload pending" image in the meantime?
- return cover && cover.link();
+ return cover && cover.url() && cover;
},
checklists() {