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

Remove a raise condition

parent e6d34fbd
No related branches found
No related tags found
No related merge requests found
Pipeline #51260 passed
...@@ -30,6 +30,8 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { ...@@ -30,6 +30,8 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
this.filesToSave = []; this.filesToSave = [];
this.numberOfSelectedFiles = 0; this.numberOfSelectedFiles = 0;
this.enabledTargets = 'local'; this.enabledTargets = 'local';
this.countUploadFiles = 0;
this.buttonsDisabled = false;
this.nextcloudWebAppPasswordURL = ""; this.nextcloudWebAppPasswordURL = "";
this.nextcloudWebDavURL = ""; this.nextcloudWebDavURL = "";
...@@ -57,11 +59,12 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { ...@@ -57,11 +59,12 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
...super.properties, ...super.properties,
lang: { type: String }, lang: { type: String },
allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' }, allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' },
clipboardSelectBtnDisabled: { type: Boolean, attribute: true }, clipboardSelectBtnDisabled: { type: Boolean },
clipboardFiles: {type: Object, attribute: 'clipboard-files' }, clipboardFiles: {type: Object, attribute: 'clipboard-files' },
filesToSave: {type: Array, attribute: 'files-to-save' }, filesToSave: {type: Array, attribute: 'files-to-save' },
numberOfSelectedFiles: {type: Number, attribute: false }, numberOfSelectedFiles: {type: Number, attribute: false },
enabledTargets: {type: String, attribute: 'enabled-targets'}, enabledTargets: {type: String, attribute: 'enabled-targets'},
buttonsDisabled: {type: Boolean },
nextcloudWebAppPasswordURL: { type: String, attribute: 'nextcloud-auth-url' }, nextcloudWebAppPasswordURL: { type: String, attribute: 'nextcloud-auth-url' },
nextcloudWebDavURL: { type: String, attribute: 'nextcloud-web-dav-url' }, nextcloudWebDavURL: { type: String, attribute: 'nextcloud-web-dav-url' },
...@@ -352,20 +355,6 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { ...@@ -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 * Sends the files to a provider and throws a notification
* *
...@@ -454,6 +443,14 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { ...@@ -454,6 +443,14 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
{ bubbles: true, composed: true }); { bubbles: true, composed: true });
this.dispatchEvent(event); 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) { ...@@ -570,11 +567,13 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) {
getAdditionalButtons() { getAdditionalButtons() {
const i18n = this._i18n; const i18n = this._i18n;
let buttonsAreDisabled = this.clipboardFiles.files.length === 0 ? true : this.clipboardSelectBtnDisabled; let buttonsAreDisabled = this.clipboardFiles.files.length === 0 ? true : this.clipboardSelectBtnDisabled;
buttonsAreDisabled = this.buttonsDisabled ? true : buttonsAreDisabled;
return html` return html`
<div class="flex-container additional-button-container"> <div class="flex-container additional-button-container">
<div class="btn-flex-container-mobile"> <div class="btn-flex-container-mobile">
<button @click="${() => { this.openFileSource(); }}" <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')} <dbp-icon class="nav-icon" name="clipboard"></dbp-icon> ${i18n.t('clipboard.add-files-btn')}
</button> </button>
<button @click="${() => { this.clearClipboard(); }}" <button @click="${() => { this.clearClipboard(); }}"
......
...@@ -14,7 +14,7 @@ export default class DbpFileHandlingLitElement extends ScopedElementsMixin(DBPLi ...@@ -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 * to match the scrolling position
* *
* @param e * @param e
......
...@@ -155,8 +155,6 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -155,8 +155,6 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
super.disconnectedCallback(); super.disconnectedCallback();
} }
preventDefaults (e) { preventDefaults (e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
...@@ -205,42 +203,44 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -205,42 +203,44 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
// console.log('handleFiles: files.length = ' + files.length); // console.log('handleFiles: files.length = ' + files.length);
// this.dispatchEvent(new CustomEvent("dbp-file-source-selection-start", // this.dispatchEvent(new CustomEvent("dbp-file-source-selection-start",
// { "detail": {}, bubbles: true, composed: true })); // { "detail": {}, bubbles: true, composed: true }));
let fileCount = files.length;
await commonUtils.asyncArrayForEach(files, async (file) => { await commonUtils.asyncArrayForEach(files, async (file, index) => {
if (file.size === 0) { if (file.size === 0) {
console.log('file \'' + file.name + '\' has size=0 and is denied!'); console.log('file \'' + file.name + '\' has size=0 and is denied!');
return; return;
} }
// check if we want to decompress the zip and queue the contained files // check if we want to decompress the zip and queue the contained files
if (this.decompressZip if (this.decompressZip
&& (file.type === "application/zip" || file.type === "application/x-zip-compressed")) { && (file.type === "application/zip" || file.type === "application/x-zip-compressed")) {
// add decompressed files to tempFilesToHandle // add decompressed files to tempFilesToHandle
await commonUtils.asyncArrayForEach( 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; return;
} else if (this.allowedMimeTypes && !this.checkFileType(file)) { } else if (this.allowedMimeTypes && !this.checkFileType(file)) {
return; return;
} }
await this.sendFileEvent(file); await this.sendFileEvent(file, fileCount);
}); });
// this.dispatchEvent(new CustomEvent("dbp-file-source-selection-finished", // this.dispatchEvent(new CustomEvent("dbp-file-source-selection-finished",
// { "detail": {}, bubbles: true, composed: true })); // { "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.dispatchEvent(event);
this.closeDialog(); this.closeDialog();
} }
/** /**
* @param file * @param file, last
*/ */
sendFileEvent(file) { sendFileEvent(file, maxUpload) {
this.sendSource(); this.sendSource();
MicroModal.close(this._('#modal-picker')); 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 }); const event = new CustomEvent("dbp-file-source-file-selected", { "detail": data, bubbles: true, composed: true });
this.dispatchEvent(event); this.dispatchEvent(event);
} }
...@@ -249,7 +249,6 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -249,7 +249,6 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
let data = {}; let data = {};
if (this.activeTarget == 'nextcloud') { if (this.activeTarget == 'nextcloud') {
data = {"target": this.activeTarget, "path": this._("#nextcloud-file-picker").directoryPath}; data = {"target": this.activeTarget, "path": this._("#nextcloud-file-picker").directoryPath};
} else { } else {
data = {"target": this.activeTarget}; data = {"target": this.activeTarget};
} }
...@@ -485,7 +484,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -485,7 +484,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
auth-info="${this.nextcloudAuthInfo}" auth-info="${this.nextcloudAuthInfo}"
allowed-mime-types="${this.allowedMimeTypes}" allowed-mime-types="${this.allowedMimeTypes}"
@dbp-nextcloud-file-picker-file-downloaded="${(event) => { @dbp-nextcloud-file-picker-file-downloaded="${(event) => {
this.sendFileEvent(event.detail.file);}}"> this.sendFileEvent(event.detail.file, event.detail.maxUpload);}}">
</dbp-nextcloud-file-picker>`; </dbp-nextcloud-file-picker>`;
} }
return html``; return html``;
...@@ -577,10 +576,16 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -577,10 +576,16 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
height: 100%; height: 100%;
} }
}
@media only screen
and (orientation: portrait)
and (max-width: 340px) {
.paddles{ .paddles{
display: inherit; display: inherit;
} }
} }
`; `;
} }
...@@ -593,7 +598,6 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -593,7 +598,6 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
allowedMimeTypes += ",application/zip,application/x-zip-compressed"; allowedMimeTypes += ",application/zip,application/x-zip-compressed";
} }
return html` return html`
<!-- <!--
<button class="button" <button class="button"
......
...@@ -549,7 +549,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -549,7 +549,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
* @param files * @param files
*/ */
downloadFiles(files) { downloadFiles(files) {
files.forEach((fileData) => this.downloadFile(fileData)); files.forEach((fileData) => this.downloadFile(fileData, files.length));
this.tabulatorTable.deselectRow(); this.tabulatorTable.deselectRow();
if (this._("#select_all")) { if (this._("#select_all")) {
this._("#select_all").checked = false; this._("#select_all").checked = false;
...@@ -569,9 +570,10 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -569,9 +570,10 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
/** /**
* Download a single file * Download a single file
* *
* @param fileData * @param fileData, maxUpload
*/ */
downloadFile(fileData) { downloadFile(fileData, maxUpload) {
const i18n = this._i18n; const i18n = this._i18n;
this.loading = true; this.loading = true;
this.statusText = "Loading " + fileData.filename + "..."; this.statusText = "Loading " + fileData.filename + "...";
...@@ -583,7 +585,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -583,7 +585,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
// create file to send via event // create file to send via event
const file = new File([contents], fileData.basename, {type: fileData.mime}); const file = new File([contents], fileData.basename, {type: fileData.mime});
// send event // 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", const event = new CustomEvent("dbp-nextcloud-file-picker-file-downloaded",
{"detail": data, bubbles: true, composed: true}); {"detail": data, bubbles: true, composed: true});
this.dispatchEvent(event); this.dispatchEvent(event);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment