Skip to content
Snippets Groups Projects
Commit ed4efaff authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Implement enabled-sources attribute (#6)

parent 7a8ac7dc
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,10 @@ files from a [Nextcloud](https://nextcloud.com/) instance.
- example `<vpu-file-source allowed-mime-types='image/*'></vpu-file-source>` ... images (of all sub types) only
- example `<vpu-file-source allowed-mime-types='image/png,text/plain'></vpu-file-source>` ... PNGs or TXTs only
- example `<vpu-file-source allowed-mime-types='*/*'></vpu-file-source>` ... all file types (default)
- `enabled-sources` (optional): sets which sources are enabled
- you can use `local` and `nextcloud`
- default is `local`
- example `<vpu-file-source enabled-sources='local,nextcloud'></vpu-file-source>`
- `disabled` (optional): disable input control
- example `<vpu-file-source disabled></vpu-file-source>`
- `decompress-zip` (optional): decompress zip file and send the contained files (including files in folders)
......
......@@ -38,6 +38,7 @@ export class FileSource extends ScopedElementsMixin(VPULitElement) {
this.nextcloudWebDavUrl = '';
this.dropArea = null;
this.allowedMimeTypes = '*/*';
this.enabledSources = 'local';
this.text = '';
this.buttonLabel = '';
this.disabled = false;
......@@ -62,6 +63,7 @@ export class FileSource extends ScopedElementsMixin(VPULitElement) {
return {
lang: { type: String },
allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' },
enabledSources: { type: String, attribute: 'enabled-sources' },
nextcloudAuthUrl: { type: String, attribute: 'nextcloud-auth-url' },
nextcloudWebDavUrl: { type: String, attribute: 'nextcloud-web-dav-url' },
text: { type: String },
......@@ -80,6 +82,11 @@ export class FileSource extends ScopedElementsMixin(VPULitElement) {
case "lang":
i18n.changeLanguage(this.lang);
break;
case "enabledSources":
if (!this.hasEnabledSource(this.activeSource)) {
this.activeSource = this.enabledSources.split(",")[0];
}
break;
case "isDialogOpen":
if (this.isDialogOpen) {
// this.setAttribute("dialog-open", "");
......@@ -219,6 +226,12 @@ export class FileSource extends ScopedElementsMixin(VPULitElement) {
return true;
}
hasEnabledSource(source) {
const enabledSources = this.enabledSources.split(',');
return enabledSources.includes(source);
}
/**
* Decompress files synchronously
*
......@@ -515,12 +528,12 @@ export class FileSource extends ScopedElementsMixin(VPULitElement) {
<nav class="modal-nav">
<div title="${i18n.t('file-source.nav-local')}"
@click="${() => { this.activeSource = "local"; }}"
class="${classMap({"active": this.activeSource === "local"})}">
class="${classMap({"active": this.activeSource === "local", hidden: !this.hasEnabledSource("local")})}">
<vpu-icon class="nav-icon" name="laptop"></vpu-icon>
</div>
<div title="Nextcloud"
@click="${() => { this.activeSource = "nextcloud"; }}"
class="${classMap({"active": this.activeSource === "nextcloud", hidden: this.nextcloudWebDavUrl === "" || this.nextcloudAuthUrl === ""})}">
class="${classMap({"active": this.activeSource === "nextcloud", hidden: !this.hasEnabledSource("nextcloud")})}">
<vpu-icon class="nav-icon" name="cloud"></vpu-icon>
</div>
</nav>
......
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