diff --git a/packages/file-handling/src/clipboard.js b/packages/file-handling/src/clipboard.js index 5b2665a4e27d5a21142d98212bb03f9d29ee6ad7..cafdafe0e6954564a649ae5df29ddb20beed5ae2 100644 --- a/packages/file-handling/src/clipboard.js +++ b/packages/file-handling/src/clipboard.js @@ -624,7 +624,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { </div> <div class="clipboard-footer"> <button class="button select-button is-primary" ?disabled="${this.clipboardSelectBtnDisabled}" - @click="${() => {this.sendClipboardFiles(this.tabulatorTable.getSelectedData());}}"> ${i18n.t('clipboard.source-btn', {count: this.tabulatorTable ? this.tabulatorTable.getSelectedRows().length : 0})} + @click="${() => {this.sendClipboardFiles(this.tabulatorTable.getSelectedData());}}"> ${this.tabulatorTable && this.tabulatorTable.getSelectedRows().length > 0 ? i18n.t('clipboard.source-btn', {count: this.tabulatorTable ? this.tabulatorTable.getSelectedRows().length : 0}) : i18n.t('clipboard.source-btn-none')} </button> </div> </div> diff --git a/packages/file-handling/src/dbp-nextcloud-file-picker.js b/packages/file-handling/src/dbp-nextcloud-file-picker.js index f45838f86f26dbd511663b3e1a4fae722f6903d3..d352f07f8e7ebbe1b220dfb0f504bb22f9bdf541 100644 --- a/packages/file-handling/src/dbp-nextcloud-file-picker.js +++ b/packages/file-handling/src/dbp-nextcloud-file-picker.js @@ -49,12 +49,10 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { this.activeDirectoryACL = ''; this.forAll = false; this.uploadCount = 0; - this.selectAllButton = true; this.abortUploadButton = false; this.abortUpload = false; this.authInfo = ''; - - this.numberOfSelectedFiles = 0; + this.selectBtnDisabled = true; } static get scopedElements() { @@ -89,10 +87,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { uploadFileDirectory: { type: String, attribute: false }, activeDirectoryRights: { type: String, attribute: false }, activeDirectoryACL: { type: String, attribute: false }, - selectAllButton: { type: Boolean, attribute: false }, abortUploadButton: { type: Boolean, attribute: false }, - - numberOfSelectedFiles: {type: Number, attribute: false }, + selectBtnDisabled: { type: Boolean, attribute: true }, }; } @@ -193,6 +189,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { else { this.folderIsSelected = i18n.t('nextcloud-file-picker.load-in-folder'); } + if (this.tabulatorTable && this.tabulatorTable.getSelectedRows().filter(row => row.getData().type != 'directory' && this.checkFileType(row.getData(), this.allowedMimeTypes)).length > 0) { + this.selectBtnDisabled = false; + } else { + this.selectBtnDisabled = true; + } + this.requestUpdate(); + + }, rowClick: (e, row) => { const data = row.getData(); @@ -211,7 +215,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { this.directoryClicked(e, data); break; case "file": - this.numberOfSelectedFiles = this.tabulatorTable !== null ? this.tabulatorTable.getSelectedRows().length : 0; if (this.tabulatorTable !== null && this.tabulatorTable.getSelectedRows().length === this.tabulatorTable.getRows().filter(row => row.getData().type != 'directory' && this.checkFileType(row.getData(), this.allowedMimeTypes)).length) { this._("#select_all").checked = true; @@ -339,7 +342,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { } // console.log("load nextcloud directory", path); - this.selectAllButton = true; this.loading = true; this.statusText = i18n.t('nextcloud-file-picker.loadpath-nextcloud-file-picker', {name: this.nextcloudName}); this.lastDirectoryPath = this.directoryPath; @@ -442,6 +444,10 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { downloadFiles(files) { files.forEach((fileData) => this.downloadFile(fileData)); this.tabulatorTable.deselectRow(); + if (this._("#select_all")) + { + this._("#select_all").checked = false; + } const data = {"count": files.length}; const event = new CustomEvent("dbp-nextcloud-file-picker-number-files", { "detail": data, bubbles: true, composed: true }); @@ -476,7 +482,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { this.dispatchEvent(event); this.loading = false; this.statusText = ""; - this.numberOfSelectedFiles = 0; }).catch(error => { console.error(error.message); this.loading = false; @@ -491,7 +496,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { */ sendDirectory(directory) { this.tabulatorTable.deselectRow(); - this.numberOfSelectedFiles = 0; let path; if (!directory[0]) { @@ -794,7 +798,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { } closeDialog(e) { - this.numberOfSelectedFiles = 0; + if (this.tabulatorTable) { + this.tabulatorTable.deselectRow(); + } + if (this._("#select_all")) + { + this._("#select_all").checked = false; + } MicroModal.close(this._('#modal-picker')); } @@ -932,10 +942,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { let allSelected = this.checkAllSelected(); if (allSelected) { this.tabulatorTable.getSelectedRows().forEach(row => row.deselect()); - this.numberOfSelectedFiles = 0; } else { this.tabulatorTable.selectRow(this.tabulatorTable.getRows().filter(row => row.getData().type != 'directory' && this.checkFileType(row.getData(), this.allowedMimeTypes))); - this.numberOfSelectedFiles = this.tabulatorTable.getSelectedRows().length; } } @@ -1539,12 +1547,12 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { <div class="nextcloud-footer-grid"> <button id="download-button" class="button select-button is-primary ${classMap({hidden: ((!this.directoriesOnly) || (this.directoriesOnly && this.abortUploadButton && this.forAll))})}" @click="${() => { this.sendDirectory(this.tabulatorTable.getSelectedData()); }}" - ?disabled="${this.numberOfSelectedFiles === 0}"> + ?disabled="${this.selectBtnDisabled}"> <dbp-icon class="nav-icon" name="cloud-upload"></dbp-icon> ${this.folderIsSelected}</button> <button class="button select-button is-primary ${classMap({hidden: this.directoriesOnly})}" @click="${() => { this.downloadFiles(this.tabulatorTable.getSelectedData()); }}" - ?disabled="${!this.numberOfSelectedFiles > 0}"> - ${i18n.t('nextcloud-file-picker.select-files')}</button> + ?disabled="${this.selectBtnDisabled}"> + ${(this.tabulatorTable && this.tabulatorTable.getSelectedRows().filter(row => row.getData().type != 'directory' && this.checkFileType(row.getData(), this.allowedMimeTypes)).length === 0) ? i18n.t('nextcloud-file-picker.select-files') : i18n.t('nextcloud-file-picker.select-files-btn', {count: this.tabulatorTable ? this.tabulatorTable.getSelectedRows().length : 0})}</button> <button id="abortButton" class="button select-button hidden ${classMap({"visible": (this.directoriesOnly && this.forAll && this.abortUploadButton)})}" title="${i18n.t('nextcloud-file-picker.abort')}" @click="${() => { this.abortUpload = true; }}">${i18n.t('nextcloud-file-picker.abort')}</button> diff --git a/packages/file-handling/src/file-source.js b/packages/file-handling/src/file-source.js index e329114a60c15653b5e8ed5cfc576dd9359f10cb..9c7bf2d80cafb2829a36ce1200d3208f90ac046d 100644 --- a/packages/file-handling/src/file-source.js +++ b/packages/file-handling/src/file-source.js @@ -412,6 +412,26 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) { closeDialog() { this.sendSource(); + if (this.enabledTargets.includes('nextcloud')) { + const filePicker = this._('#nextcloud-file-picker'); + if (filePicker && filePicker.tabulatorTable) { + + filePicker.tabulatorTable.deselectRow(); + if (filePicker._('#select_all')) { + filePicker._("#select_all").checked = false; + } + } + } + + if (this.enabledTargets.includes('clipboard')) { + const filePicker = this._('#clipboard-file-picker'); + if (filePicker && filePicker.tabulatorTable) { + filePicker.tabulatorTable.deselectRow(); + if (filePicker._('#select_all')) { + filePicker._("#select_all").checked = false; + } + } + } MicroModal.close(this._('#modal-picker')); } @@ -539,7 +559,7 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) { <p>${i18n.t('file-source.nav-local')}</p> </div> <div title="Nextcloud" - @click="${() => { this.activeTarget = "nextcloud"; this.loadWebdavDirectory();}}" + @click="${() => { this.activeTarget = "nextcloud";}}" class="${classMap({"active": this.activeTarget === "nextcloud", hidden: !this.hasEnabledSource("nextcloud") || this.nextcloudWebDavUrl === "" || this.nextcloudAuthUrl === ""})}"> <dbp-icon class="nav-icon" name="cloud"></dbp-icon> <p> ${this.nextcloudName} </p> diff --git a/packages/file-handling/src/i18n/de/translation.json b/packages/file-handling/src/i18n/de/translation.json index 3ceae22b03e740ab313988f122de716a17ea7241..e9dfc4f3b610aa7741c621e66c281ae2656f042a 100644 --- a/packages/file-handling/src/i18n/de/translation.json +++ b/packages/file-handling/src/i18n/de/translation.json @@ -38,6 +38,8 @@ "folder-up": "In das übergeordnete Verzeichnis springen", "folder-home": "In das Home Verzeichnis springen", "select-files": "Dateien auswählen", + "select-files-btn": "Datei auswählen", + "select-files-btn_plural": "{{count}} Dateien auswählen", "refresh-nextcloud-file-picker": "Erneut verbinden", "loadpath-nextcloud-file-picker": "Das {{name}} Verzeichnis wird geladen.", "load-path-link": "Gehe zu {{path}}", @@ -124,6 +126,7 @@ "source-body": "Hier können Sie zuvor temporär abgelegte Dateien auswählen.", "source-btn": "Datei auswählen", "source-btn_plural": "{{count}} Dateien auswählen", + "source-btn-none": "Dateien auswählen", "sink-title": "Dateien in der Zwischenablage ablegen", "sink-body": "Hier können Sie Dateien temporär in der Zwischenablage ablegen.", "sink-btn": "{{count}} Datei ablegen", diff --git a/packages/file-handling/src/i18n/en/translation.json b/packages/file-handling/src/i18n/en/translation.json index 5de26a882b55987c2e07e2a0b1d2d8a20a624bf2..7639e448011b5881359a41d77d155f99ff951800 100644 --- a/packages/file-handling/src/i18n/en/translation.json +++ b/packages/file-handling/src/i18n/en/translation.json @@ -52,6 +52,8 @@ "folder-up": "Jump to the parent directory", "folder-home": "Jump to the home directory", "select-files": "Select files", + "select-files-btn": "Select file", + "select-files-btn_plural": "Select {{count}} files", "refresh-nextcloud-file-picker": "Connect again", "loadpath-nextcloud-file-picker": "Loading directory from {{name}}.", "load-path-link": "Go to {{path}}", @@ -138,6 +140,7 @@ "source-body": "Here you can select files which were previously stored temporarily.", "source-btn": "Select file", "source-btn_plural": "Select {{count}} files", + "source-btn-none": "Select files", "sink-title": "Store files on the clipboard", "sink-body": "Here you can temporarily store files on the clipboard.", "sink-btn": "Store {{count}} file",