@progressive-development/pd-spa-helper 0.2.3 → 0.2.5
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 +2 -1
- package/dist/src/PdSpaHelper.js.map +1 -1
- package/dist/src/model/spa-model.d.ts +7 -0
- package/dist/src/model/spa-model.js.map +1 -1
- package/dist/src/store/spa-app-actions.d.ts +24 -4
- package/dist/src/store/spa-app-actions.js +3 -1
- 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.d.ts +1 -1
- package/dist/src/store/spa-app-reducer.js +30 -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 +3 -0
- package/dist/src/stories/pd-loading-state.stories.js +55 -1
- package/dist/src/stories/pd-loading-state.stories.js.map +1 -1
- package/dist/src/tmpown/pd-loading-state.d.ts +4 -3
- package/dist/src/tmpown/pd-loading-state.js +51 -8
- 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 +3 -3
- package/src/model/spa-model.ts +11 -2
- package/src/store/spa-app-actions.ts +7 -2
- package/src/store/spa-app-effects.ts +3 -0
- package/src/store/spa-app-reducer.ts +32 -10
- package/src/stories/pd-loading-state.stories.ts +58 -1
- package/src/tmpown/pd-loading-state.ts +53 -6
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.
|
|
@@ -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,8 +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,
|
|
11
|
+
actionKey: string
|
|
5
12
|
modal?: boolean,
|
|
6
13
|
smallBackground?: boolean,
|
|
7
|
-
loadingTxt?: string
|
|
8
|
-
|
|
14
|
+
loadingTxt?: string,
|
|
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');
|
|
@@ -8,4 +8,9 @@ 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 changeSubTask = action('SPA_APP_CHANGE_SUB_LOADING', payload<{
|
|
13
|
+
loadingActionId: string,
|
|
14
|
+
newTaskState: LoadingSubTask
|
|
15
|
+
}>());
|
|
16
|
+
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, changeSubTask } 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,37 @@ 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(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
|
+
|
|
55
|
+
on(removeLoadingState, (state, {payload}) => (
|
|
56
|
+
{
|
|
57
|
+
...state,
|
|
58
|
+
loadingState: state.loadingState?.filter(a => a.actionKey !== payload)
|
|
37
59
|
}
|
|
38
60
|
)),
|
|
39
61
|
|
|
@@ -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,50 @@ 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
|
+
|
|
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
|
|
|
@@ -10,10 +12,7 @@ import {LoadingState} from '../model/spa-model.js';
|
|
|
10
12
|
export class PdLoadingState extends LitElement {
|
|
11
13
|
|
|
12
14
|
@property({ type: Object})
|
|
13
|
-
loadingState
|
|
14
|
-
isLoading: false
|
|
15
|
-
};
|
|
16
|
-
|
|
15
|
+
loadingState?: LoadingState;
|
|
17
16
|
|
|
18
17
|
static styles = [
|
|
19
18
|
css`
|
|
@@ -62,7 +61,7 @@ export class PdLoadingState extends LitElement {
|
|
|
62
61
|
bottom: 0em;
|
|
63
62
|
|
|
64
63
|
padding: 1em;
|
|
65
|
-
z-index:
|
|
64
|
+
z-index: 600; /* Sit on top */
|
|
66
65
|
|
|
67
66
|
display: flex;
|
|
68
67
|
gap: 0.5em;
|
|
@@ -92,6 +91,34 @@ export class PdLoadingState extends LitElement {
|
|
|
92
91
|
animation: spin 2s linear infinite;
|
|
93
92
|
}
|
|
94
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
|
+
|
|
95
122
|
@keyframes spin {
|
|
96
123
|
0% {
|
|
97
124
|
transform: rotate(0deg);
|
|
@@ -105,6 +132,9 @@ export class PdLoadingState extends LitElement {
|
|
|
105
132
|
] as CSSResultGroup;
|
|
106
133
|
|
|
107
134
|
render() {
|
|
135
|
+
if (!this.loadingState) {
|
|
136
|
+
return '';
|
|
137
|
+
}
|
|
108
138
|
return this.loadingState.modal ? html`
|
|
109
139
|
<div id="modalId" class="modal">
|
|
110
140
|
${this._renderContent()}
|
|
@@ -113,6 +143,9 @@ export class PdLoadingState extends LitElement {
|
|
|
113
143
|
}
|
|
114
144
|
|
|
115
145
|
_renderContent() {
|
|
146
|
+
if (!this.loadingState) {
|
|
147
|
+
return '';
|
|
148
|
+
}
|
|
116
149
|
return html`
|
|
117
150
|
<div class="${classMap({
|
|
118
151
|
content: !this.loadingState.smallBackground,
|
|
@@ -121,7 +154,21 @@ export class PdLoadingState extends LitElement {
|
|
|
121
154
|
})}">
|
|
122
155
|
<div class="${this.loadingState.smallBackground ? "background-loader" : "loader"}"></div>
|
|
123
156
|
<p>${this.loadingState.loadingTxt || (this.loadingState.smallBackground ?
|
|
124
|
-
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
|
+
` : ''}
|
|
125
172
|
</div>
|
|
126
173
|
`
|
|
127
174
|
}
|