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

Show a loading spinner between login and auth checks

In case the activity gets loaded and we are already logged in there
is a short perio where we still wait for the person fetch to finish
so we can see if the user has the right permissions.

Instead of showing the "not logged in" message show a loading spinner.
parent 7cc833f7
No related branches found
No related tags found
No related merge requests found
Pipeline #10590 passed
...@@ -293,6 +293,9 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitElem ...@@ -293,6 +293,9 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitElem
} }
render() { render() {
if (this.isLoading()) {
return html`<vpu-mini-spinner></vpu-mini-spinner>`;
}
return html` return html`
<div class="${classMap({hidden: !this.isLoggedIn() || !this.hasSignaturePermissions()})}"> <div class="${classMap({hidden: !this.isLoggedIn() || !this.hasSignaturePermissions()})}">
<div class="field"> <div class="field">
......
...@@ -504,6 +504,9 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle ...@@ -504,6 +504,9 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle
} }
render() { render() {
if (this.isLoading()) {
return html`<vpu-mini-spinner></vpu-mini-spinner>`;
}
return html` return html`
<div class="${classMap({hidden: !this.isLoggedIn() || !this.hasSignaturePermissions()})}"> <div class="${classMap({hidden: !this.isLoggedIn() || !this.hasSignaturePermissions()})}">
<div class="field"> <div class="field">
......
...@@ -12,16 +12,18 @@ export default class VPUSignatureLitElement extends LitElement { ...@@ -12,16 +12,18 @@ export default class VPUSignatureLitElement extends LitElement {
} }
_updateAuth() { _updateAuth() {
if (this.isLoggedIn() && !this._loginCalled) { // Every time isLoggedIn()/isLoading() return something different we request a re-render
this._loginCalled = true; let newLoginState = [this.isLoggedIn(), this.isLoading()];
this.loginCallback(); if (this._loginState.toString() !== newLoginState.toString()) {
this.requestUpdate();
} }
this._loginState = newLoginState;
} }
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
this._loginCalled = false; this._loginState = [];
this._subscriber = new events.EventSubscriber('vpu-auth-update', 'vpu-auth-update-request'); this._subscriber = new events.EventSubscriber('vpu-auth-update', 'vpu-auth-update-request');
this._updateAuth = this._updateAuth.bind(this); this._updateAuth = this._updateAuth.bind(this);
this._subscriber.subscribe(this._updateAuth); this._subscriber.subscribe(this._updateAuth);
...@@ -38,9 +40,8 @@ export default class VPUSignatureLitElement extends LitElement { ...@@ -38,9 +40,8 @@ export default class VPUSignatureLitElement extends LitElement {
return (window.VPUPerson !== undefined && window.VPUPerson !== null); return (window.VPUPerson !== undefined && window.VPUPerson !== null);
} }
loginCallback() { isLoading() {
// Implement in subclass return (!this.isLoggedIn() && window.VPUAuthToken !== undefined);
this.requestUpdate();
} }
getOrganization() { getOrganization() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment