@thzero/library_client_vue3_store_pinia 0.18.39 → 0.19.2
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/README.md +119 -17
- package/license.md +8 -8
- package/openSource.js +52 -52
- package/package.json +42 -33
- package/service/store/index.js +51 -51
- package/store/admin/news/index.js +86 -76
- package/store/admin/users/index.js +67 -63
- package/store/index.js +329 -324
- package/store/news/index.js +41 -43
- package/store/user/index.js +138 -135
|
@@ -1,63 +1,67 @@
|
|
|
1
|
-
import LibraryClientConstants from '@thzero/library_client/constants';
|
|
2
|
-
|
|
3
|
-
import LibraryClientUtility from '@thzero/library_client/utility/index';
|
|
4
|
-
import LibraryCommonUtility from '@thzero/library_common/utility';
|
|
5
|
-
|
|
6
|
-
import Response from '@thzero/library_common/response';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.users
|
|
33
|
-
this.$logger.debug('store.admin.users', '
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.$logger.debug('store.admin.users', '
|
|
44
|
-
this.users
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
import LibraryClientConstants from '@thzero/library_client/constants';
|
|
2
|
+
|
|
3
|
+
import LibraryClientUtility from '@thzero/library_client/utility/index';
|
|
4
|
+
import LibraryCommonUtility from '@thzero/library_common/utility';
|
|
5
|
+
|
|
6
|
+
import Response from '@thzero/library_common/response';
|
|
7
|
+
|
|
8
|
+
// An optional module: an app registers it from its store's _initModules as
|
|
9
|
+
// addModule('adminUsers', adminUsers)
|
|
10
|
+
// The dispatchers below and the admin components both expect that key.
|
|
11
|
+
const store = {
|
|
12
|
+
state: () => ({
|
|
13
|
+
users: null
|
|
14
|
+
}),
|
|
15
|
+
actions: {
|
|
16
|
+
async deleteAdminUser(correlationId, id) {
|
|
17
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_USERS);
|
|
18
|
+
const response = await service.delete(correlationId, id);
|
|
19
|
+
this.$logger.debug('store.admin.users', 'deleteAdminUser', 'response', response, correlationId);
|
|
20
|
+
// deleteArrayById removes in place and returns nothing; assigning its
|
|
21
|
+
// result is what emptied the list
|
|
22
|
+
if (Response.hasSucceeded(response))
|
|
23
|
+
LibraryCommonUtility.deleteArrayById(this.users, id);
|
|
24
|
+
return response;
|
|
25
|
+
},
|
|
26
|
+
async searchAdminUsers(correlationId, params) {
|
|
27
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_USERS);
|
|
28
|
+
const response = await service.search(correlationId, params);
|
|
29
|
+
this.$logger.debug('store.admin.users', 'searchAdminUsers', 'response', response, correlationId);
|
|
30
|
+
if (Response.hasSucceeded(response)) {
|
|
31
|
+
const list = response.success && response.results ? response.results.data : null;
|
|
32
|
+
this.$logger.debug('store.admin.users', 'searchAdminUsers', 'list.a', list, correlationId);
|
|
33
|
+
this.$logger.debug('store.admin.users', 'searchAdminUsers', 'list.b', this.users, correlationId);
|
|
34
|
+
this.users = list;
|
|
35
|
+
this.$logger.debug('store.admin.users', 'searchAdminUsers', 'list.c', this.users, correlationId);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
async updateAdminUser(correlationId, item) {
|
|
39
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_USERS);
|
|
40
|
+
const response = await service.update(correlationId, item);
|
|
41
|
+
this.$logger.debug('store.admin.users', 'updateAdminUser', 'response', response, correlationId);
|
|
42
|
+
if (Response.hasSucceeded(response) && response.results) {
|
|
43
|
+
this.$logger.debug('store.admin.users', 'updateAdminUser', 'items.a', response.results, correlationId);
|
|
44
|
+
this.$logger.debug('store.admin.users', 'updateAdminUser', 'items.b', this.users, correlationId);
|
|
45
|
+
// updateArrayById takes (array, id, object); called with two arguments
|
|
46
|
+
// it put the item in the id slot and appended undefined
|
|
47
|
+
this.users = LibraryCommonUtility.updateArrayByObject(this.users ?? [], response.results);
|
|
48
|
+
this.$logger.debug('store.admin.users', 'updateAdminUser', 'items.c', this.users, correlationId);
|
|
49
|
+
}
|
|
50
|
+
return response;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
// module actions live on $store.adminUsers, not on the root $store
|
|
54
|
+
dispatcher: {
|
|
55
|
+
async deleteAdminUser(correlationId, id) {
|
|
56
|
+
return await LibraryClientUtility.$store.adminUsers.deleteAdminUser(correlationId, id);
|
|
57
|
+
},
|
|
58
|
+
async searchAdminUsers(correlationId, params) {
|
|
59
|
+
await LibraryClientUtility.$store.adminUsers.searchAdminUsers(correlationId, params);
|
|
60
|
+
},
|
|
61
|
+
async updateAdminUser(correlationId, item) {
|
|
62
|
+
return await LibraryClientUtility.$store.adminUsers.updateAdminUser(correlationId, item);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default store;
|