mirror of
https://github.com/wekan/wekan.git
synced 2026-02-04 15:41:52 +01:00
Ref: original & and use fileObj.meta
fileObj.meta is part of the ostrio:files API and be passed to the constructor. This is less hacky than trying tu update a persistet object after the fact.
This commit is contained in:
parent
16506e7a6a
commit
e702f17c7b
10 changed files with 124 additions and 159 deletions
|
|
@ -67,19 +67,19 @@ Template.cardAttachmentsPopup.events({
|
|||
const uploader = Attachments.insert(
|
||||
{
|
||||
file: event.currentTarget.files[0],
|
||||
meta: Utils.getCommonAttachmentMetaFrom(card),
|
||||
chunkSize: 'dynamic',
|
||||
},
|
||||
false,
|
||||
);
|
||||
uploader.on('uploaded', (error, fileObj) => {
|
||||
uploader.on('uploaded', (error, fileRef) => {
|
||||
if (!error) {
|
||||
if (fileObj.isImage) {
|
||||
card.setCover(fileObj._id);
|
||||
if (fileRef.isImage) {
|
||||
card.setCover(fileRef._id);
|
||||
}
|
||||
Utils.addCommonMetaToAttachment(card, fileObj);
|
||||
}
|
||||
});
|
||||
uploader.on('end', (error, fileObj) => {
|
||||
uploader.on('end', (error, fileRef) => {
|
||||
Popup.back();
|
||||
});
|
||||
uploader.start();
|
||||
|
|
@ -131,28 +131,27 @@ Template.previewClipboardImagePopup.onRendered(() => {
|
|||
|
||||
Template.previewClipboardImagePopup.events({
|
||||
'click .js-upload-pasted-image'() {
|
||||
const results = pastedResults;
|
||||
if (results && results.file) {
|
||||
const card = this;
|
||||
if (pastedResults && pastedResults.file) {
|
||||
const file = pastedResults.file;
|
||||
window.oPasted = pastedResults;
|
||||
const card = this;
|
||||
const uploader = Attachments.insert(
|
||||
{
|
||||
file: results.file,
|
||||
fileName:
|
||||
results.name || results.file.type.replace('image/', 'clipboard.'),
|
||||
file,
|
||||
meta: Utils.getCommonAttachmentMetaFrom(card),
|
||||
fileName: file.name || file.type.replace('image/', 'clipboard.'),
|
||||
chunkSize: 'dynamic',
|
||||
},
|
||||
false,
|
||||
);
|
||||
uploader.on('uploaded', (error, fileObj) => {
|
||||
uploader.on('uploaded', (error, fileRef) => {
|
||||
if (!error) {
|
||||
if (fileObj.isImage) {
|
||||
card.setCover(fileObj._id);
|
||||
if (fileRef.isImage) {
|
||||
card.setCover(fileRef._id);
|
||||
}
|
||||
Utils.addCommonMetaToAttachment(card, fileObj);
|
||||
}
|
||||
});
|
||||
uploader.on('end', (error, fileObj) => {
|
||||
uploader.on('end', (error, fileRef) => {
|
||||
pastedResults = null;
|
||||
$(document.body).pasteImageReader(() => {});
|
||||
Popup.back();
|
||||
|
|
|
|||
|
|
@ -160,28 +160,23 @@ BlazeComponent.extendComponent({
|
|||
const currentCard = Utils.getCurrentCard();
|
||||
const MAX_IMAGE_PIXEL = Utils.MAX_IMAGE_PIXEL;
|
||||
const COMPRESS_RATIO = Utils.IMAGE_COMPRESS_RATIO;
|
||||
const insertImage = src => {
|
||||
const img = document.createElement('img');
|
||||
img.src = src;
|
||||
img.setAttribute('width', '100%');
|
||||
$summernote.summernote('insertNode', img);
|
||||
};
|
||||
const processUpload = function(file) {
|
||||
const uploader = Attachments.insert(
|
||||
{
|
||||
file,
|
||||
meta: Utils.getCommonAttachmentMetaFrom(card),
|
||||
chunkSize: 'dynamic',
|
||||
},
|
||||
false,
|
||||
);
|
||||
uploader.on('uploaded', (error, fileObj) => {
|
||||
uploader.on('uploaded', (error, fileRef) => {
|
||||
if (!error) {
|
||||
if (fileObj.isImage) {
|
||||
insertImage(
|
||||
`${location.protocol}//${location.host}${fileObj.path}`,
|
||||
);
|
||||
if (fileRef.isImage) {
|
||||
const img = document.createElement('img');
|
||||
img.src = fileRef.link();
|
||||
img.setAttribute('width', '100%');
|
||||
$summernote.summernote('insertNode', img);
|
||||
}
|
||||
Utils.addCommonMetaToAttachment(currentCard, fileObj);
|
||||
}
|
||||
});
|
||||
uploader.start();
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ template(name="changeAvatarPopup")
|
|||
unless isSelected
|
||||
a.js-delete-avatar {{_ 'delete'}}
|
||||
| -
|
||||
= original.name
|
||||
= name
|
||||
li: a.js-select-initials
|
||||
.member
|
||||
+userAvatarInitials(userId=currentUser._id)
|
||||
|
|
|
|||
|
|
@ -229,13 +229,13 @@ BlazeComponent.extendComponent({
|
|||
},
|
||||
false,
|
||||
);
|
||||
uploader.on('uploaded', (error, fileObj) => {
|
||||
uploader.on('uploaded', (error, fileRef) => {
|
||||
if (!error) {
|
||||
self.setAvatar(fileObj.path);
|
||||
self.setAvatar(fileRef.path);
|
||||
// self.setAvatar(this.currentData().url(this.avatarUrlOptions()));
|
||||
}
|
||||
});
|
||||
uploader.on('error', (error, fileObj) => {
|
||||
uploader.on('error', (error, fileData) => {
|
||||
// XXX check for actually returned error
|
||||
self.setError('avatar-too-big');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue