@genesislcap/foundation-entity-management 11.3.0
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 +266 -0
- package/dist/dts/entities/entities.d.ts +550 -0
- package/dist/dts/entities/entities.d.ts.map +1 -0
- package/dist/dts/entities/entities.styles.d.ts +10 -0
- package/dist/dts/entities/entities.styles.d.ts.map +1 -0
- package/dist/dts/entities/entities.template.d.ts +7 -0
- package/dist/dts/entities/entities.template.d.ts.map +1 -0
- package/dist/dts/entities/index.d.ts +4 -0
- package/dist/dts/entities/index.d.ts.map +1 -0
- package/dist/dts/index.d.ts +5 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/index.federated.d.ts +1 -0
- package/dist/dts/index.federated.d.ts.map +1 -0
- package/dist/dts/list/index.d.ts +2 -0
- package/dist/dts/list/index.d.ts.map +1 -0
- package/dist/dts/list/list.d.ts +29 -0
- package/dist/dts/list/list.d.ts.map +1 -0
- package/dist/dts/list/list.styles.d.ts +2 -0
- package/dist/dts/list/list.styles.d.ts.map +1 -0
- package/dist/dts/list/list.template.d.ts +26 -0
- package/dist/dts/list/list.template.d.ts.map +1 -0
- package/dist/dts/profiles/editProfileSchema.d.ts +19 -0
- package/dist/dts/profiles/editProfileSchema.d.ts.map +1 -0
- package/dist/dts/profiles/profiles.d.ts +43 -0
- package/dist/dts/profiles/profiles.d.ts.map +1 -0
- package/dist/dts/types.d.ts +3 -0
- package/dist/dts/types.d.ts.map +1 -0
- package/dist/dts/users/users.d.ts +566 -0
- package/dist/dts/users/users.d.ts.map +1 -0
- package/dist/dts/users/users.template.d.ts +3 -0
- package/dist/dts/users/users.template.d.ts.map +1 -0
- package/dist/dts/utils/formatting.d.ts +7 -0
- package/dist/dts/utils/formatting.d.ts.map +1 -0
- package/dist/dts/utils/index.d.ts +2 -0
- package/dist/dts/utils/index.d.ts.map +1 -0
- package/dist/esm/entities/entities.js +296 -0
- package/dist/esm/entities/entities.styles.js +29 -0
- package/dist/esm/entities/entities.template.js +43 -0
- package/dist/esm/entities/index.js +3 -0
- package/dist/esm/index.federated.js +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/list/index.js +1 -0
- package/dist/esm/list/list.js +111 -0
- package/dist/esm/list/list.styles.js +27 -0
- package/dist/esm/list/list.template.js +77 -0
- package/dist/esm/profiles/editProfileSchema.js +40 -0
- package/dist/esm/profiles/profiles.js +88 -0
- package/dist/esm/types.js +3 -0
- package/dist/esm/users/users.js +302 -0
- package/dist/esm/users/users.template.js +90 -0
- package/dist/esm/utils/formatting.js +6 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/foundation-entity-management.api.json +1727 -0
- package/dist/foundation-entity-management.d.ts +1172 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/docs/.gitattributes +2 -0
- package/docs/api/foundation-entity-management.datasourceconfiguration.md +29 -0
- package/docs/api/foundation-entity-management.entitymanagement.closemodal.md +15 -0
- package/docs/api/foundation-entity-management.entitymanagement.columns.md +13 -0
- package/docs/api/foundation-entity-management.entitymanagement.connect.md +18 -0
- package/docs/api/foundation-entity-management.entitymanagement.createevent.md +13 -0
- package/docs/api/foundation-entity-management.entitymanagement.createformuischema.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.datasourceconfig.md +18 -0
- package/docs/api/foundation-entity-management.entitymanagement.deepclone.md +17 -0
- package/docs/api/foundation-entity-management.entitymanagement.deleteevent.md +13 -0
- package/docs/api/foundation-entity-management.entitymanagement.editdialogtitle.md +13 -0
- package/docs/api/foundation-entity-management.entitymanagement.editedentity.md +13 -0
- package/docs/api/foundation-entity-management.entitymanagement.editentitymodal.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.editmodalvisible.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.editmodalvisiblechanged.md +15 -0
- package/docs/api/foundation-entity-management.entitymanagement.enablecellflashing.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.enablefilterbar.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.entitylabel.md +13 -0
- package/docs/api/foundation-entity-management.entitymanagement.errornotify.md +24 -0
- package/docs/api/foundation-entity-management.entitymanagement.formuischema.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.md +74 -0
- package/docs/api/foundation-entity-management.entitymanagement.persistcolumnstatekey.md +18 -0
- package/docs/api/foundation-entity-management.entitymanagement.readevent.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.readeventfn.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.readonly.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.resourcename.md +13 -0
- package/docs/api/foundation-entity-management.entitymanagement.selectedentity.md +18 -0
- package/docs/api/foundation-entity-management.entitymanagement.sizecolumnstofit.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.submitentitychanges.md +24 -0
- package/docs/api/foundation-entity-management.entitymanagement.submitting.md +11 -0
- package/docs/api/foundation-entity-management.entitymanagement.title.md +13 -0
- package/docs/api/foundation-entity-management.entitymanagement.updateevent.md +13 -0
- package/docs/api/foundation-entity-management.entitymanagement.updateformuischema.md +11 -0
- package/docs/api/foundation-entity-management.geterrorformat.md +13 -0
- package/docs/api/foundation-entity-management.md +27 -0
- package/docs/api/foundation-entity-management.profiles._constructor_.md +13 -0
- package/docs/api/foundation-entity-management.profiles.deleteentity.md +22 -0
- package/docs/api/foundation-entity-management.profiles.md +40 -0
- package/docs/api/foundation-entity-management.profiles.readprofiledata.md +26 -0
- package/docs/api/foundation-entity-management.users._constructor_.md +13 -0
- package/docs/api/foundation-entity-management.users.additionalcreatefields.md +11 -0
- package/docs/api/foundation-entity-management.users.additionalupdatefields.md +11 -0
- package/docs/api/foundation-entity-management.users.allaccesstype.md +11 -0
- package/docs/api/foundation-entity-management.users.columns.md +13 -0
- package/docs/api/foundation-entity-management.users.connectedcallback.md +15 -0
- package/docs/api/foundation-entity-management.users.createevent.md +13 -0
- package/docs/api/foundation-entity-management.users.deepclone.md +15 -0
- package/docs/api/foundation-entity-management.users.deleteevent.md +13 -0
- package/docs/api/foundation-entity-management.users.md +69 -0
- package/docs/api/foundation-entity-management.users.updateevent.md +13 -0
- package/docs/api/foundation-entity-management.userscolumnconfig.md +35 -0
- package/docs/api/index.md +12 -0
- package/docs/api-report.md +200 -0
- package/docs/img/foundation-entity-management-form.png +0 -0
- package/docs/img/foundation-entity-management-grid.png +0 -0
- package/docs/img/foundation-profile-management.png +0 -0
- package/docs/img/foundation-user-management.png +0 -0
- package/license.txt +46 -0
- package/package.json +123 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { __awaiter, __decorate } from "tslib";
|
|
2
|
+
import { Auth } from '@genesislcap/foundation-comms';
|
|
3
|
+
import { customElement } from '@microsoft/fast-element';
|
|
4
|
+
import { EntityManagement, styles, template } from '../entities';
|
|
5
|
+
import { editProfileFormSchema } from './editProfileSchema';
|
|
6
|
+
/**
|
|
7
|
+
* Main class which defined the profile management functionality
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
*
|
|
11
|
+
* Under the hood the profile-management is the entity-management micro-frontend configured for use
|
|
12
|
+
* with the `ALL_PROFILES` resource.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* You can use this class by forward declaring it in the template file where it is used, and then using
|
|
19
|
+
* it in a html template. It is recommended to wrap it in an error boundary.
|
|
20
|
+
* ```javascript
|
|
21
|
+
* <profile-management></profile-management>
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
let Profiles = class Profiles extends EntityManagement {
|
|
26
|
+
/**
|
|
27
|
+
* Constructor will set the {@link EntityManagement.createEvent} {@link EntityManagement.deleteEvent} {@link EntityManagement.updateEvent} to match the permissions set from the server
|
|
28
|
+
*/
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
this.createEvent = this.auth.currentUser.hasPermission('INSERT_PROFILE')
|
|
32
|
+
? 'EVENT_INSERT_PROFILE'
|
|
33
|
+
: '';
|
|
34
|
+
this.deleteEvent = this.auth.currentUser.hasPermission('DELETE_PROFILE')
|
|
35
|
+
? 'EVENT_DELETE_PROFILE'
|
|
36
|
+
: '';
|
|
37
|
+
this.updateEvent = this.auth.currentUser.hasPermission('AMEND_PROFILE')
|
|
38
|
+
? 'EVENT_AMEND_PROFILE'
|
|
39
|
+
: '';
|
|
40
|
+
this.persistColumnStateKey = 'entity_profiles_management';
|
|
41
|
+
this.updateFormUiSchema = editProfileFormSchema;
|
|
42
|
+
this.createFormUiSchema = editProfileFormSchema;
|
|
43
|
+
this.readEventFn = this.readProfileData.bind(this);
|
|
44
|
+
this.resourceName = 'ALL_PROFILES';
|
|
45
|
+
this.title = 'Profile Management';
|
|
46
|
+
this.entityLabel = 'Profile';
|
|
47
|
+
}
|
|
48
|
+
readProfileData(profile) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const selectedRightsReq = yield this.connect.request('PROFILE_RIGHT', {
|
|
51
|
+
REQUEST: {
|
|
52
|
+
PROFILE_NAME: profile.PROFILE_NAME,
|
|
53
|
+
RIGHT_CODE: '*',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const selectedUsersReq = yield this.connect.request('PROFILE_USER', {
|
|
57
|
+
REQUEST: {
|
|
58
|
+
PROFILE_NAME: profile.PROFILE_NAME,
|
|
59
|
+
USER_NAME: '*',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
RIGHT_CODES: selectedRightsReq.REPLY.map((v) => v.RIGHT_CODE),
|
|
64
|
+
USER_NAMES: Array.from(new Set(selectedUsersReq.REPLY.map((v) => v.USER_NAME))),
|
|
65
|
+
NAME: profile.PROFILE_NAME,
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
deleteEntity(e) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const deleteReq = yield this.connect.commitEvent(this.deleteEvent, {
|
|
72
|
+
DETAILS: { NAME: e.detail.PROFILE_NAME },
|
|
73
|
+
});
|
|
74
|
+
this.errorNotify(deleteReq);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
__decorate([
|
|
79
|
+
Auth
|
|
80
|
+
], Profiles.prototype, "auth", void 0);
|
|
81
|
+
Profiles = __decorate([
|
|
82
|
+
customElement({
|
|
83
|
+
name: 'profile-management',
|
|
84
|
+
template,
|
|
85
|
+
styles,
|
|
86
|
+
})
|
|
87
|
+
], Profiles);
|
|
88
|
+
export { Profiles };
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { __awaiter, __decorate } from "tslib";
|
|
2
|
+
import { Auth, Connect } from '@genesislcap/foundation-comms';
|
|
3
|
+
import { ErrorBoundaryEvent, getErrorBuilder, getNotificationBuilder, } from '@genesislcap/foundation-errors';
|
|
4
|
+
import { LifecycleMixin } from '@genesislcap/foundation-utils';
|
|
5
|
+
import { GridProRendererTypes } from '@genesislcap/grid-pro';
|
|
6
|
+
import { attr, css, customElement, FASTElement, observable } from '@microsoft/fast-element';
|
|
7
|
+
import { logger } from '../entities';
|
|
8
|
+
import { getErrorFormat } from '../utils';
|
|
9
|
+
import { UsersTemplate } from './users.template';
|
|
10
|
+
const defaultColumnConfig = {
|
|
11
|
+
enableCellChangeFlash: true,
|
|
12
|
+
enableRowGroup: false,
|
|
13
|
+
enablePivot: true,
|
|
14
|
+
enableValue: true,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Defines the default columns which are present on the user management component
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
*
|
|
21
|
+
* This is exported so you can override and mix-in custom columns along with the default
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export const UsersColumnConfig = [
|
|
25
|
+
Object.assign(Object.assign({}, defaultColumnConfig), { field: 'USER_NAME', headerName: 'Username' }),
|
|
26
|
+
Object.assign(Object.assign({}, defaultColumnConfig), { field: 'FIRST_NAME', headerName: 'First Name' }),
|
|
27
|
+
Object.assign(Object.assign({}, defaultColumnConfig), { field: 'LAST_NAME', headerName: 'Last Name' }),
|
|
28
|
+
Object.assign(Object.assign({}, defaultColumnConfig), { field: 'EMAIL_ADDRESS', headerName: 'Email' }),
|
|
29
|
+
Object.assign(Object.assign({}, defaultColumnConfig), { field: 'LAST_LOGIN', headerName: 'Last Login', valueFormatter: ({ value }) => value
|
|
30
|
+
? new Intl.DateTimeFormat('default', {
|
|
31
|
+
year: 'numeric',
|
|
32
|
+
month: 'numeric',
|
|
33
|
+
day: 'numeric',
|
|
34
|
+
hour: 'numeric',
|
|
35
|
+
minute: 'numeric',
|
|
36
|
+
}).format(value)
|
|
37
|
+
: '' }),
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Main class which defines the user management functionality
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
*
|
|
44
|
+
* Under the hood the user-management is the entity-management micro-frontend configured for use
|
|
45
|
+
* with the `ALL_USERS` resource.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
*
|
|
51
|
+
* With no customisation required the user management micro-frontend can simply be dropped into the
|
|
52
|
+
* template as shown. However, it is advised to wrap it in an error boundary component.
|
|
53
|
+
* ```javascript
|
|
54
|
+
* <user-management></user-management>
|
|
55
|
+
* ```
|
|
56
|
+
* With this default example above the columns will be the {@link UsersColumnConfig} as well as the
|
|
57
|
+
* entity and status columns. The entity and status
|
|
58
|
+
* columns are always added regardless of the other columns which are configured.
|
|
59
|
+
*
|
|
60
|
+
* You can add in additional customisation options. For example you can define a custom column and
|
|
61
|
+
* then mix-in with the standard columns
|
|
62
|
+
* ```javascript
|
|
63
|
+
* import { Users, UsersColumnConfig, } from '@genesislcap/foundation-entity-management';
|
|
64
|
+
*
|
|
65
|
+
* const userColumns = [
|
|
66
|
+
* {
|
|
67
|
+
* field: 'ACCESS_TYPE',
|
|
68
|
+
* headerName: 'Access Type',
|
|
69
|
+
* },
|
|
70
|
+
* ];
|
|
71
|
+
*
|
|
72
|
+
* // Definition inside of the html template
|
|
73
|
+
* <user-management :columns=${() => [...UsersColumnConfig, ...userColumns]}></user-management>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
let Users = class Users extends LifecycleMixin(FASTElement) {
|
|
77
|
+
/**
|
|
78
|
+
* Returns a configuration for an optional status column
|
|
79
|
+
*
|
|
80
|
+
* @returns Column configuration for an optional status column
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
statusColumn() {
|
|
84
|
+
return Object.assign(Object.assign({}, defaultColumnConfig), { headerName: 'Status', field: 'STATUS', minWidth: 135, width: 135, suppressSizeToFit: true, cellRendererSelector: this.statusRendererSelector.bind(this) });
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns the config for an entity column if the entityID attribute is defined
|
|
88
|
+
*
|
|
89
|
+
* @returns Config for an entity column if the entityID is defined, else an empty array
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
entityColumn() {
|
|
93
|
+
return this.entityID
|
|
94
|
+
? [
|
|
95
|
+
Object.assign(Object.assign({}, defaultColumnConfig), { headerName: this.entityLabel, field: this.entityID }),
|
|
96
|
+
]
|
|
97
|
+
: [];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Constructor will set the {@link Users.createEvent} {@link Users.deleteEvent} {@link Users.updateEvent} to match the permissions set from the server
|
|
101
|
+
*/
|
|
102
|
+
constructor() {
|
|
103
|
+
super();
|
|
104
|
+
/**
|
|
105
|
+
* Configuring the resourceName from the entity-management, set to manage the users resource specifically
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
this.resourceName = 'ALL_USERS';
|
|
109
|
+
/**
|
|
110
|
+
* Column definition, default to the UsersColumnConfig
|
|
111
|
+
*/
|
|
112
|
+
this.columns = UsersColumnConfig;
|
|
113
|
+
this.additionalCreateFields = [];
|
|
114
|
+
this.additionalUpdateFields = [];
|
|
115
|
+
/**
|
|
116
|
+
* entityID used to control the definition of an optional entity column which is created with the {@link Users.entityColumn} function.
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
this.entityID = 'COUNTERPARTY_ID';
|
|
120
|
+
/**
|
|
121
|
+
* entityID used to display label from the selector of entityID {@link Users.entityColumn} function.
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
this.entityLabelKey = 'NAME';
|
|
125
|
+
/**
|
|
126
|
+
* entityID used to control the definition of an optional entity column which is created with the {@link Users.entityColumn} function.
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
this.entityLabel = 'Counterparty';
|
|
130
|
+
/**
|
|
131
|
+
* Definition of the `DATASERVER` query which is used when managing Counterpartys
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
this.availableEntitiesEndpoint = 'ALL_COUNTERPARTYS';
|
|
135
|
+
this.createEvent = this.auth.currentUser.hasPermission('INSERT_USER')
|
|
136
|
+
? 'EVENT_INSERT_USER'
|
|
137
|
+
: '';
|
|
138
|
+
this.deleteEvent = this.auth.currentUser.hasPermission('DELETE_USER')
|
|
139
|
+
? 'EVENT_DELETE_USER'
|
|
140
|
+
: '';
|
|
141
|
+
this.updateEvent = this.auth.currentUser.hasPermission('AMEND_USER') ? 'EVENT_AMEND_USER' : '';
|
|
142
|
+
}
|
|
143
|
+
connectedCallback() {
|
|
144
|
+
const _super = Object.create(null, {
|
|
145
|
+
connectedCallback: { get: () => super.connectedCallback }
|
|
146
|
+
});
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
_super.connectedCallback.call(this);
|
|
149
|
+
// retrieving access type of currently logged-in user
|
|
150
|
+
const userReq = yield this.connect.snapshot('ALL_USERS', {
|
|
151
|
+
CRITERIA_MATCH: `USER_NAME == '${this.auth.currentUser.username}'`,
|
|
152
|
+
});
|
|
153
|
+
if (userReq.ROW[0]) {
|
|
154
|
+
this.allAccessType = userReq.ROW[0].ACCESS_TYPE === 'ALL';
|
|
155
|
+
this.entityIdValue = userReq.ROW[0][this.entityID];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
deepClone() {
|
|
160
|
+
const copy = super.deepClone();
|
|
161
|
+
copy.additionalCreateFields = structuredClone(this.additionalCreateFields);
|
|
162
|
+
copy.additionalUpdateFields = structuredClone(this.additionalUpdateFields);
|
|
163
|
+
copy.allAccessType = structuredClone(this.allAccessType);
|
|
164
|
+
copy.createEvent = structuredClone(this.createEvent);
|
|
165
|
+
copy.datasourceConfig = structuredClone(this.datasourceConfig);
|
|
166
|
+
copy.deleteEvent = structuredClone(this.deleteEvent);
|
|
167
|
+
copy.updateEvent = structuredClone(this.updateEvent);
|
|
168
|
+
// this.columns[number] might contain a function, so can't use structuredClone
|
|
169
|
+
copy.columns = this.columns ? [...this.columns].map((x) => (Object.assign({}, x))) : this.columns;
|
|
170
|
+
return copy;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Used as the callback function in {@link Users.statusColumn}
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
statusRendererSelector(params) {
|
|
177
|
+
return {
|
|
178
|
+
component: GridProRendererTypes.action,
|
|
179
|
+
params: {
|
|
180
|
+
actionClick: () => this.changeStatus(params),
|
|
181
|
+
actionName: params.value === 'ENABLED' ? 'Deactivate' : 'Activate',
|
|
182
|
+
appearance: 'secondary-orange',
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Changes the status of an entity
|
|
188
|
+
*
|
|
189
|
+
* @remarks
|
|
190
|
+
*
|
|
191
|
+
* The action which is run on the status button from {@link Users.statusRendererSelector}
|
|
192
|
+
*
|
|
193
|
+
* @internal
|
|
194
|
+
*/
|
|
195
|
+
changeStatus(params) {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
const isEnabled = params.data.STATUS === 'ENABLED';
|
|
198
|
+
// optimistically set value and store previous value
|
|
199
|
+
const previousValue = params.data.STATUS;
|
|
200
|
+
params.setValue(isEnabled ? 'DISABLED' : 'ENABLED');
|
|
201
|
+
const changeStatusRequest = yield this.connect.commitEvent(isEnabled ? 'EVENT_DISABLE_USER' : 'EVENT_ENABLE_USER', {
|
|
202
|
+
DETAILS: {
|
|
203
|
+
USER_NAME: params.data.USER_NAME,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
if (changeStatusRequest.ERROR) {
|
|
207
|
+
logger.error(changeStatusRequest.ERROR);
|
|
208
|
+
const notificationCloseTimeout = 5000;
|
|
209
|
+
changeStatusRequest.ERROR.forEach((err) => {
|
|
210
|
+
this.$emit(ErrorBoundaryEvent.ERROR_BOUNDARY_EVENT, getErrorBuilder()
|
|
211
|
+
.withTitle(err.CODE)
|
|
212
|
+
.withErrorDetails(getErrorFormat(err))
|
|
213
|
+
.withNotification(getNotificationBuilder()
|
|
214
|
+
.withType('warning')
|
|
215
|
+
.withAutoClose(true)
|
|
216
|
+
.withCloseTimeout(notificationCloseTimeout)
|
|
217
|
+
.build())
|
|
218
|
+
.build());
|
|
219
|
+
});
|
|
220
|
+
// bring back original value
|
|
221
|
+
params.setValue(previousValue);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
readUserData(user) {
|
|
229
|
+
var _a;
|
|
230
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
231
|
+
const userProfiles = yield this.connect.request('PROFILE_USER', {
|
|
232
|
+
REQUEST: {
|
|
233
|
+
USER_NAME: user.USER_NAME,
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
const defaultValues = !this.allAccessType && ((_a = this.entityIdValue) === null || _a === void 0 ? void 0 : _a.length)
|
|
237
|
+
? {
|
|
238
|
+
ACCESS_TYPE: 'ENTITY',
|
|
239
|
+
[this.entityID]: this.entityIdValue,
|
|
240
|
+
}
|
|
241
|
+
: {};
|
|
242
|
+
return Object.assign(Object.assign({}, defaultValues), { USER_PROFILES: (userProfiles.REPLY || []).map((profile) => profile.PROFILE_NAME), ADDRESS_LINE_1: user.ADDRESS_LINE1, ADDRESS_LINE_2: user.ADDRESS_LINE2, ADDRESS_LINE_3: user.ADDRESS_LINE3, ADDRESS_LINE_4: user.ADDRESS_LINE4 });
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
__decorate([
|
|
247
|
+
Connect
|
|
248
|
+
], Users.prototype, "connect", void 0);
|
|
249
|
+
__decorate([
|
|
250
|
+
Auth
|
|
251
|
+
], Users.prototype, "auth", void 0);
|
|
252
|
+
__decorate([
|
|
253
|
+
observable
|
|
254
|
+
], Users.prototype, "datasourceConfig", void 0);
|
|
255
|
+
__decorate([
|
|
256
|
+
attr
|
|
257
|
+
], Users.prototype, "resourceName", void 0);
|
|
258
|
+
__decorate([
|
|
259
|
+
observable
|
|
260
|
+
], Users.prototype, "columns", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
observable
|
|
263
|
+
], Users.prototype, "additionalCreateFields", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
observable
|
|
266
|
+
], Users.prototype, "additionalUpdateFields", void 0);
|
|
267
|
+
__decorate([
|
|
268
|
+
observable
|
|
269
|
+
], Users.prototype, "allAccessType", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
observable
|
|
272
|
+
], Users.prototype, "createEvent", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
observable
|
|
275
|
+
], Users.prototype, "deleteEvent", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
observable
|
|
278
|
+
], Users.prototype, "updateEvent", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
attr
|
|
281
|
+
], Users.prototype, "entityID", void 0);
|
|
282
|
+
__decorate([
|
|
283
|
+
attr
|
|
284
|
+
], Users.prototype, "entityLabelKey", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
attr
|
|
287
|
+
], Users.prototype, "entityLabel", void 0);
|
|
288
|
+
__decorate([
|
|
289
|
+
attr
|
|
290
|
+
], Users.prototype, "availableEntitiesEndpoint", void 0);
|
|
291
|
+
Users = __decorate([
|
|
292
|
+
customElement({
|
|
293
|
+
name: 'user-management',
|
|
294
|
+
template: UsersTemplate,
|
|
295
|
+
styles: css `
|
|
296
|
+
:host {
|
|
297
|
+
height: 100%;
|
|
298
|
+
}
|
|
299
|
+
`,
|
|
300
|
+
})
|
|
301
|
+
], Users);
|
|
302
|
+
export { Users };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { html } from '@microsoft/fast-element';
|
|
2
|
+
const conditionalSchemaEntry = (predicate, entry) => {
|
|
3
|
+
return predicate ? [entry] : [];
|
|
4
|
+
};
|
|
5
|
+
const editUserSchema = (edit, allAccessType, entityID, entityLabel, entityLabelKey, availableEntitiesEndpoint, additionalEntries = []) => ({
|
|
6
|
+
type: 'VerticalLayout',
|
|
7
|
+
elements: [
|
|
8
|
+
{
|
|
9
|
+
type: 'Control',
|
|
10
|
+
label: 'Username',
|
|
11
|
+
scope: '#/properties/USER_NAME',
|
|
12
|
+
options: {
|
|
13
|
+
readonly: edit,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: 'Control',
|
|
18
|
+
label: 'Email',
|
|
19
|
+
scope: '#/properties/EMAIL_ADDRESS',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'Control',
|
|
23
|
+
label: 'First Name',
|
|
24
|
+
scope: '#/properties/FIRST_NAME',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'Control',
|
|
28
|
+
label: 'Last Name',
|
|
29
|
+
scope: '#/properties/LAST_NAME',
|
|
30
|
+
},
|
|
31
|
+
...conditionalSchemaEntry(!edit, {
|
|
32
|
+
type: 'Control',
|
|
33
|
+
label: 'One Time Password',
|
|
34
|
+
scope: '#/properties/ONE_TIME_PASSWORD',
|
|
35
|
+
}),
|
|
36
|
+
{
|
|
37
|
+
type: 'Control',
|
|
38
|
+
label: 'User Profiles',
|
|
39
|
+
scope: '#/properties/USER_PROFILES',
|
|
40
|
+
options: {
|
|
41
|
+
allOptionsResourceName: 'ALL_PROFILES',
|
|
42
|
+
valueField: 'PROFILE_NAME',
|
|
43
|
+
labelField: 'PROFILE_NAME',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'Control',
|
|
48
|
+
label: 'Access Type',
|
|
49
|
+
scope: '#/properties/ACCESS_TYPE',
|
|
50
|
+
options: {
|
|
51
|
+
hidden: !allAccessType,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'Control',
|
|
56
|
+
scope: `#/properties/${entityID}`,
|
|
57
|
+
options: {
|
|
58
|
+
allOptionsResourceName: availableEntitiesEndpoint,
|
|
59
|
+
valueField: entityID,
|
|
60
|
+
labelField: entityLabelKey || entityID,
|
|
61
|
+
hidden: !allAccessType,
|
|
62
|
+
},
|
|
63
|
+
label: entityLabel,
|
|
64
|
+
},
|
|
65
|
+
...additionalEntries.map((entry) => typeof entry === 'string'
|
|
66
|
+
? {
|
|
67
|
+
type: 'Control',
|
|
68
|
+
scope: `#/properties/${entry}`,
|
|
69
|
+
}
|
|
70
|
+
: entry),
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
export const UsersTemplate = html `
|
|
74
|
+
<entity-management
|
|
75
|
+
resourceName=${(x) => x.resourceName}
|
|
76
|
+
title="User Management"
|
|
77
|
+
entityLabel="User"
|
|
78
|
+
createEvent="${(x) => x.createEvent}"
|
|
79
|
+
:readEventFn=${(x) => (user) => x.readUserData(user)}
|
|
80
|
+
updateEvent="${(x) => x.updateEvent}"
|
|
81
|
+
deleteEvent="${(x) => x.deleteEvent}"
|
|
82
|
+
entityLabel="User Details"
|
|
83
|
+
:updateFormUiSchema=${(x) => editUserSchema(true, x.allAccessType, x.entityID, x.entityLabel, x.entityLabelKey, x.availableEntitiesEndpoint, x.additionalUpdateFields)}
|
|
84
|
+
:createFormUiSchema=${(x) => editUserSchema(false, x.allAccessType, x.entityID, x.entityLabel, x.entityLabelKey, x.availableEntitiesEndpoint, x.additionalCreateFields)}
|
|
85
|
+
persist-column-state-key="entity_users_management"
|
|
86
|
+
size-columns-to-fit
|
|
87
|
+
:columns=${(x) => [...x.columns, ...x.entityColumn(), x.statusColumn()]}
|
|
88
|
+
:datasourceConfig=${(x) => x.datasourceConfig}
|
|
89
|
+
></entity-management>
|
|
90
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './formatting';
|