Resolve Nextcloud save issue and added mockup code for files browser

https://github.com/the-djmaze/snappymail/issues/96#issuecomment-1282589485
This commit is contained in:
the-djmaze 2022-10-18 19:21:27 +02:00
parent 640f75da8d
commit a41afb17ad
4 changed files with 61 additions and 3 deletions

View file

@ -4,8 +4,8 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Nextcloud',
VERSION = '2.3',
RELEASE = '2022-10-18',
VERSION = '2.4',
RELEASE = '2022-10-19',
CATEGORY = 'Integrations',
DESCRIPTION = 'Integrate with Nextcloud v20+',
REQUIRED = '2.19.0';
@ -21,6 +21,8 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
$this->addJs('js/message.js');
$this->addHook('json.attachments', 'DoAttachmentsActions');
$this->addJsonHook('NextcloudSaveMsg', 'NextcloudSaveMsg');
$this->addTemplate('templates/PopupsNextcloudFiles.html');
}
}

View file

@ -46,7 +46,7 @@
* TODO: op select screen to show browseFiles result
* Then the user can select which Nextcloud folder to save to
*/
browseFiles();
// browseFiles();
rl.pluginRemoteRequest(
(iError, data) => {

View file

@ -87,9 +87,53 @@
});
}
class NextcloudFilesPopupView extends rl.pluginPopupView {
constructor() {
super('NextcloudFiles');
this.addObservables({
folder: '',
files: false
});
}
onShow(files, fResolve) {
this.files(!!files);
this.fResolve = fResolve;
}
select() {
this.close();
this.fResolve(this.folder());
}
onClose() {
this.close();
this.fResolve();
return false;
}
}
rl.ncFiles = new class {
async getDirectoryContents(path) {
return await fetchFiles(propertyRequestBody, path);
}
selectFolder() {
return new Promise(resolve => {
NextcloudFilesPopupView.showModal([
false,
folder => resolve(folder),
]);
});
}
selectFiles() {
return new Promise(resolve => {
NextcloudFilesPopupView.showModal([
true,
files => resolve(files),
]);
});
}
}
})(window.rl);

View file

@ -0,0 +1,12 @@
<header>
<a class="close" href="#" data-bind="click: close">×</a>
<h3 data-i18n="NEXTCLOUD/BROWSE"></h3>
</header>
<div class="modal-body form-horizontal">
TODO: built tree of directories and optional files
In case of directories: radiobutton to select one OR click selects
In case of files: checkbox to select (multiple)
</div>
<footer>
<a class="btn" data-bind="command: select" data-i18n="NEXTCLOUD/SELECT"></a>
</footer>