mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
Uploaded done, but uploading not
This commit is contained in:
parent
4dcdec0084
commit
6cdd464f54
7 changed files with 27 additions and 31 deletions
|
|
@ -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);
|
||||
|
|
@ -48,7 +48,10 @@ Template.attachmentsGalery.events({
|
|||
Template.attachmentsGalery.helpers({
|
||||
url() {
|
||||
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);
|
||||
Utils.processUploadedAttachment(card, f,
|
||||
(err, attachment) => {
|
||||
if (attachment && attachment._id && attachment.isImage) {
|
||||
card.setCover(attachment._id);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -32,4 +32,7 @@ Template.minicard.helpers({
|
|||
hiddenMinicardLabelText() {
|
||||
return Meteor.user().hasHiddenMinicardLabelText();
|
||||
},
|
||||
coverUrl() {
|
||||
return Attachments.findOne(this.coverId).link();
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue