Skip to content
Snippets Groups Projects
Commit 4fcf8995 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Split the base element class into a signature specific part and a generic one

Not every activity needs those file queuing things
parent 8b270264
No related branches found
No related tags found
No related merge requests found
Pipeline #15503 failed
......@@ -3,7 +3,58 @@ import {EventBus} from '@dbp-toolkit/common';
import buildinfo from 'consts:buildinfo';
import * as utils from "./utils";
export default class DBPSignatureLitElement extends LitElement {
export class DBPSignatureBaseLitElement extends LitElement {
constructor() {
super();
}
_(selector) {
return this.shadowRoot === null ? this.querySelector(selector) : this.shadowRoot.querySelector(selector);
}
_hasSignaturePermissions(roleName) {
return (window.DBPPerson && Array.isArray(window.DBPPerson.roles) && window.DBPPerson.roles.indexOf(roleName) !== -1);
}
_updateAuth(e) {
this._loginStatus = e.status;
// Every time isLoggedIn()/isLoading() return something different we request a re-render
let newLoginState = [this.isLoggedIn(), this.isLoading()];
if (this._loginState.toString() !== newLoginState.toString()) {
this.requestUpdate();
}
this._loginState = newLoginState;
}
connectedCallback() {
super.connectedCallback();
this._loginStatus = '';
this._loginState = [];
this._bus = new EventBus();
this._updateAuth = this._updateAuth.bind(this);
this._bus.subscribe('auth-update', this._updateAuth);
}
disconnectedCallback() {
this._bus.close();
super.disconnectedCallback();
}
isLoggedIn() {
return (window.DBPPerson !== undefined && window.DBPPerson !== null);
}
isLoading() {
if (this._loginStatus === "logged-out")
return false;
return (!this.isLoggedIn() && window.DBPAuthToken !== undefined);
}
}
export default class DBPSignatureLitElement extends DBPSignatureBaseLitElement {
constructor() {
super();
this.queuedFiles = [];
......@@ -142,57 +193,6 @@ export default class DBPSignatureLitElement extends LitElement {
this.onFileUploadFinished(data);
}
/**
* @param data
*/
onFileUploadFinished(data) {
console.log("Override me");
}
_(selector) {
return this.shadowRoot === null ? this.querySelector(selector) : this.shadowRoot.querySelector(selector);
}
_hasSignaturePermissions(roleName) {
return (window.DBPPerson && Array.isArray(window.DBPPerson.roles) && window.DBPPerson.roles.indexOf(roleName) !== -1);
}
_updateAuth(e) {
this._loginStatus = e.status;
// Every time isLoggedIn()/isLoading() return something different we request a re-render
let newLoginState = [this.isLoggedIn(), this.isLoading()];
if (this._loginState.toString() !== newLoginState.toString()) {
this.requestUpdate();
}
this._loginState = newLoginState;
}
connectedCallback() {
super.connectedCallback();
this._loginStatus = '';
this._loginState = [];
this._bus = new EventBus();
this._updateAuth = this._updateAuth.bind(this);
this._bus.subscribe('auth-update', this._updateAuth);
}
disconnectedCallback() {
this._bus.close();
super.disconnectedCallback();
}
isLoggedIn() {
return (window.DBPPerson !== undefined && window.DBPPerson !== null);
}
isLoading() {
if (this._loginStatus === "logged-out")
return false;
return (!this.isLoggedIn() && window.DBPAuthToken !== undefined);
}
/**
* Open Filesink for multiple files
*/
......@@ -210,6 +210,13 @@ export default class DBPSignatureLitElement extends LitElement {
this._("#zip-download-button").stop();
}
/**
* @param data
*/
onFileUploadFinished(data) {
console.log("Override me");
}
/**
* Open Filesink for a single File
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment