diff --git a/packages/file-handling/src/clipboard.js b/packages/file-handling/src/clipboard.js index ee6e67ec7bbfd9ae4d3303362757a332fabad6dc..8088f961b0e98620d175499d6ffa0867ecfe1525 100644 --- a/packages/file-handling/src/clipboard.js +++ b/packages/file-handling/src/clipboard.js @@ -30,6 +30,8 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { this.filesToSave = []; this.numberOfSelectedFiles = 0; this.enabledTargets = 'local'; + this.countUploadFiles = 0; + this.buttonsDisabled = false; this.nextcloudWebAppPasswordURL = ""; this.nextcloudWebDavURL = ""; @@ -57,11 +59,12 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { ...super.properties, lang: { type: String }, allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' }, - clipboardSelectBtnDisabled: { type: Boolean, attribute: true }, + clipboardSelectBtnDisabled: { type: Boolean }, clipboardFiles: {type: Object, attribute: 'clipboard-files' }, filesToSave: {type: Array, attribute: 'files-to-save' }, numberOfSelectedFiles: {type: Number, attribute: false }, enabledTargets: {type: String, attribute: 'enabled-targets'}, + buttonsDisabled: {type: Boolean }, nextcloudWebAppPasswordURL: { type: String, attribute: 'nextcloud-auth-url' }, nextcloudWebDavURL: { type: String, attribute: 'nextcloud-web-dav-url' }, @@ -352,20 +355,6 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { } } - async addClickEventToggleCollapse() { - console.log("add event"); - if (this.tabulatorTable !== null) { - - if (this._('.tabulator-responsive-collapse-toggle-open')) { - this._a('.tabulator-responsive-collapse-toggle-open').forEach(element => element.addEventListener("click", this.toggleCollapse.bind(this))); - } - - if (this._('.tabulator-responsive-collapse-toggle-close')) { - this._a('.tabulator-responsive-collapse-toggle-close').forEach(element => element.addEventListener("click", this.toggleCollapse.bind(this))); - } - } - } - /** * Sends the files to a provider and throws a notification * @@ -454,6 +443,14 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { { bubbles: true, composed: true }); this.dispatchEvent(event); } + + this.countUploadFiles += 1; + if (this.countUploadFiles === event.detail.maxUpload) { + this.buttonsDisabled = false; + this.countUploadFiles = 0; + } else { + this.buttonsDisabled = true; + } } /** @@ -570,11 +567,13 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { getAdditionalButtons() { const i18n = this._i18n; let buttonsAreDisabled = this.clipboardFiles.files.length === 0 ? true : this.clipboardSelectBtnDisabled; + buttonsAreDisabled = this.buttonsDisabled ? true : buttonsAreDisabled; return html` <div class="flex-container additional-button-container"> <div class="btn-flex-container-mobile"> <button @click="${() => { this.openFileSource(); }}" - class="button ${classMap({hidden: this.mode === MODE_FILE_SINK || this.mode === MODE_FILE_SOURCE})}" title="${i18n.t('clipboard.add-files')}"> + class="button ${classMap({hidden: this.mode === MODE_FILE_SINK || this.mode === MODE_FILE_SOURCE})}" title="${i18n.t('clipboard.add-files')}" + ?disabled="${this.buttonsDisabled}"> <dbp-icon class="nav-icon" name="clipboard"></dbp-icon> ${i18n.t('clipboard.add-files-btn')} </button> <button @click="${() => { this.clearClipboard(); }}" diff --git a/packages/file-handling/src/dbp-file-handling-lit-element.js b/packages/file-handling/src/dbp-file-handling-lit-element.js index c4224d0c23adda01544f430dfb025926e7d13bb1..5da4f58da8cdfc2f7a17bd71b814a374df11d156 100644 --- a/packages/file-handling/src/dbp-file-handling-lit-element.js +++ b/packages/file-handling/src/dbp-file-handling-lit-element.js @@ -14,7 +14,7 @@ export default class DbpFileHandlingLitElement extends ScopedElementsMixin(DBPLi } /** - * handles the scroll of the current element and displays the right and/or the left paddle + * Handles the scroll of the current element and displays the right and/or the left paddle * to match the scrolling position * * @param e diff --git a/packages/file-handling/src/file-source.js b/packages/file-handling/src/file-source.js index 267147ef5c032dcb685c4affc7b7d8026947165e..b352500c4b486c1c3669b1782d68489f3a6e38ac 100644 --- a/packages/file-handling/src/file-source.js +++ b/packages/file-handling/src/file-source.js @@ -155,8 +155,6 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { super.disconnectedCallback(); } - - preventDefaults (e) { e.preventDefault(); e.stopPropagation(); @@ -205,42 +203,44 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { // console.log('handleFiles: files.length = ' + files.length); // this.dispatchEvent(new CustomEvent("dbp-file-source-selection-start", // { "detail": {}, bubbles: true, composed: true })); - - await commonUtils.asyncArrayForEach(files, async (file) => { + let fileCount = files.length; + await commonUtils.asyncArrayForEach(files, async (file, index) => { if (file.size === 0) { console.log('file \'' + file.name + '\' has size=0 and is denied!'); return; } - // check if we want to decompress the zip and queue the contained files if (this.decompressZip && (file.type === "application/zip" || file.type === "application/x-zip-compressed")) { // add decompressed files to tempFilesToHandle await commonUtils.asyncArrayForEach( - await this.decompressZIP(file), (file) => this.sendFileEvent(file)); + await this.decompressZIP(file), (file, index, array) => { + fileCount = index === array.length - 1 ? fileCount : fileCount + 1; + this.sendFileEvent(file,fileCount); + }); return; } else if (this.allowedMimeTypes && !this.checkFileType(file)) { return; } - await this.sendFileEvent(file); + await this.sendFileEvent(file, fileCount); }); // this.dispatchEvent(new CustomEvent("dbp-file-source-selection-finished", // { "detail": {}, bubbles: true, composed: true })); - const event = new CustomEvent("dbp-file-source-file-upload-finished", { "detail": {count: files.length}, bubbles: true, composed: true }); + const event = new CustomEvent("dbp-file-source-file-upload-finished", { "detail": {count: fileCount}, bubbles: true, composed: true }); this.dispatchEvent(event); this.closeDialog(); } /** - * @param file + * @param file, last */ - sendFileEvent(file) { + sendFileEvent(file, maxUpload) { this.sendSource(); MicroModal.close(this._('#modal-picker')); - const data = {"file": file}; + const data = {"file": file, "maxUpload": maxUpload}; const event = new CustomEvent("dbp-file-source-file-selected", { "detail": data, bubbles: true, composed: true }); this.dispatchEvent(event); } @@ -249,7 +249,6 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { let data = {}; if (this.activeTarget == 'nextcloud') { data = {"target": this.activeTarget, "path": this._("#nextcloud-file-picker").directoryPath}; - } else { data = {"target": this.activeTarget}; } @@ -485,7 +484,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { auth-info="${this.nextcloudAuthInfo}" allowed-mime-types="${this.allowedMimeTypes}" @dbp-nextcloud-file-picker-file-downloaded="${(event) => { - this.sendFileEvent(event.detail.file);}}"> + this.sendFileEvent(event.detail.file, event.detail.maxUpload);}}"> </dbp-nextcloud-file-picker>`; } return html``; @@ -576,11 +575,17 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { #dropArea{ height: 100%; } - + + + } + + @media only screen + and (orientation: portrait) + and (max-width: 340px) { + .paddles{ display: inherit; } - } `; } @@ -593,7 +598,6 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { allowedMimeTypes += ",application/zip,application/x-zip-compressed"; } - return html` <!-- <button class="button" diff --git a/packages/file-handling/src/nextcloud-file-picker.js b/packages/file-handling/src/nextcloud-file-picker.js index 1ac5ea7b13064172c6b1cf768ba06e5a1a36605b..b37ab28e88c8aac90339688aec4c1c8ed386e25e 100644 --- a/packages/file-handling/src/nextcloud-file-picker.js +++ b/packages/file-handling/src/nextcloud-file-picker.js @@ -549,7 +549,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { * @param files */ downloadFiles(files) { - files.forEach((fileData) => this.downloadFile(fileData)); + files.forEach((fileData) => this.downloadFile(fileData, files.length)); + this.tabulatorTable.deselectRow(); if (this._("#select_all")) { this._("#select_all").checked = false; @@ -569,9 +570,10 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { /** * Download a single file * - * @param fileData + * @param fileData, maxUpload */ - downloadFile(fileData) { + downloadFile(fileData, maxUpload) { + const i18n = this._i18n; this.loading = true; this.statusText = "Loading " + fileData.filename + "..."; @@ -583,7 +585,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { // create file to send via event const file = new File([contents], fileData.basename, {type: fileData.mime}); // send event - const data = {"file": file, "data": fileData}; + const data = {"file": file, "data": fileData, "maxUpload": maxUpload}; const event = new CustomEvent("dbp-nextcloud-file-picker-file-downloaded", {"detail": data, bubbles: true, composed: true}); this.dispatchEvent(event);