Skip to content
Snippets Groups Projects
Commit e1b83639 authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Small fixes in file-handling

parent 59695e8c
Branches
No related tags found
No related merge requests found
Pipeline #46226 passed
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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",
......
......@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment