Skip to content
Snippets Groups Projects
Unverified Commit e46b30bb authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Fix error when Nextcloud file picker is not present and do element fetching refactoring

parent 7f9d111a
No related branches found
No related tags found
No related merge requests found
Pipeline #25597 passed
{ {
"name": "@dbp-toolkit/file-handling", "name": "@dbp-toolkit/file-handling",
"homepage": "https://gitlab.tugraz.at/dbp/web-components/toolkit/-/tree/master/packages/file-handling", "homepage": "https://gitlab.tugraz.at/dbp/web-components/toolkit/-/tree/master/packages/file-handling",
"version": "0.2.2", "version": "0.2.3",
"main": "src/index.js", "main": "src/index.js",
"license": "LGPL-2.1-or-later", "license": "LGPL-2.1-or-later",
"repository": { "repository": {
......
...@@ -198,9 +198,10 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) { ...@@ -198,9 +198,10 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) {
} }
loadWebdavDirectory() { loadWebdavDirectory() {
const filePicker = this._('#nextcloud-file-picker');
if (this._('#nextcloud-file-picker') && this._('#nextcloud-file-picker').webDavClient !== null) { if (filePicker && filePicker.webDavClient !== null) {
this._('#nextcloud-file-picker').loadDirectory(this._('#nextcloud-file-picker').directoryPath); filePicker.loadDirectory(filePicker.directoryPath);
} }
} }
...@@ -217,8 +218,10 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) { ...@@ -217,8 +218,10 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) {
if (this.initialFileHandlingState.target !== '' && typeof this.initialFileHandlingState.target !== 'undefined' && this.firstOpen) { if (this.initialFileHandlingState.target !== '' && typeof this.initialFileHandlingState.target !== 'undefined' && this.firstOpen) {
this.activeTarget = this.initialFileHandlingState.target; this.activeTarget = this.initialFileHandlingState.target;
this.nextcloudPath = this.initialFileHandlingState.path; this.nextcloudPath = this.initialFileHandlingState.path;
if (this._('#nextcloud-file-picker').webDavClient !== null) { const filePicker = this._('#nextcloud-file-picker');
this._('#nextcloud-file-picker').loadDirectory(this.initialFileHandlingState.path);
if (filePicker && filePicker.webDavClient !== null) {
filePicker.loadDirectory(this.initialFileHandlingState.path);
console.log("load default nextcloud sink", this.initialFileHandlingState.path); console.log("load default nextcloud sink", this.initialFileHandlingState.path);
} }
this.firstOpen = false; this.firstOpen = false;
......
...@@ -389,8 +389,13 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) { ...@@ -389,8 +389,13 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
if (filePicker) { if (filePicker) {
MicroModal.show(filePicker, { MicroModal.show(filePicker, {
disableScroll: true, disableScroll: true,
onClose: modal => { this.isDialogOpen = false; onClose: modal => {
this._('#nextcloud-file-picker').selectAllButton = true;} this.isDialogOpen = false;
const filePicker = this._('#nextcloud-file-picker');
if (filePicker) {
filePicker.selectAllButton = true;}
}
}); });
} }
...@@ -399,8 +404,10 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) { ...@@ -399,8 +404,10 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
if (this.initialFileHandlingState.target !== '' && typeof this.initialFileHandlingState.target !== 'undefined' && this.firstOpen) { if (this.initialFileHandlingState.target !== '' && typeof this.initialFileHandlingState.target !== 'undefined' && this.firstOpen) {
this.activeDestination = this.initialFileHandlingState.target; this.activeDestination = this.initialFileHandlingState.target;
this.nextcloudPath = this.initialFileHandlingState.path; this.nextcloudPath = this.initialFileHandlingState.path;
if (this._('#nextcloud-file-picker') && this._('#nextcloud-file-picker').webDavClient !== null) { const filePicker = this._('#nextcloud-file-picker');
this._('#nextcloud-file-picker').loadDirectory(this.initialFileHandlingState.path);
if (filePicker && filePicker.webDavClient !== null) {
filePicker.loadDirectory(this.initialFileHandlingState.path);
//console.log("load default nextcloud source", this.initialFileHandlingState.target); //console.log("load default nextcloud source", this.initialFileHandlingState.target);
} }
this.firstOpen = false; this.firstOpen = false;
...@@ -409,7 +416,12 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) { ...@@ -409,7 +416,12 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) {
closeDialog() { closeDialog() {
this.sendSource(); this.sendSource();
this._('#nextcloud-file-picker').selectAllButton = true; const filePicker = this._('#nextcloud-file-picker');
if (filePicker) {
filePicker.selectAllButton = true;
}
MicroModal.close(this._('#modal-picker')); MicroModal.close(this._('#modal-picker'));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment