@thzero/library_client_vue3_store_pinia 0.19.1 → 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 -119
- package/license.md +8 -8
- package/openSource.js +52 -52
- package/package.json +42 -42
- package/service/store/index.js +51 -51
- package/store/admin/news/index.js +86 -86
- package/store/admin/users/index.js +67 -67
- package/store/index.js +329 -329
- package/store/news/index.js +41 -41
- package/store/user/index.js +138 -138
|
@@ -1,86 +1,86 @@
|
|
|
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('adminNews', adminNews)
|
|
10
|
-
// The dispatchers below and the admin components both expect that key.
|
|
11
|
-
const store = {
|
|
12
|
-
state: () => ({
|
|
13
|
-
news: null
|
|
14
|
-
}),
|
|
15
|
-
actions: {
|
|
16
|
-
async createAdminNews(correlationId, item) {
|
|
17
|
-
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_NEWS);
|
|
18
|
-
const response = await service.create(correlationId, item);
|
|
19
|
-
this.$logger.debug('store.admin.news', 'createAdminNews', 'response', response, correlationId);
|
|
20
|
-
if (Response.hasSucceeded(response) && response.results) {
|
|
21
|
-
this.$logger.debug('store.admin.news', 'createAdminNews', 'items.a', response.results, correlationId);
|
|
22
|
-
this.$logger.debug('store.admin.news', 'createAdminNews', 'items.b', this.news, correlationId);
|
|
23
|
-
// the list is null until the first search
|
|
24
|
-
this.news = LibraryCommonUtility.updateArrayByObject(this.news ?? [], response.results);
|
|
25
|
-
this.$logger.debug('store.admin.news', 'createAdminNews', 'items.c', this.news, correlationId);
|
|
26
|
-
}
|
|
27
|
-
return response;
|
|
28
|
-
},
|
|
29
|
-
async deleteAdminNews(correlationId, id) {
|
|
30
|
-
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_NEWS);
|
|
31
|
-
const response = await service.delete(correlationId, id);
|
|
32
|
-
this.$logger.debug('store.admin.news', 'deleteAdminNews', 'response', response, correlationId);
|
|
33
|
-
if (Response.hasSucceeded(response)) {
|
|
34
|
-
// deleteArrayById removes in place and returns nothing; assigning its
|
|
35
|
-
// result is what emptied the list
|
|
36
|
-
LibraryCommonUtility.deleteArrayById(this.news, id);
|
|
37
|
-
// and drop it from the public news list too
|
|
38
|
-
await LibraryClientUtility.$store.dispatcher.news.delete(correlationId, id);
|
|
39
|
-
}
|
|
40
|
-
return response;
|
|
41
|
-
},
|
|
42
|
-
async searchAdminNews(correlationId, params) {
|
|
43
|
-
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_NEWS);
|
|
44
|
-
const response = await service.search(correlationId, params);
|
|
45
|
-
this.$logger.debug('store.admin.news', 'searchAdminNews', 'response', response, correlationId);
|
|
46
|
-
const list = response.success && response.results ? response.results.data : null;
|
|
47
|
-
this.$logger.debug('store.admin.news', 'searchAdminNews', 'list.a', list, correlationId);
|
|
48
|
-
this.$logger.debug('store.admin.news', 'searchAdminNews', 'list.b', this.news, correlationId);
|
|
49
|
-
this.news = list;
|
|
50
|
-
this.$logger.debug('store.admin.news', 'searchAdminNews', 'list.c', this.news, correlationId);
|
|
51
|
-
},
|
|
52
|
-
async updateAdminNews(correlationId, item) {
|
|
53
|
-
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_NEWS);
|
|
54
|
-
const response = await service.update(correlationId, item);
|
|
55
|
-
this.$logger.debug('store.admin.news', 'updateAdminNews', 'response', response, correlationId);
|
|
56
|
-
if (Response.hasSucceeded(response) && response.results) {
|
|
57
|
-
this.$logger.debug('store.admin.news', 'updateAdminNews', 'items.a', response.results, correlationId);
|
|
58
|
-
this.$logger.debug('store.admin.news', 'updateAdminNews', 'items.b', this.news, correlationId);
|
|
59
|
-
this.news = LibraryCommonUtility.updateArrayByObject(this.news ?? [], response.results);
|
|
60
|
-
this.$logger.debug('store.admin.news', 'updateAdminNews', 'items.c', this.news, correlationId);
|
|
61
|
-
}
|
|
62
|
-
return response;
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
// module actions live on $store.adminNews, not on the root $store
|
|
66
|
-
dispatcher: {
|
|
67
|
-
async createAdminNews(correlationId, item) {
|
|
68
|
-
return await LibraryClientUtility.$store.adminNews.createAdminNews(correlationId, item);
|
|
69
|
-
},
|
|
70
|
-
async deleteAdminNews(correlationId, id) {
|
|
71
|
-
return await LibraryClientUtility.$store.adminNews.deleteAdminNews(correlationId, id);
|
|
72
|
-
},
|
|
73
|
-
async searchAdminNews(correlationId, params) {
|
|
74
|
-
await LibraryClientUtility.$store.adminNews.searchAdminNews(correlationId, params);
|
|
75
|
-
},
|
|
76
|
-
// the older name for searchAdminNews
|
|
77
|
-
async searchNews(correlationId, params) {
|
|
78
|
-
await LibraryClientUtility.$store.adminNews.searchAdminNews(correlationId, params);
|
|
79
|
-
},
|
|
80
|
-
async updateAdminNews(correlationId, item) {
|
|
81
|
-
return await LibraryClientUtility.$store.adminNews.updateAdminNews(correlationId, item);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export default store;
|
|
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('adminNews', adminNews)
|
|
10
|
+
// The dispatchers below and the admin components both expect that key.
|
|
11
|
+
const store = {
|
|
12
|
+
state: () => ({
|
|
13
|
+
news: null
|
|
14
|
+
}),
|
|
15
|
+
actions: {
|
|
16
|
+
async createAdminNews(correlationId, item) {
|
|
17
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_NEWS);
|
|
18
|
+
const response = await service.create(correlationId, item);
|
|
19
|
+
this.$logger.debug('store.admin.news', 'createAdminNews', 'response', response, correlationId);
|
|
20
|
+
if (Response.hasSucceeded(response) && response.results) {
|
|
21
|
+
this.$logger.debug('store.admin.news', 'createAdminNews', 'items.a', response.results, correlationId);
|
|
22
|
+
this.$logger.debug('store.admin.news', 'createAdminNews', 'items.b', this.news, correlationId);
|
|
23
|
+
// the list is null until the first search
|
|
24
|
+
this.news = LibraryCommonUtility.updateArrayByObject(this.news ?? [], response.results);
|
|
25
|
+
this.$logger.debug('store.admin.news', 'createAdminNews', 'items.c', this.news, correlationId);
|
|
26
|
+
}
|
|
27
|
+
return response;
|
|
28
|
+
},
|
|
29
|
+
async deleteAdminNews(correlationId, id) {
|
|
30
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_NEWS);
|
|
31
|
+
const response = await service.delete(correlationId, id);
|
|
32
|
+
this.$logger.debug('store.admin.news', 'deleteAdminNews', 'response', response, correlationId);
|
|
33
|
+
if (Response.hasSucceeded(response)) {
|
|
34
|
+
// deleteArrayById removes in place and returns nothing; assigning its
|
|
35
|
+
// result is what emptied the list
|
|
36
|
+
LibraryCommonUtility.deleteArrayById(this.news, id);
|
|
37
|
+
// and drop it from the public news list too
|
|
38
|
+
await LibraryClientUtility.$store.dispatcher.news.delete(correlationId, id);
|
|
39
|
+
}
|
|
40
|
+
return response;
|
|
41
|
+
},
|
|
42
|
+
async searchAdminNews(correlationId, params) {
|
|
43
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_NEWS);
|
|
44
|
+
const response = await service.search(correlationId, params);
|
|
45
|
+
this.$logger.debug('store.admin.news', 'searchAdminNews', 'response', response, correlationId);
|
|
46
|
+
const list = response.success && response.results ? response.results.data : null;
|
|
47
|
+
this.$logger.debug('store.admin.news', 'searchAdminNews', 'list.a', list, correlationId);
|
|
48
|
+
this.$logger.debug('store.admin.news', 'searchAdminNews', 'list.b', this.news, correlationId);
|
|
49
|
+
this.news = list;
|
|
50
|
+
this.$logger.debug('store.admin.news', 'searchAdminNews', 'list.c', this.news, correlationId);
|
|
51
|
+
},
|
|
52
|
+
async updateAdminNews(correlationId, item) {
|
|
53
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ADMIN_NEWS);
|
|
54
|
+
const response = await service.update(correlationId, item);
|
|
55
|
+
this.$logger.debug('store.admin.news', 'updateAdminNews', 'response', response, correlationId);
|
|
56
|
+
if (Response.hasSucceeded(response) && response.results) {
|
|
57
|
+
this.$logger.debug('store.admin.news', 'updateAdminNews', 'items.a', response.results, correlationId);
|
|
58
|
+
this.$logger.debug('store.admin.news', 'updateAdminNews', 'items.b', this.news, correlationId);
|
|
59
|
+
this.news = LibraryCommonUtility.updateArrayByObject(this.news ?? [], response.results);
|
|
60
|
+
this.$logger.debug('store.admin.news', 'updateAdminNews', 'items.c', this.news, correlationId);
|
|
61
|
+
}
|
|
62
|
+
return response;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
// module actions live on $store.adminNews, not on the root $store
|
|
66
|
+
dispatcher: {
|
|
67
|
+
async createAdminNews(correlationId, item) {
|
|
68
|
+
return await LibraryClientUtility.$store.adminNews.createAdminNews(correlationId, item);
|
|
69
|
+
},
|
|
70
|
+
async deleteAdminNews(correlationId, id) {
|
|
71
|
+
return await LibraryClientUtility.$store.adminNews.deleteAdminNews(correlationId, id);
|
|
72
|
+
},
|
|
73
|
+
async searchAdminNews(correlationId, params) {
|
|
74
|
+
await LibraryClientUtility.$store.adminNews.searchAdminNews(correlationId, params);
|
|
75
|
+
},
|
|
76
|
+
// the older name for searchAdminNews
|
|
77
|
+
async searchNews(correlationId, params) {
|
|
78
|
+
await LibraryClientUtility.$store.adminNews.searchAdminNews(correlationId, params);
|
|
79
|
+
},
|
|
80
|
+
async updateAdminNews(correlationId, item) {
|
|
81
|
+
return await LibraryClientUtility.$store.adminNews.updateAdminNews(correlationId, item);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default store;
|
|
@@ -1,67 +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
|
-
// 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;
|
|
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;
|