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, 13 insertions, 8 deletions
diff --git a/models/cards.js b/models/cards.js
index aace2647..f4bb464c 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -412,10 +412,14 @@ Cards.helpers({
const _id = Cards.insert(this);
// Copy attachments
- oldCard.attachments().forEach(att => {
- att.cardId = _id;
- delete att._id;
- return Attachments.insert(att);
+ oldCard.attachments().forEach((file) => {
+ Meteor.call('cloneAttachment', file,
+ {
+ meta: {
+ cardId: _id
+ }
+ }
+ );
});
// copy checklists
@@ -518,14 +522,15 @@ Cards.helpers({
attachments() {
if (this.isLinkedCard()) {
return Attachments.find(
- { cardId: this.linkedId },
+ { 'meta.cardId': this.linkedId },
{ sort: { uploadedAt: -1 } },
);
} else {
- return Attachments.find(
- { cardId: this._id },
+ let ret = Attachments.find(
+ { 'meta.cardId': this._id },
{ sort: { uploadedAt: -1 } },
);
+ return ret;
}
},
@@ -533,7 +538,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.url() && cover;
+ return cover && cover.link();
},
checklists() {