@thzero/library_client_vue3_store_pinia 0.18.35 → 0.18.36

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.
@@ -1,43 +1,43 @@
1
- import LibraryClientConstants from '@thzero/library_client/constants';
2
-
3
- import LibraryClientUtility from '@thzero/library_client/utility/index';
4
-
5
- const store = {
6
- pluginPersistPaths: {
7
- persist: [
8
- 'news'
9
- ]
10
- },
11
- state: () => ({
12
- latest: null
13
- }),
14
- actions: {
15
- async getLatestNews(correlationId) {
16
- const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_NEWS);
17
- const response = await service.latest(correlationId);
18
- this.$logger.debug('store.news', 'getLatestNews', 'response', response);
19
- // commit('setLatestNews', { correlationId: correlationId, latest: response.success && response.results ? response.results.data : null });
20
- const latest = response.success && response.results ? response.results.data : null;
21
- this.$logger.debug('store.news', 'setLatest', 'item.a', latest, correlationId);
22
- this.$logger.debug('store.news', 'setLatest', 'item.b', this.latest, correlationId);
23
- this.latest = latest;
24
- this.$logger.debug('store.news', 'setLatest', 'item.c', this.latest, correlationId);
25
- }
26
- },
27
- mutations: {
28
- // setLatestNews(state, params) {
29
- // this.$logger.debug('store.news', 'setLatest', 'item.a', params.latest, params.correlationId);
30
- // this.$logger.debug('store.news', 'setLatest', 'item.b', state.latest, params.correlationId);
31
- // state.latest = params.latest;
32
- // this.$logger.debug('store.news', 'setLatest', 'item.c', state.latest, params.correlationId);
33
- // }
34
- },
35
- dispatcher: {
36
- async getLatest(correlationId) {
37
- // await LibraryClientUtility.$store.dispatch('getLatestNews', correlationId);
38
- await LibraryClientUtility.$store.news.getLatestNews(correlationId);
39
- }
40
- }
41
- };
42
-
43
- export default store;
1
+ import LibraryClientConstants from '@thzero/library_client/constants';
2
+
3
+ import LibraryClientUtility from '@thzero/library_client/utility/index';
4
+
5
+ const store = {
6
+ pluginPersistPaths: {
7
+ persist: [
8
+ 'news'
9
+ ]
10
+ },
11
+ state: () => ({
12
+ latest: null
13
+ }),
14
+ actions: {
15
+ async getLatestNews(correlationId) {
16
+ const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_NEWS);
17
+ const response = await service.latest(correlationId);
18
+ this.$logger.debug('store.news', 'getLatestNews', 'response', response);
19
+ // commit('setLatestNews', { correlationId: correlationId, latest: response.success && response.results ? response.results.data : null });
20
+ const latest = response.success && response.results ? response.results.data : null;
21
+ this.$logger.debug('store.news', 'setLatest', 'item.a', latest, correlationId);
22
+ this.$logger.debug('store.news', 'setLatest', 'item.b', this.latest, correlationId);
23
+ this.latest = latest;
24
+ this.$logger.debug('store.news', 'setLatest', 'item.c', this.latest, correlationId);
25
+ }
26
+ },
27
+ mutations: {
28
+ // setLatestNews(state, params) {
29
+ // this.$logger.debug('store.news', 'setLatest', 'item.a', params.latest, params.correlationId);
30
+ // this.$logger.debug('store.news', 'setLatest', 'item.b', state.latest, params.correlationId);
31
+ // state.latest = params.latest;
32
+ // this.$logger.debug('store.news', 'setLatest', 'item.c', state.latest, params.correlationId);
33
+ // }
34
+ },
35
+ dispatcher: {
36
+ async getLatest(correlationId) {
37
+ // await LibraryClientUtility.$store.dispatch('getLatestNews', correlationId);
38
+ await LibraryClientUtility.$store.news.getLatestNews(correlationId);
39
+ }
40
+ }
41
+ };
42
+
43
+ export default store;
@@ -1,135 +1,135 @@
1
- import LibraryClientConstants from '@thzero/library_client/constants';
2
-
3
- import LibraryClientUtility from '@thzero/library_client/utility/index';
4
- import LibraryClientVueUtility from '@thzero/library_client_vue3/utility';
5
-
6
- import Response from '@thzero/library_common/response';
7
-
8
- const store = {
9
- pluginPersistPaths: {
10
- persist: [
11
- 'settings',
12
- 'user'
13
- ]
14
- },
15
- state: () => ({
16
- authCompleted: false,
17
- claims: null,
18
- isLoggedIn: false,
19
- settings: {},
20
- theme: 'defaultTheme',
21
- token: null,
22
- tokenResult: null,
23
- user: null
24
- }),
25
- actions: {
26
- async refreshUserSettings(correlationId) {
27
- const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_USER);
28
- const response = await service.refreshSettings(correlationId, this.user);
29
- this.$logger.debug('store.user', 'refreshUserSettings', 'response', response);
30
- if (Response.hasSucceeded(response) && response.results)
31
- this.setUser(response.results);
32
- return response;
33
- },
34
- async resetUser(correlationId) {
35
- this.$patch({
36
- claims: null,
37
- isLoggedIn: false,
38
- token: null,
39
- tokenResult: null,
40
- settings: {},
41
- user: null
42
- });
43
- },
44
- async setUser(correlationId, user) {
45
- if (user) {
46
- this.settings = LibraryClientVueUtility.settings().mergeUser(correlationId, user.settings);
47
- delete user.settings;
48
- }
49
- this.user = user;
50
- },
51
- async setUserAuthCompleted(correlationId, authCompleted) {
52
- this.authCompleted = authCompleted;
53
- },
54
- async setUserClaims(correlationId, claims) {
55
- this.claims = claims;
56
- },
57
- async setUserLoggedIn(correlationId, isLoggedIn) {
58
- this.isLoggedIn = isLoggedIn;
59
- },
60
- async setUserSettings(correlationId, settings) {
61
- const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_USER);
62
- settings = LibraryClientVueUtility.settings().mergeUser(correlationId, settings);
63
- if (this.isLoggedIn) {
64
- const response = await service.updateSettings(correlationId, this.user, settings);
65
- this.$logger.debug('store.user', 'setUserSettings', 'response', response);
66
- if (Response.hasSucceeded(response) && response.results) {
67
- // this.settings = response.results.settings;
68
- // delete response.results.settings;
69
- // this.user = response.results;
70
- // response.results = this.settings;
71
- this.setUser(correlationId, response.results);
72
- response.results = this.settings;
73
- }
74
- return response;
75
- }
76
- this.settings = LibraryClientVueUtility.settings().mergeUser(correlationId, settings);
77
- return Response.success(correlationId, this.settings);
78
- },
79
- async setUserTheme(correlationId, isLoggedIn) {
80
- this.theme = theme;
81
- },
82
- async setUserTokenResult(correlationId, tokenResult) {
83
- this.$patch({
84
- tokenResult: null,
85
- token: tokenResult ? tokenResult.token : null
86
- });
87
- }
88
- },
89
- getters: {
90
- getUser (correlationId) {
91
- return LibraryClientUtility.$store.user.user;
92
- },
93
- getUserTheme (correlationId) {
94
- return LibraryClientUtility.$store.theme;
95
- },
96
- getUserSettings(correlationId) {
97
- if (LibraryClientUtility.$store.user.settings) // TODO: userRef
98
- return LibraryClientUtility.$store.user.settings;
99
-
100
- const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_USER);
101
- return service.initializeSettings();
102
- }
103
- },
104
- dispatcher: {
105
- async refreshUserSettings(correlationId) {
106
- return await LibraryClientUtility.$store.user.refreshUserSettings(correlationId);
107
- },
108
- async resetUser(correlationId) {
109
- await LibraryClientUtility.$store.user.resetUser(correlationId);
110
- },
111
- async setUserAuthCompleted(correlationId, authCompleted) {
112
- await LibraryClientUtility.$store.user.setUserAuthCompleted(correlationId, authCompleted);
113
- },
114
- async setUserClaims(correlationId, claims) {
115
- await LibraryClientUtility.$store.user.setUserClaims(correlationId, claims);
116
- },
117
- async setUserLoggedIn(correlationId, isLoggedIn) {
118
- await LibraryClientUtility.$store.user.setUserLoggedIn(correlationId, isLoggedIn);
119
- },
120
- async setUserSettings(correlationId, settings) {
121
- return await LibraryClientUtility.$store.user.setUserSettings(correlationId, settings);
122
- },
123
- async setUserTheme(correlationId, theme) {
124
- await LibraryClientUtility.$store.user.setUserTheme(correlationId, theme);
125
- },
126
- async setUserTokenResult(correlationId, tokenResult) {
127
- await LibraryClientUtility.$store.user.setUserTokenResult(correlationId, tokenResult);
128
- },
129
- async setUser(correlationId, user) {
130
- await LibraryClientUtility.$store.user.setUser(correlationId, user);
131
- }
132
- }
133
- };
134
-
135
- export default store;
1
+ import LibraryClientConstants from '@thzero/library_client/constants';
2
+
3
+ import LibraryClientUtility from '@thzero/library_client/utility/index';
4
+ import LibraryClientVueUtility from '@thzero/library_client_vue3/utility';
5
+
6
+ import Response from '@thzero/library_common/response';
7
+
8
+ const store = {
9
+ pluginPersistPaths: {
10
+ persist: [
11
+ 'settings',
12
+ 'user'
13
+ ]
14
+ },
15
+ state: () => ({
16
+ authCompleted: false,
17
+ claims: null,
18
+ isLoggedIn: false,
19
+ settings: {},
20
+ theme: 'defaultTheme',
21
+ token: null,
22
+ tokenResult: null,
23
+ user: null
24
+ }),
25
+ actions: {
26
+ async refreshUserSettings(correlationId) {
27
+ const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_USER);
28
+ const response = await service.refreshSettings(correlationId, this.user);
29
+ this.$logger.debug('store.user', 'refreshUserSettings', 'response', response);
30
+ if (Response.hasSucceeded(response) && response.results)
31
+ this.setUser(response.results);
32
+ return response;
33
+ },
34
+ async resetUser(correlationId) {
35
+ this.$patch({
36
+ claims: null,
37
+ isLoggedIn: false,
38
+ token: null,
39
+ tokenResult: null,
40
+ settings: {},
41
+ user: null
42
+ });
43
+ },
44
+ async setUser(correlationId, user) {
45
+ if (user) {
46
+ this.settings = LibraryClientVueUtility.settings().mergeUser(correlationId, user.settings);
47
+ delete user.settings;
48
+ }
49
+ this.user = user;
50
+ },
51
+ async setUserAuthCompleted(correlationId, authCompleted) {
52
+ this.authCompleted = authCompleted;
53
+ },
54
+ async setUserClaims(correlationId, claims) {
55
+ this.claims = claims;
56
+ },
57
+ async setUserLoggedIn(correlationId, isLoggedIn) {
58
+ this.isLoggedIn = isLoggedIn;
59
+ },
60
+ async setUserSettings(correlationId, settings) {
61
+ const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_USER);
62
+ settings = LibraryClientVueUtility.settings().mergeUser(correlationId, settings);
63
+ if (this.isLoggedIn) {
64
+ const response = await service.updateSettings(correlationId, this.user, settings);
65
+ this.$logger.debug('store.user', 'setUserSettings', 'response', response);
66
+ if (Response.hasSucceeded(response) && response.results) {
67
+ // this.settings = response.results.settings;
68
+ // delete response.results.settings;
69
+ // this.user = response.results;
70
+ // response.results = this.settings;
71
+ this.setUser(correlationId, response.results);
72
+ response.results = this.settings;
73
+ }
74
+ return response;
75
+ }
76
+ this.settings = LibraryClientVueUtility.settings().mergeUser(correlationId, settings);
77
+ return Response.success(correlationId, this.settings);
78
+ },
79
+ async setUserTheme(correlationId, isLoggedIn) {
80
+ this.theme = theme;
81
+ },
82
+ async setUserTokenResult(correlationId, tokenResult) {
83
+ this.$patch({
84
+ tokenResult: null,
85
+ token: tokenResult ? tokenResult.token : null
86
+ });
87
+ }
88
+ },
89
+ getters: {
90
+ getUser (correlationId) {
91
+ return LibraryClientUtility.$store.user.user;
92
+ },
93
+ getUserTheme (correlationId) {
94
+ return LibraryClientUtility.$store.theme;
95
+ },
96
+ getUserSettings(correlationId) {
97
+ if (LibraryClientUtility.$store.user.settings) // TODO: userRef
98
+ return LibraryClientUtility.$store.user.settings;
99
+
100
+ const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_USER);
101
+ return service.initializeSettings();
102
+ }
103
+ },
104
+ dispatcher: {
105
+ async refreshUserSettings(correlationId) {
106
+ return await LibraryClientUtility.$store.user.refreshUserSettings(correlationId);
107
+ },
108
+ async resetUser(correlationId) {
109
+ await LibraryClientUtility.$store.user.resetUser(correlationId);
110
+ },
111
+ async setUserAuthCompleted(correlationId, authCompleted) {
112
+ await LibraryClientUtility.$store.user.setUserAuthCompleted(correlationId, authCompleted);
113
+ },
114
+ async setUserClaims(correlationId, claims) {
115
+ await LibraryClientUtility.$store.user.setUserClaims(correlationId, claims);
116
+ },
117
+ async setUserLoggedIn(correlationId, isLoggedIn) {
118
+ await LibraryClientUtility.$store.user.setUserLoggedIn(correlationId, isLoggedIn);
119
+ },
120
+ async setUserSettings(correlationId, settings) {
121
+ return await LibraryClientUtility.$store.user.setUserSettings(correlationId, settings);
122
+ },
123
+ async setUserTheme(correlationId, theme) {
124
+ await LibraryClientUtility.$store.user.setUserTheme(correlationId, theme);
125
+ },
126
+ async setUserTokenResult(correlationId, tokenResult) {
127
+ await LibraryClientUtility.$store.user.setUserTokenResult(correlationId, tokenResult);
128
+ },
129
+ async setUser(correlationId, user) {
130
+ await LibraryClientUtility.$store.user.setUser(correlationId, user);
131
+ }
132
+ }
133
+ };
134
+
135
+ export default store;