mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 06:27:02 +03:00
Attach Nextcloud files to mail #569
This commit is contained in:
parent
2ede940aa7
commit
30c2371b9a
5 changed files with 119 additions and 23 deletions
51
plugins/nextcloud/js/composer.js
Normal file
51
plugins/nextcloud/js/composer.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
(rl => {
|
||||
// if (rl.settings.get('Nextcloud'))
|
||||
|
||||
addEventListener('rl-view-model.create', e => {
|
||||
if ('PopupsCompose' === e.detail.viewModelTemplateID) {
|
||||
let view = e.detail;
|
||||
view.nextcloudAttach = () => {
|
||||
rl.ncFiles.selectFiles().then(files => {
|
||||
files.forEach(file => {
|
||||
let id = Jua?.randomId() || file.etag,
|
||||
attachment = view.addAttachmentHelper(
|
||||
id.etag,
|
||||
file.name.replace(/^.*\/([^/]+)$/, '$1'),
|
||||
file.size
|
||||
);
|
||||
attachment
|
||||
.waiting(false)
|
||||
.uploading(true)
|
||||
.complete(false);
|
||||
|
||||
rl.pluginRemoteRequest(
|
||||
(iError, data) => {
|
||||
attachment
|
||||
.uploading(false)
|
||||
.complete(true);
|
||||
if (iError) {
|
||||
attachment.error(data?.Result?.error || 'failed');
|
||||
} else {
|
||||
attachment.tempName(data.Result.tempName);
|
||||
}
|
||||
},
|
||||
'NextcloudAttachFile',
|
||||
{
|
||||
'file': file.name
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
let template = document.getElementById('PopupsCompose');
|
||||
const uploadBtn = template.content.querySelector('#composeUploadButton');
|
||||
if (uploadBtn) {
|
||||
uploadBtn.after(Element.fromHTML('<a class="btn fontastic"'
|
||||
+ ' data-bind="click: nextcloudAttach" data-i18n="[title]NEXTCLOUD/ATTACH_FILES">◦◯◦</a>'));
|
||||
}
|
||||
|
||||
})(window.rl);
|
||||
Loading…
Add table
Add a link
Reference in a new issue