summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/components/cards/attachments.jade2
-rw-r--r--client/components/cards/attachments.js26
-rw-r--r--client/components/cards/minicard.jade2
-rw-r--r--client/components/cards/minicard.js3
-rw-r--r--client/lib/utils.js16
-rw-r--r--models/attachments.js6
-rw-r--r--models/cards.js3
7 files changed, 27 insertions, 31 deletions
diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade
index 2a96f4f4..3ce639bc 100644
--- a/client/components/cards/attachments.jade
+++ b/client/components/cards/attachments.jade
@@ -23,7 +23,7 @@ template(name="attachmentsGalery")
each attachments
.attachment-item
a.attachment-thumbnail.swipebox(href="{{url}}" title="{{name}}")
- if isUploaded
+ if isUploaded
if isImage
img.attachment-thumbnail-img(src="{{url}}")
else
diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js
index f24a7f82..7346e943 100644
--- a/client/components/cards/attachments.js
+++ b/client/components/cards/attachments.js
@@ -13,10 +13,10 @@ Template.attachmentsGalery.events({
event.stopPropagation();
},
'click .js-add-cover'() {
- Cards.findOne(this.cardId).setCover(this._id);
+ Cards.findOne(this.meta.cardId).setCover(this._id);
},
'click .js-remove-cover'() {
- Cards.findOne(this.cardId).unsetCover();
+ Cards.findOne(this.meta.cardId).unsetCover();
},
'click .js-preview-image'(event) {
Popup.open('previewAttachedImage').call(this, event);
@@ -47,8 +47,11 @@ Template.attachmentsGalery.events({
Template.attachmentsGalery.helpers({
url() {
- return Attachments.link(this);
- }
+ return Attachments.link(this);
+ },
+ isUploaded() {
+ return !!this.meta.uploaded;
+ },
});
Template.previewAttachedImagePopup.events({
@@ -67,13 +70,14 @@ Template.cardAttachmentsPopup.events({
'change .js-attach-file'(event) {
const card = this;
const processFile = f => {
- Utils.processUploadedAttachment(card, f, attachment => {
- console.log('attachment', attachment);
- if (attachment && attachment._id && attachment.isImage) {
- card.setCover(attachment._id);
+ Utils.processUploadedAttachment(card, f,
+ (err, attachment) => {
+ if (attachment && attachment._id && attachment.isImage) {
+ card.setCover(attachment._id);
+ }
+ Popup.close();
}
- Popup.close();
- });
+ );
};
FS.Utility.eachFile(event, f => {
@@ -169,7 +173,6 @@ Template.previewClipboardImagePopup.events({
};
if (!results.name) {
// if no filename, it's from clipboard. then we give it a name, with ext name from MIME type
- // FIXME: Check this behavior
if (typeof results.file.type === 'string') {
settings.fileName =
new Date().getTime() + results.file.type.replace('.+/', '');
@@ -182,7 +185,6 @@ Template.previewClipboardImagePopup.events({
settings.meta.userId = Meteor.userId();
const attachment = Attachments.insert(settings);
- // TODO: Check image cover behavior
if (attachment && attachment._id && attachment.isImage) {
card.setCover(attachment._id);
}
diff --git a/client/components/cards/minicard.jade b/client/components/cards/minicard.jade
index 79672f8c..0a35bd3a 100644
--- a/client/components/cards/minicard.jade
+++ b/client/components/cards/minicard.jade
@@ -11,7 +11,7 @@ template(name="minicard")
.handle
.fa.fa-arrows
if cover
- .minicard-cover(style="background-image: url('{{cover.url}}');")
+ .minicard-cover(style="background-image: url('{{coverUrl}}');")
if labels
.minicard-labels
each labels
diff --git a/client/components/cards/minicard.js b/client/components/cards/minicard.js
index 4c76db46..3ddb7e97 100644
--- a/client/components/cards/minicard.js
+++ b/client/components/cards/minicard.js
@@ -32,4 +32,7 @@ Template.minicard.helpers({
hiddenMinicardLabelText() {
return Meteor.user().hasHiddenMinicardLabelText();
},
+ coverUrl() {
+ return Attachments.findOne(this.coverId).link();
+ },
});
diff --git a/client/lib/utils.js b/client/lib/utils.js
index d667382d..8503b035 100644
--- a/client/lib/utils.js
+++ b/client/lib/utils.js
@@ -32,20 +32,12 @@ Utils = {
}
};
if (!card) {
- return next();
+ return onUploaded();
}
let settings = {
file: fileObj,
streams: 'dynamic',
chunkSize: 'dynamic',
- onUploaded: function(error, fileObj) {
- console.log('after insert', Attachments.find({}).fetch());
- if (error) {
- console.log('Error while upload', error);
- } else {
- next(fileObj);
- }
- },
};
settings.meta = {};
if (card.isLinkedCard()) {
@@ -58,11 +50,7 @@ Utils = {
settings.meta.cardId = card._id;
}
settings.meta.userId = Meteor.userId();
- // FIXME: What is this?
- /* if (file.original) {
- file.original.name = fileObj.name;
- }*/
- Attachments.insert(settings);
+ Attachments.insert(settings).on('end', next);
},
shrinkImage(options) {
// shrink image to certain size
diff --git a/models/attachments.js b/models/attachments.js
index 4537e47c..5dcc75e6 100644
--- a/models/attachments.js
+++ b/models/attachments.js
@@ -2,9 +2,12 @@ import { FilesCollection } from 'meteor/ostrio:files';
Attachments = new FilesCollection({
storagePath: storagePath(),
- debug: true, // FIXME: Remove debug mode
+ debug: false, // FIXME: Remove debug mode
collectionName: 'attachments2',
allowClientCode: true, // FIXME: Permissions
+ onAfterUpload: (fileRef) => {
+ Attachments.update({_id:fileRef._id}, {$set: {"meta.uploaded": true}});
+ }
});
if (Meteor.isServer) {
@@ -15,6 +18,7 @@ if (Meteor.isServer) {
// TODO: Permission related
// TODO: Add Activity update
// TODO: publish and subscribe
+
Meteor.publish('attachments', function() {
return Attachments.find().cursor;
});
diff --git a/models/cards.js b/models/cards.js
index 4c3e2c99..86d22c53 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -460,11 +460,10 @@ Cards.helpers({
{ sort: { uploadedAt: -1 } },
);
} else {
- const ret = Attachments.find(
+ let ret = Attachments.find(
{ 'meta.cardId': this._id },
{ sort: { uploadedAt: -1 } },
);
- if (ret.first()) console.log('link', Attachments.link(ret.first()));
return ret;
}
},