diff --git a/packages/file-handling/src/clipboard.js b/packages/file-handling/src/clipboard.js index 8088f961b0e98620d175499d6ffa0867ecfe1525..7f7fb3faa49c5495715d153e37a8255b5158e098 100644 --- a/packages/file-handling/src/clipboard.js +++ b/packages/file-handling/src/clipboard.js @@ -239,7 +239,22 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { if (this._("#select_all_checkmark")) { this._("#select_all_checkmark").title = this.checkAllSelected() ? i18n.t('clipboard.select-nothing') : i18n.t('clipboard.select-all'); } - } + }, + renderComplete: () => { + if (this.tabulatorTable !== null) { + const that = this; + setTimeout(function(){ + if (that._('.tabulator-responsive-collapse-toggle-open')) { + that._a('.tabulator-responsive-collapse-toggle-open').forEach(element => element.addEventListener("click", that.toggleCollapse.bind(that))); + } + + if (that._('.tabulator-responsive-collapse-toggle-close')) { + that._a('.tabulator-responsive-collapse-toggle-close').forEach(element => element.addEventListener("click", that.toggleCollapse.bind(that))); + } + }, 0); + } + + }, }); that.generateClipboardTable(); @@ -337,17 +352,6 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { if (this.tabulatorTable !== null) { this.tabulatorTable.clearData(); this.tabulatorTable.setData(data); - - const that = this; - setTimeout(function(){ - if (that._('.tabulator-responsive-collapse-toggle-open')) { - that._a('.tabulator-responsive-collapse-toggle-open').forEach(element => element.addEventListener("click", that.toggleCollapse.bind(that))); - } - - if (that._('.tabulator-responsive-collapse-toggle-close')) { - that._a('.tabulator-responsive-collapse-toggle-close').forEach(element => element.addEventListener("click", that.toggleCollapse.bind(that))); - } - }, 0); } } if (this._("#select_all")) { diff --git a/packages/file-handling/src/file-source.js b/packages/file-handling/src/file-source.js index b352500c4b486c1c3669b1782d68489f3a6e38ac..c0a8a7ba995c6dbef43eee69a93f3b888a9bd6cc 100644 --- a/packages/file-handling/src/file-source.js +++ b/packages/file-handling/src/file-source.js @@ -118,7 +118,12 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { if (this.firstOpen) { this.nextcloudPath = this.initialFileHandlingState.path; } - break; + break; + case "activeTarget": + if (this.activeTarget === "nextcloud") { + this.loadWebdavDirectory(); + } + break; } }); super.update(changedProperties); diff --git a/packages/file-handling/src/nextcloud-file-picker.js b/packages/file-handling/src/nextcloud-file-picker.js index b37ab28e88c8aac90339688aec4c1c8ed386e25e..8b149ed8a9e74ee237678f2abf757bd4c98bf562 100644 --- a/packages/file-handling/src/nextcloud-file-picker.js +++ b/packages/file-handling/src/nextcloud-file-picker.js @@ -306,7 +306,22 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { }, rowAdded: (row) => { row.getElement().classList.toggle("addRowAnimation"); - } + }, + renderComplete: () => { + if (this.tabulatorTable !== null) { + const that = this; + setTimeout(function(){ + if (that._('.tabulator-responsive-collapse-toggle-open')) { + that._a('.tabulator-responsive-collapse-toggle-open').forEach(element => element.addEventListener("click", that.toggleCollapse.bind(that))); + } + + if (that._('.tabulator-responsive-collapse-toggle-close')) { + that._a('.tabulator-responsive-collapse-toggle-close').forEach(element => element.addEventListener("click", that.toggleCollapse.bind(that))); + } + }, 0); + } + + }, }); @@ -392,6 +407,10 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { } } + _a(selector) { + return this.shadowRoot === null ? this.querySelectorAll(selector) : this.shadowRoot.querySelectorAll(selector); + } + onReceiveWindowMessage(event) { if (this.webDavClient === null) { const data = event.data; @@ -413,14 +432,19 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { if (this._("#remember-checkbox") && this._("#remember-checkbox").checked) { sessionStorage.setItem('nextcloud-webdav-username', data.loginName); sessionStorage.setItem('nextcloud-webdav-password', data.token); - console.log("saved"); - } this.loadDirectory(this.directoryPath); } } } + toggleCollapse(e) { + const table = this.tabulatorTable; + setTimeout(function() { + table.redraw(); + }, 0); + } + /** * Loads the directory from WebDAV * @@ -479,7 +503,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { "</d:propfind>" }) .then(contents => { - //console.log("------", contents); + this.loading = false; this.statusText = ""; this.tabulatorTable.setData(contents.data); @@ -490,6 +514,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { } else { this._("#download-button").removeAttribute("disabled"); } + }).catch(error => { console.error(error.message); diff --git a/packages/file-handling/src/styles.js b/packages/file-handling/src/styles.js index 180643c959c5acc62be18f274f341338304c64d0..70cd49b72045d0d814f20670836d3c19676184c8 100644 --- a/packages/file-handling/src/styles.js +++ b/packages/file-handling/src/styles.js @@ -230,6 +230,7 @@ export function getFileHandlingCss() { .tabulator-responsive-collapse-toggle-open, .tabulator-responsive-collapse-toggle-close{ width: 100%; height: 100%; + line-height: 37px; } .tabulator-row-handle{