@progressive-development/pd-spa-helper 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/PdSpaHelper.d.ts +1 -1
- package/dist/src/PdSpaHelper.js +3 -2
- package/dist/src/PdSpaHelper.js.map +1 -1
- package/dist/src/model/spa-model.d.ts +1 -0
- package/dist/src/model/spa-model.js.map +1 -1
- package/dist/src/service-provider/mock/auth.d.ts +1 -1
- package/dist/src/service-provider/mock/auth.js +12 -5
- package/dist/src/service-provider/mock/auth.js.map +1 -1
- package/dist/src/service-provider/service-provider-impl.js +1 -1
- package/dist/src/service-provider/service-provider-impl.js.map +1 -1
- package/dist/src/store/spa-app-actions.d.ts +10 -3
- package/dist/src/store/spa-app-actions.js +2 -1
- package/dist/src/store/spa-app-actions.js.map +1 -1
- package/dist/src/store/spa-app-reducer.d.ts +1 -1
- package/dist/src/store/spa-app-reducer.js +16 -10
- package/dist/src/store/spa-app-reducer.js.map +1 -1
- package/dist/src/store/spa-app-selector.d.ts +1 -1
- package/dist/src/stories/pd-loading-state.stories.d.ts +2 -0
- package/dist/src/stories/pd-loading-state.stories.js +29 -1
- package/dist/src/stories/pd-loading-state.stories.js.map +1 -1
- package/dist/src/tmpown/pd-loading-state.d.ts +3 -3
- package/dist/src/tmpown/pd-loading-state.js +7 -7
- package/dist/src/tmpown/pd-loading-state.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/PdSpaHelper.ts +4 -4
- package/src/model/spa-model.ts +2 -1
- package/src/service-provider/mock/auth.ts +15 -6
- package/src/service-provider/service-provider-impl.ts +1 -1
- package/src/store/spa-app-actions.ts +2 -1
- package/src/store/spa-app-reducer.ts +15 -10
- package/src/stories/pd-loading-state.stories.ts +31 -1
- package/src/tmpown/pd-loading-state.ts +8 -5
package/package.json
CHANGED
package/src/PdSpaHelper.ts
CHANGED
|
@@ -157,7 +157,7 @@ export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
|
157
157
|
_profile: any | undefined;
|
|
158
158
|
|
|
159
159
|
@property({ type: Object, state: true })
|
|
160
|
-
_loadingState
|
|
160
|
+
_loadingState: LoadingState[] = [];
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
* Properties needed for the router.
|
|
@@ -312,7 +312,7 @@ export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
|
312
312
|
this._subscription = pdStore().select(getLoadingSelector)
|
|
313
313
|
.subscribe((loadingState) => {
|
|
314
314
|
console.log("Loading State: ", loadingState);
|
|
315
|
-
this._loadingState = loadingState;
|
|
315
|
+
this._loadingState = loadingState || [];
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
318
|
|
|
@@ -384,7 +384,7 @@ export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
|
384
384
|
|
|
385
385
|
<main class="${this._getMainClass(hideTeaser, pageConf)}">
|
|
386
386
|
|
|
387
|
-
${this._loadingState
|
|
387
|
+
${this._loadingState.map(ls => html`<pd-loading-state .loadingState="${ls}"></pd-loading-state>`)}
|
|
388
388
|
|
|
389
389
|
<app-main active-route=${this.route}
|
|
390
390
|
@init-menu-sections="${this._initMenuSections}"
|
|
@@ -408,7 +408,7 @@ export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
|
408
408
|
</footer>` : ''}
|
|
409
409
|
`;
|
|
410
410
|
}
|
|
411
|
-
|
|
411
|
+
|
|
412
412
|
// eslint-disable-next-line class-methods-use-this
|
|
413
413
|
private _getMainClass(hideTeaser: boolean, pageConf: NavigationPage): string {
|
|
414
414
|
if (hideTeaser) {
|
package/src/model/spa-model.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pdStore } from "../../store/mini-rx.store";
|
|
1
2
|
|
|
2
3
|
/*
|
|
3
4
|
* Only for temporary development:
|
|
@@ -44,8 +45,13 @@ export const getAuthUserMock = (): unknown =>
|
|
|
44
45
|
} : undefined;
|
|
45
46
|
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
let callbackLogin: Function;
|
|
49
|
+
export const authStateChangedMock = (callback: Function) => {
|
|
50
|
+
callbackLogin = callback;
|
|
51
|
+
console.log("Not implemented for MOCK, do call once if authenticated");
|
|
52
|
+
if (isAuthenticatedMock()) {
|
|
53
|
+
callbackLogin(getAuthUserMock())
|
|
54
|
+
}
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
export const loginMock = async (user:string, sec:string): Promise<unknown> => {
|
|
@@ -57,13 +63,16 @@ export const loginMock = async (user:string, sec:string): Promise<unknown> => {
|
|
|
57
63
|
localStorage.setItem(LOCALSTORE_ITEM_KEY, 'true');
|
|
58
64
|
}
|
|
59
65
|
valid = true;
|
|
60
|
-
loginAvailable = true;
|
|
66
|
+
loginAvailable = true;
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
if (valid) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
|
|
71
|
+
const userMock = getAuthUserMock();
|
|
72
|
+
if (callbackLogin) {
|
|
73
|
+
callbackLogin(userMock)
|
|
74
|
+
}
|
|
75
|
+
return Promise.resolve(user);
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
const err = new Error("Invalid login");
|
|
@@ -98,7 +98,7 @@ export const authStateChangedImpl = (
|
|
|
98
98
|
if (provider === "firebase") {
|
|
99
99
|
authStateChanged(callback);
|
|
100
100
|
} else if (provider === "mock") {
|
|
101
|
-
authStateChangedMock();
|
|
101
|
+
authStateChangedMock(callback);
|
|
102
102
|
} else {
|
|
103
103
|
throwUndefinedProviderError();
|
|
104
104
|
}
|
|
@@ -8,4 +8,5 @@ export const routeAction = action('SPA_APP_ROUTE', payload<string>());
|
|
|
8
8
|
|
|
9
9
|
export const updateInternetOffline = action('SPA_APP_UPDATE_INTERNET_OFFLINE', payload<boolean>());
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const addLoadingState = action('SPA_APP_ADD_LOADING', payload<LoadingState>());
|
|
12
|
+
export const removeLoadingState = action('SPA_APP_REMOVE_LOADING', payload<string>());
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { on, reducer } from 'ts-action';
|
|
2
2
|
|
|
3
|
-
import { initIndexDBSucess,
|
|
3
|
+
import { initIndexDBSucess, addLoadingState, loginSucess, routeAction, updateInternetOffline, removeLoadingState } from './spa-app-actions.js';
|
|
4
4
|
import { LoadingState } from '../model/spa-model.js';
|
|
5
5
|
|
|
6
6
|
export interface SpaAppState {
|
|
7
7
|
offline?: boolean,
|
|
8
|
-
loadingState
|
|
8
|
+
loadingState: LoadingState[];
|
|
9
9
|
lastRoutes?: any[];
|
|
10
10
|
initIndexDB?: boolean;
|
|
11
11
|
userLogin?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const initialState: SpaAppState = {
|
|
15
|
-
|
|
15
|
+
loadingState: [],
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const spaAppReducer = reducer(
|
|
@@ -25,15 +25,20 @@ export const spaAppReducer = reducer(
|
|
|
25
25
|
}
|
|
26
26
|
)),
|
|
27
27
|
|
|
28
|
-
on(
|
|
28
|
+
on(addLoadingState, (state, {payload}) => (
|
|
29
29
|
{
|
|
30
30
|
...state,
|
|
31
|
-
loadingState:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
loadingState: [
|
|
32
|
+
...(state.loadingState),
|
|
33
|
+
payload
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
)),
|
|
37
|
+
|
|
38
|
+
on(removeLoadingState, (state, {payload}) => (
|
|
39
|
+
{
|
|
40
|
+
...state,
|
|
41
|
+
loadingState: state.loadingState?.filter(a => a.actionKey !== payload)
|
|
37
42
|
}
|
|
38
43
|
)),
|
|
39
44
|
|
|
@@ -10,7 +10,17 @@ const meta = {
|
|
|
10
10
|
render: (args) => html`
|
|
11
11
|
<pd-loading-state
|
|
12
12
|
.loadingState="${args.loadingState}"
|
|
13
|
-
></pd-loading-state>
|
|
13
|
+
></pd-loading-state>
|
|
14
|
+
|
|
15
|
+
${args.doubleState ? html`
|
|
16
|
+
<pd-loading-state
|
|
17
|
+
.loadingState="${{
|
|
18
|
+
isLoading: true,
|
|
19
|
+
modal: true,
|
|
20
|
+
actionKey: ""
|
|
21
|
+
}}"
|
|
22
|
+
></pd-loading-state>
|
|
23
|
+
` : ''}
|
|
14
24
|
|
|
15
25
|
<p>
|
|
16
26
|
Hier steht noch sonst was an text.
|
|
@@ -81,3 +91,23 @@ export const BackgroundState: Story = {
|
|
|
81
91
|
},
|
|
82
92
|
};
|
|
83
93
|
|
|
94
|
+
export const ModalBackgroundState: Story = {
|
|
95
|
+
args: {
|
|
96
|
+
loadingState: {
|
|
97
|
+
isLoading: true,
|
|
98
|
+
smallBackground: true,
|
|
99
|
+
modal: true,
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const ModalWithBackgroundState: Story = {
|
|
105
|
+
args: {
|
|
106
|
+
loadingState: {
|
|
107
|
+
isLoading: true,
|
|
108
|
+
smallBackground: true,
|
|
109
|
+
},
|
|
110
|
+
doubleState: true
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
@@ -10,10 +10,7 @@ import {LoadingState} from '../model/spa-model.js';
|
|
|
10
10
|
export class PdLoadingState extends LitElement {
|
|
11
11
|
|
|
12
12
|
@property({ type: Object})
|
|
13
|
-
loadingState
|
|
14
|
-
isLoading: false
|
|
15
|
-
};
|
|
16
|
-
|
|
13
|
+
loadingState?: LoadingState;
|
|
17
14
|
|
|
18
15
|
static styles = [
|
|
19
16
|
css`
|
|
@@ -62,7 +59,7 @@ export class PdLoadingState extends LitElement {
|
|
|
62
59
|
bottom: 0em;
|
|
63
60
|
|
|
64
61
|
padding: 1em;
|
|
65
|
-
z-index:
|
|
62
|
+
z-index: 600; /* Sit on top */
|
|
66
63
|
|
|
67
64
|
display: flex;
|
|
68
65
|
gap: 0.5em;
|
|
@@ -105,6 +102,9 @@ export class PdLoadingState extends LitElement {
|
|
|
105
102
|
] as CSSResultGroup;
|
|
106
103
|
|
|
107
104
|
render() {
|
|
105
|
+
if (!this.loadingState) {
|
|
106
|
+
return '';
|
|
107
|
+
}
|
|
108
108
|
return this.loadingState.modal ? html`
|
|
109
109
|
<div id="modalId" class="modal">
|
|
110
110
|
${this._renderContent()}
|
|
@@ -113,6 +113,9 @@ export class PdLoadingState extends LitElement {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
_renderContent() {
|
|
116
|
+
if (!this.loadingState) {
|
|
117
|
+
return '';
|
|
118
|
+
}
|
|
116
119
|
return html`
|
|
117
120
|
<div class="${classMap({
|
|
118
121
|
content: !this.loadingState.smallBackground,
|