@progressive-development/pd-spa-helper 0.2.4 → 0.2.6
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 -15
- package/dist/src/PdSpaHelper.js +49 -46
- package/dist/src/PdSpaHelper.js.map +1 -1
- package/dist/src/model/spa-model.d.ts +6 -0
- package/dist/src/model/spa-model.js.map +1 -1
- package/dist/src/store/spa-app-actions.d.ts +14 -1
- package/dist/src/store/spa-app-actions.js +1 -0
- package/dist/src/store/spa-app-actions.js.map +1 -1
- package/dist/src/store/spa-app-effects.js +1 -0
- package/dist/src/store/spa-app-effects.js.map +1 -1
- package/dist/src/store/spa-app-reducer.js +15 -1
- package/dist/src/store/spa-app-reducer.js.map +1 -1
- package/dist/src/stories/pd-loading-state.stories.d.ts +1 -0
- package/dist/src/stories/pd-loading-state.stories.js +26 -0
- package/dist/src/stories/pd-loading-state.stories.js.map +1 -1
- package/dist/src/tmpown/pd-loading-state.d.ts +1 -0
- package/dist/src/tmpown/pd-loading-state.js +44 -1
- 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 +51 -49
- package/src/model/spa-model.ts +9 -1
- package/src/store/spa-app-actions.ts +5 -1
- package/src/store/spa-app-effects.ts +3 -0
- package/src/store/spa-app-reducer.ts +18 -1
- package/src/stories/pd-loading-state.stories.ts +27 -0
- package/src/tmpown/pd-loading-state.ts +45 -1
package/package.json
CHANGED
package/src/PdSpaHelper.ts
CHANGED
|
@@ -9,11 +9,10 @@ import { FirebaseApp } from 'firebase/app';
|
|
|
9
9
|
import '@progressive-development/pd-page/pd-menu.js';
|
|
10
10
|
import '@progressive-development/pd-page/pd-footer.js';
|
|
11
11
|
|
|
12
|
-
import { ServiceCallController } from './service-call-controller2.js';
|
|
13
12
|
import { initializeStore, pdStore } from './store/mini-rx.store.js';
|
|
14
13
|
|
|
15
14
|
import { authStateChangedImpl, initAppImpl, isAuthenticatedImpl, setServiceProvider } from './service-provider/service-provider-impl.js';
|
|
16
|
-
import { AppConfiguration, Footer,
|
|
15
|
+
import { AppConfiguration, Footer, MenuElement, NavigationConfig, NavigationPage } from './service-provider/service-provider-model.js';
|
|
17
16
|
|
|
18
17
|
import { getLoadingSelector } from './store/spa-app-selector.js';
|
|
19
18
|
import { setRouteElement } from './store/spa-app-effects.js';
|
|
@@ -139,8 +138,6 @@ const TOP_MENU_HEIGHT = 50;
|
|
|
139
138
|
*/
|
|
140
139
|
export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
141
140
|
|
|
142
|
-
protected functionsController = new ServiceCallController(this);
|
|
143
|
-
|
|
144
141
|
protected abstract _appConfiguration: any;
|
|
145
142
|
|
|
146
143
|
// not used at the moment
|
|
@@ -312,7 +309,7 @@ export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
|
312
309
|
this._subscription = pdStore().select(getLoadingSelector)
|
|
313
310
|
.subscribe((loadingState) => {
|
|
314
311
|
console.log("Loading State: ", loadingState);
|
|
315
|
-
this._loadingState = loadingState
|
|
312
|
+
this._loadingState = loadingState;
|
|
316
313
|
});
|
|
317
314
|
}
|
|
318
315
|
|
|
@@ -393,14 +390,7 @@ export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
|
393
390
|
${navigationConfig.includeLogin ? html`
|
|
394
391
|
<default-login ?active="${this.route === "login"}" route="login"></default-login>` : ''}
|
|
395
392
|
</app-main>
|
|
396
|
-
</main>
|
|
397
|
-
|
|
398
|
-
${this.functionsController.render({
|
|
399
|
-
complete: (result: FunctionResult) => this._renderSuccessResultInfo(result),
|
|
400
|
-
initial: () => '',
|
|
401
|
-
pending: () => this._renderPendingInfo(),
|
|
402
|
-
error: (e: any) => this._renderErrorInfo(e),
|
|
403
|
-
})}
|
|
393
|
+
</main>
|
|
404
394
|
|
|
405
395
|
${pageConf?.withFooter ? html`
|
|
406
396
|
<footer class="default-footer">
|
|
@@ -488,40 +478,6 @@ export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
|
488
478
|
`;
|
|
489
479
|
}
|
|
490
480
|
|
|
491
|
-
/**
|
|
492
|
-
* Called when (any) cloud function call was finished.
|
|
493
|
-
*/
|
|
494
|
-
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
495
|
-
_renderSuccessResultInfo(result: FunctionResult) {
|
|
496
|
-
return html`
|
|
497
|
-
<pd-toast isSuccess duration="${TOAST_DURATION}">
|
|
498
|
-
${this.functionsController.callDataPromise?.func.successTxt}
|
|
499
|
-
</pd-toast>`;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Called when (any) cloud function is currently running.
|
|
504
|
-
*/
|
|
505
|
-
_renderPendingInfo() {
|
|
506
|
-
return this.functionsController.callDataPromise?.func.fadeWindow ? html`
|
|
507
|
-
<p>Überblende und lade ${this.functionsController.callDataPromise?.func.name}...</p>`
|
|
508
|
-
: html`
|
|
509
|
-
<pd-toast duration="-1">
|
|
510
|
-
${this.functionsController.callDataPromise?.func.pendingTxt}
|
|
511
|
-
</pd-toast>`;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* Called when (any) cloud function stopped with errors.
|
|
516
|
-
*/
|
|
517
|
-
// eslint-disable-next-line class-methods-use-this
|
|
518
|
-
_renderErrorInfo(error:any) {
|
|
519
|
-
return html`
|
|
520
|
-
<pd-toast isError duration="-1">
|
|
521
|
-
${error}
|
|
522
|
-
</pd-toast>`;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
481
|
protected abstract _getTeaserContent(): Array<TemplateResult>;
|
|
526
482
|
|
|
527
483
|
protected abstract _getFooter(): Footer;
|
|
@@ -579,7 +535,7 @@ export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
|
579
535
|
_createTemporaryToast(e: any) {
|
|
580
536
|
|
|
581
537
|
// hide existing call function toast (old one still is visible for directly incoming errors)
|
|
582
|
-
this.functionsController.clear();
|
|
538
|
+
// this.functionsController.clear();
|
|
583
539
|
|
|
584
540
|
const tmpToast = new PdToast();
|
|
585
541
|
tmpToast.isError = e.detail.isError;
|
|
@@ -619,4 +575,50 @@ export abstract class PdSpaHelper extends router(navigator(LitElement)) {
|
|
|
619
575
|
}
|
|
620
576
|
}
|
|
621
577
|
|
|
622
|
-
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// Refactor: deactivate functions controller unwanted with new loader
|
|
581
|
+
/*
|
|
582
|
+
protected functionsController = new ServiceCallController(this);
|
|
583
|
+
|
|
584
|
+
// from render
|
|
585
|
+
${this.functionsController.render({
|
|
586
|
+
complete: (result: FunctionResult) => this._renderSuccessResultInfo(result),
|
|
587
|
+
initial: () => '',
|
|
588
|
+
pending: () => this._renderPendingInfo(),
|
|
589
|
+
error: (e: any) => this._renderErrorInfo(e),
|
|
590
|
+
})}
|
|
591
|
+
/**
|
|
592
|
+
* Called when (any) cloud function call was finished.
|
|
593
|
+
|
|
594
|
+
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
595
|
+
_renderSuccessResultInfo(result: FunctionResult) {
|
|
596
|
+
return html`
|
|
597
|
+
<pd-toast isSuccess duration="${TOAST_DURATION}">
|
|
598
|
+
${this.functionsController.callDataPromise?.func.successTxt}
|
|
599
|
+
</pd-toast>`;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Called when (any) cloud function is currently running.
|
|
604
|
+
|
|
605
|
+
_renderPendingInfo() {
|
|
606
|
+
return this.functionsController.callDataPromise?.func.fadeWindow ? html`
|
|
607
|
+
<p>Überblende und lade ${this.functionsController.callDataPromise?.func.name}...</p>`
|
|
608
|
+
: html`
|
|
609
|
+
<pd-toast duration="-1">
|
|
610
|
+
${this.functionsController.callDataPromise?.func.pendingTxt}
|
|
611
|
+
</pd-toast>`;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Called when (any) cloud function stopped with errors.
|
|
616
|
+
|
|
617
|
+
// eslint-disable-next-line class-methods-use-this
|
|
618
|
+
_renderErrorInfo(error:any) {
|
|
619
|
+
return html`
|
|
620
|
+
<pd-toast isError duration="-1">
|
|
621
|
+
${error}
|
|
622
|
+
</pd-toast>`;
|
|
623
|
+
}
|
|
624
|
+
*/
|
package/src/model/spa-model.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
export const APP_CONF_EVENT = "get-app-conf";
|
|
2
2
|
|
|
3
|
+
export interface LoadingSubTask {
|
|
4
|
+
actionKey: string
|
|
5
|
+
completed: boolean,
|
|
6
|
+
loadingTxt: string,
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
export interface LoadingState {
|
|
4
10
|
isLoading: boolean,
|
|
5
11
|
actionKey: string
|
|
6
12
|
modal?: boolean,
|
|
7
13
|
smallBackground?: boolean,
|
|
8
14
|
loadingTxt?: string,
|
|
9
|
-
|
|
15
|
+
subTask?: LoadingSubTask[],
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { action, payload } from 'ts-action';
|
|
2
|
-
import { LoadingState } from '../model/spa-model.js';
|
|
2
|
+
import { LoadingState, LoadingSubTask } from '../model/spa-model.js';
|
|
3
3
|
|
|
4
4
|
export const initIndexDBSucess = action('SPA_INIT_INDEX_DB_SUCCESS');
|
|
5
5
|
export const loginSucess = action('SPA_LOGIN_SUCCESS');
|
|
@@ -9,4 +9,8 @@ export const routeAction = action('SPA_APP_ROUTE', payload<string>());
|
|
|
9
9
|
export const updateInternetOffline = action('SPA_APP_UPDATE_INTERNET_OFFLINE', payload<boolean>());
|
|
10
10
|
|
|
11
11
|
export const addLoadingState = action('SPA_APP_ADD_LOADING', payload<LoadingState>());
|
|
12
|
+
export const changeSubTask = action('SPA_APP_CHANGE_SUB_LOADING', payload<{
|
|
13
|
+
loadingActionId: string,
|
|
14
|
+
newTaskState: LoadingSubTask
|
|
15
|
+
}>());
|
|
12
16
|
export const removeLoadingState = action('SPA_APP_REMOVE_LOADING', payload<string>());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { on, reducer } from 'ts-action';
|
|
2
2
|
|
|
3
|
-
import { initIndexDBSucess, addLoadingState, loginSucess, routeAction, updateInternetOffline, removeLoadingState } from './spa-app-actions.js';
|
|
3
|
+
import { initIndexDBSucess, addLoadingState, loginSucess, routeAction, updateInternetOffline, removeLoadingState, changeSubTask } from './spa-app-actions.js';
|
|
4
4
|
import { LoadingState } from '../model/spa-model.js';
|
|
5
5
|
|
|
6
6
|
export interface SpaAppState {
|
|
@@ -35,6 +35,23 @@ export const spaAppReducer = reducer(
|
|
|
35
35
|
}
|
|
36
36
|
)),
|
|
37
37
|
|
|
38
|
+
on(changeSubTask, (state, {payload}) => (
|
|
39
|
+
{
|
|
40
|
+
...state,
|
|
41
|
+
loadingState: state.loadingState.map(ls => {
|
|
42
|
+
if (ls.actionKey === payload.loadingActionId) {
|
|
43
|
+
// change new sub task in sub task list
|
|
44
|
+
return {
|
|
45
|
+
...ls,
|
|
46
|
+
subTask: ls.subTask?.map(subLs => subLs.actionKey
|
|
47
|
+
=== payload.newTaskState.actionKey ? payload.newTaskState : subLs),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return ls;
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
)),
|
|
54
|
+
|
|
38
55
|
on(removeLoadingState, (state, {payload}) => (
|
|
39
56
|
{
|
|
40
57
|
...state,
|
|
@@ -111,3 +111,30 @@ export const ModalWithBackgroundState: Story = {
|
|
|
111
111
|
},
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
+
export const ModalStateWithSubTasks: Story = {
|
|
115
|
+
args: {
|
|
116
|
+
loadingState: {
|
|
117
|
+
isLoading: true,
|
|
118
|
+
modal: true,
|
|
119
|
+
loadingTxt: "Sammelaufgabe wird erledigt",
|
|
120
|
+
subTask: [
|
|
121
|
+
{
|
|
122
|
+
actionKey: "",
|
|
123
|
+
completed: true,
|
|
124
|
+
loadingTxt: "SubTask 1"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
actionKey: "",
|
|
128
|
+
completed: false,
|
|
129
|
+
loadingTxt: "SubTask 2"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
actionKey: "",
|
|
133
|
+
completed: false,
|
|
134
|
+
loadingTxt: "SubTask 3"
|
|
135
|
+
},
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
|
|
@@ -3,6 +3,8 @@ import { customElement, property } from 'lit/decorators.js';
|
|
|
3
3
|
import { msg } from '@lit/localize';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
|
|
6
|
+
import '@progressive-development/pd-icon/pd-icon.js';
|
|
7
|
+
|
|
6
8
|
import {LoadingState} from '../model/spa-model.js';
|
|
7
9
|
|
|
8
10
|
|
|
@@ -89,6 +91,34 @@ export class PdLoadingState extends LitElement {
|
|
|
89
91
|
animation: spin 2s linear infinite;
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
.sub-ul {
|
|
95
|
+
text-align: start;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.sub-row {
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: space-between;
|
|
102
|
+
padding-right: 10px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.sub-icon {
|
|
106
|
+
--pd-icon-size: 1rem;
|
|
107
|
+
padding: 0;
|
|
108
|
+
vertical-align: baseline;
|
|
109
|
+
margin: 0 .25rem 0 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.completed {
|
|
113
|
+
--pd-icon-stroke-col-active: green;
|
|
114
|
+
--pd-icon-col-active: green;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.loading {
|
|
118
|
+
--pd-icon-stroke-col-active: orange;
|
|
119
|
+
--pd-icon-col-active: orange;
|
|
120
|
+
}
|
|
121
|
+
|
|
92
122
|
@keyframes spin {
|
|
93
123
|
0% {
|
|
94
124
|
transform: rotate(0deg);
|
|
@@ -124,7 +154,21 @@ export class PdLoadingState extends LitElement {
|
|
|
124
154
|
})}">
|
|
125
155
|
<div class="${this.loadingState.smallBackground ? "background-loader" : "loader"}"></div>
|
|
126
156
|
<p>${this.loadingState.loadingTxt || (this.loadingState.smallBackground ?
|
|
127
|
-
msg("Daten werden synchronisiert", {id: "spaH.loadingstate.syncState"}) : msg("Bitte warten, Daten werden geladen", {id: "spaH.loadingstate.pleaseWait"}))}
|
|
157
|
+
msg("Daten werden synchronisiert", {id: "spaH.loadingstate.syncState"}) : msg("Bitte warten, Daten werden geladen", {id: "spaH.loadingstate.pleaseWait"}))}
|
|
158
|
+
</p>
|
|
159
|
+
${this.loadingState.subTask && this.loadingState.subTask.length > 0 ? html`
|
|
160
|
+
<ul class="sub-ul">
|
|
161
|
+
${this.loadingState.subTask.map(task => html`
|
|
162
|
+
<li>
|
|
163
|
+
<div class="sub-row">
|
|
164
|
+
${task.loadingTxt}
|
|
165
|
+
${task.completed ? html`<pd-icon class="sub-icon completed" icon="checkBox" activeIcon></pd-icon>`
|
|
166
|
+
: html`<pd-icon class="sub-icon loading" icon="syncIcon" activeIcon></pd-icon>`}
|
|
167
|
+
</div>
|
|
168
|
+
</li>
|
|
169
|
+
`)}
|
|
170
|
+
</ul>
|
|
171
|
+
` : ''}
|
|
128
172
|
</div>
|
|
129
173
|
`
|
|
130
174
|
}
|