@progressive-development/pd-spa-helper 0.2.4 → 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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent pd-spa-helper following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "pd-spa-helper",
6
- "version": "0.2.4",
6
+ "version": "0.2.5",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
9
9
  "exports": {
@@ -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
 
@@ -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>());
@@ -13,6 +13,9 @@ export const setRouteElement = (param: HTMLElement) => {
13
13
  routeElement = param;
14
14
  }
15
15
 
16
+ // remove loading task if all sub tasks done
17
+
18
+
16
19
  export const appRouteEffect = createEffect(
17
20
  actions$.pipe(
18
21
  ofType(routeAction),
@@ -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"}))}</p>
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
  }