@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 @@
|
|
|
1
|
+
{"version":3,"file":"users.template.d.ts","sourceRoot":"","sources":["../../../src/users/users.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAqF5D,eAAO,MAAM,aAAa,EAAE,YAmC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,cAAc,sBAAsE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { __awaiter, __decorate, __rest } from "tslib";
|
|
2
|
+
import { Connect } from '@genesislcap/foundation-comms';
|
|
3
|
+
import { ErrorBoundaryEvent, getErrorBuilder, getNotificationBuilder, } from '@genesislcap/foundation-errors';
|
|
4
|
+
import { createLogger, LifecycleMixin } from '@genesislcap/foundation-utils';
|
|
5
|
+
import { attr, customElement, FASTElement, observable } from '@microsoft/fast-element';
|
|
6
|
+
import { getErrorFormat } from '../utils';
|
|
7
|
+
import { styles } from './entities.styles';
|
|
8
|
+
import { template } from './entities.template';
|
|
9
|
+
/**
|
|
10
|
+
* Logger for the entity management suite
|
|
11
|
+
*
|
|
12
|
+
* @privateRemarks TODO: Should we expose a hook to set log level rather than the logger itself
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export const logger = createLogger('entity-management');
|
|
16
|
+
/**
|
|
17
|
+
* Main class which defines the entity management functionality
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
*
|
|
21
|
+
* Connects to a backend resource and wraps up a grid which is populated
|
|
22
|
+
* with entities from that resource. The different interactions that the user
|
|
23
|
+
* can perform with the entities can be configured, examples being able to
|
|
24
|
+
* update and delete entities.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* Example of using the entity management system to handle counterparties
|
|
30
|
+
* ```
|
|
31
|
+
* <entity-management
|
|
32
|
+
* resourceName="ALL_COUNTERPARTYS"
|
|
33
|
+
* title="Counterparty Management"
|
|
34
|
+
* updateEvent="EVENT_COUNTERPARTY_MODIFY"
|
|
35
|
+
* deleteEvent="EVENT_COUNTERPARTY_DELETE"
|
|
36
|
+
* createEvent="EVENT_COUNTERPARTY_INSERT"
|
|
37
|
+
* ></entity-management>
|
|
38
|
+
* ```
|
|
39
|
+
* Where:<br />
|
|
40
|
+
* - the title of the grid is `Counterparty Management`<br />
|
|
41
|
+
* - the name of the resource in the database to manage is `ALL_COUNTERPARTYS`<br />
|
|
42
|
+
* - the name of the event handler for update events is `EVENT_COUNTERPARTY_MODIFY`<br />
|
|
43
|
+
* - the name of the event handler for create events is `EVENT_COUNTERPARTY_INSERT`<br />
|
|
44
|
+
* - the name of the event handler for delete events is `EVENT_COUNTERPARTY_DELETE`<br />
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
let EntityManagement = class EntityManagement extends LifecycleMixin(FASTElement) {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
/**
|
|
51
|
+
* Label for the entity which has usages such as being shown in the title of the modal wen editing the entity
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
this.entityLabel = '';
|
|
55
|
+
this.editModalVisible = false;
|
|
56
|
+
/**
|
|
57
|
+
* Updates the reference to the current entity stored in the class. Added as an event listener on the class when receiving the `rowSelected` event.
|
|
58
|
+
*
|
|
59
|
+
* @param e - CustomEvent which contains data about the selected entity. If the row is not selected then the reference will be set to an empty object.
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
this.selectEntity = (e) => {
|
|
63
|
+
this.selectedEntity = e.detail.node.isSelected() ? e.detail.data : {};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
editModalVisibleChanged() {
|
|
67
|
+
if (this.editEntityModal) {
|
|
68
|
+
if (this.editModalVisible) {
|
|
69
|
+
this.editEntityModal.show();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.editEntityModal.close();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Set up the web component
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
connectedCallback() {
|
|
81
|
+
const _super = Object.create(null, {
|
|
82
|
+
connectedCallback: { get: () => super.connectedCallback }
|
|
83
|
+
});
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
_super.connectedCallback.call(this);
|
|
86
|
+
this.addEventListener('rowSelected', this.selectEntity);
|
|
87
|
+
if (this.deleteEvent) {
|
|
88
|
+
this.addEventListener('delete-entity', this.deleteEntity);
|
|
89
|
+
}
|
|
90
|
+
this.addEventListener('edit-entity', this.editEntity);
|
|
91
|
+
this.addEventListener('read-entity', this.readEntity);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Override the deepClone method to ensure that observable attributes are cloned
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
deepClone() {
|
|
99
|
+
const copy = super.deepClone();
|
|
100
|
+
copy.createFormUiSchema = structuredClone(this.createFormUiSchema);
|
|
101
|
+
copy.datasourceConfig = structuredClone(this.datasourceConfig);
|
|
102
|
+
copy.editDialogTitle = structuredClone(this.editDialogTitle);
|
|
103
|
+
copy.editModalVisible = structuredClone(this.editModalVisible);
|
|
104
|
+
copy.formResourceName = structuredClone(this.formResourceName);
|
|
105
|
+
copy.formUiSchema = structuredClone(this.formUiSchema);
|
|
106
|
+
copy.updateFormUiSchema = structuredClone(this.updateFormUiSchema);
|
|
107
|
+
// this.columns[number] might contain a function, so can't use structuredClone
|
|
108
|
+
copy.columns = this.columns ? [...this.columns].map((x) => (Object.assign({}, x))) : this.columns;
|
|
109
|
+
return copy;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Event handler for when the user submits the action for the currently open form, either editing or adding the entity
|
|
113
|
+
*
|
|
114
|
+
* @param e - CustomEvent which contains the payload for the entity to submit to the backend
|
|
115
|
+
*
|
|
116
|
+
* Emits an event upon error
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
submitEntityChanges(e) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
this.closeModal();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Sets up and opens the model to either edit or add an entity. Added as an event listener on the class when receiving the `edit-entity` event.
|
|
126
|
+
*
|
|
127
|
+
* @param e - CustomEvent where `e.detail` is used to deduce whether to edit or add an entity.
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
editEntity(e) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
this.editDialogTitle = `${e.detail ? 'Edit' : 'Add'} ${this.entityLabel}`;
|
|
133
|
+
this.formUiSchema = e.detail ? this.updateFormUiSchema : this.createFormUiSchema;
|
|
134
|
+
this.formResourceName = e.detail ? this.updateEvent : this.createEvent;
|
|
135
|
+
if (e.detail) {
|
|
136
|
+
const _a = e.detail, { ROW_REF } = _a, formData = __rest(_a, ["ROW_REF"]);
|
|
137
|
+
this.editedEntity = formData;
|
|
138
|
+
if (this.readEventFn) {
|
|
139
|
+
const readEntityReq = yield this.readEventFn(formData);
|
|
140
|
+
this.editedEntity = Object.assign(Object.assign({}, readEntityReq), this.editedEntity);
|
|
141
|
+
}
|
|
142
|
+
else if (this.readEvent) {
|
|
143
|
+
const readEventReq = yield this.connect.request(this.readEvent, {
|
|
144
|
+
REQUEST: formData,
|
|
145
|
+
});
|
|
146
|
+
this.editedEntity = Object.assign(Object.assign({}, readEventReq.REPLY[0]), this.editedEntity);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this.editedEntity = {};
|
|
151
|
+
}
|
|
152
|
+
this.editModalVisible = true;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
readEntity(e) {
|
|
156
|
+
this.readonly = true;
|
|
157
|
+
this.editEntity(e);
|
|
158
|
+
this.editDialogTitle = '';
|
|
159
|
+
}
|
|
160
|
+
closeModal() {
|
|
161
|
+
this.readonly = false;
|
|
162
|
+
this.editModalVisible = false;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Handler for deleting the entity. Added as an event listener on the class when receiving the `delete-entity` event.
|
|
166
|
+
*
|
|
167
|
+
* @param e - CustomEvent where `e.detail` contains data to update the selectedEntity reference with the entity to delete.
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
170
|
+
deleteEntity(e) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
const schema = yield this.connect.getJSONSchema(this.deleteEvent);
|
|
173
|
+
this.selectedEntity = e.detail;
|
|
174
|
+
const DETAILS = {};
|
|
175
|
+
if (typeof schema.INBOUND.properties.DETAILS !== 'boolean') {
|
|
176
|
+
const requiredFields = schema.INBOUND.properties.DETAILS.required;
|
|
177
|
+
if (requiredFields) {
|
|
178
|
+
requiredFields.forEach((property) => {
|
|
179
|
+
DETAILS[property] = this.selectedEntity[property];
|
|
180
|
+
});
|
|
181
|
+
const deleteReq = yield this.connect.commitEvent(this.deleteEvent, {
|
|
182
|
+
DETAILS,
|
|
183
|
+
});
|
|
184
|
+
this.errorNotify(deleteReq);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
logger.error('No required fields found for delete event', this.deleteEvent);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Show notifications if the executed event returned an error.
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
errorNotify(request) {
|
|
197
|
+
const notificationCloseTimeout = 5000;
|
|
198
|
+
if (request.ERROR) {
|
|
199
|
+
logger.error(request.ERROR);
|
|
200
|
+
request.ERROR.forEach((err) => {
|
|
201
|
+
this.$emit(ErrorBoundaryEvent.ERROR_BOUNDARY_EVENT, getErrorBuilder()
|
|
202
|
+
.withTitle(err.CODE)
|
|
203
|
+
.withErrorDetails(getErrorFormat(err))
|
|
204
|
+
.withNotification(getNotificationBuilder()
|
|
205
|
+
.withType('warning')
|
|
206
|
+
.withAutoClose(true)
|
|
207
|
+
.withCloseTimeout(notificationCloseTimeout)
|
|
208
|
+
.build())
|
|
209
|
+
.build());
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
__decorate([
|
|
215
|
+
Connect
|
|
216
|
+
], EntityManagement.prototype, "connect", void 0);
|
|
217
|
+
__decorate([
|
|
218
|
+
attr
|
|
219
|
+
], EntityManagement.prototype, "resourceName", void 0);
|
|
220
|
+
__decorate([
|
|
221
|
+
attr
|
|
222
|
+
], EntityManagement.prototype, "readEvent", void 0);
|
|
223
|
+
__decorate([
|
|
224
|
+
observable
|
|
225
|
+
], EntityManagement.prototype, "readEventFn", void 0);
|
|
226
|
+
__decorate([
|
|
227
|
+
attr({ mode: 'boolean' })
|
|
228
|
+
], EntityManagement.prototype, "readonly", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
attr
|
|
231
|
+
], EntityManagement.prototype, "updateEvent", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
attr
|
|
234
|
+
], EntityManagement.prototype, "deleteEvent", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
attr
|
|
237
|
+
], EntityManagement.prototype, "createEvent", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
attr
|
|
240
|
+
], EntityManagement.prototype, "title", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
attr
|
|
243
|
+
], EntityManagement.prototype, "entityLabel", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
attr({ attribute: 'persist-column-state-key' })
|
|
246
|
+
], EntityManagement.prototype, "persistColumnStateKey", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
observable
|
|
249
|
+
], EntityManagement.prototype, "columns", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
observable
|
|
252
|
+
], EntityManagement.prototype, "datasourceConfig", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
observable
|
|
255
|
+
], EntityManagement.prototype, "formUiSchema", void 0);
|
|
256
|
+
__decorate([
|
|
257
|
+
observable
|
|
258
|
+
], EntityManagement.prototype, "createFormUiSchema", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
observable
|
|
261
|
+
], EntityManagement.prototype, "updateFormUiSchema", void 0);
|
|
262
|
+
__decorate([
|
|
263
|
+
observable
|
|
264
|
+
], EntityManagement.prototype, "formResourceName", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
observable
|
|
267
|
+
], EntityManagement.prototype, "selectedEntity", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
observable
|
|
270
|
+
], EntityManagement.prototype, "editedEntity", void 0);
|
|
271
|
+
__decorate([
|
|
272
|
+
observable
|
|
273
|
+
], EntityManagement.prototype, "submitting", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
observable
|
|
276
|
+
], EntityManagement.prototype, "editDialogTitle", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
observable
|
|
279
|
+
], EntityManagement.prototype, "editModalVisible", void 0);
|
|
280
|
+
__decorate([
|
|
281
|
+
attr({ mode: 'boolean', attribute: 'size-columns-to-fit' })
|
|
282
|
+
], EntityManagement.prototype, "sizeColumnsToFit", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
attr({ mode: 'boolean', attribute: 'enable-filter-bar' })
|
|
285
|
+
], EntityManagement.prototype, "enableFilterBar", void 0);
|
|
286
|
+
__decorate([
|
|
287
|
+
attr({ mode: 'boolean', attribute: 'enable-cell-flashing' })
|
|
288
|
+
], EntityManagement.prototype, "enableCellFlashing", void 0);
|
|
289
|
+
EntityManagement = __decorate([
|
|
290
|
+
customElement({
|
|
291
|
+
name: 'entity-management',
|
|
292
|
+
template,
|
|
293
|
+
styles,
|
|
294
|
+
})
|
|
295
|
+
], EntityManagement);
|
|
296
|
+
export { EntityManagement };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { css } from '@microsoft/fast-element';
|
|
2
|
+
/**
|
|
3
|
+
* Defines the css of the entity component as an ElementStyles object
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
*
|
|
7
|
+
* Mixin to custom ElementStyles to override and customise the style of an
|
|
8
|
+
* entity manager component
|
|
9
|
+
*/
|
|
10
|
+
export const styles = css `
|
|
11
|
+
:host {
|
|
12
|
+
contain: content;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.container {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
height: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
foundation-form {
|
|
22
|
+
height: 100%;
|
|
23
|
+
overflow-y: auto;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.title {
|
|
27
|
+
margin-left: 1px;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Form } from '@genesislcap/foundation-forms';
|
|
2
|
+
import { html, ref, when } from '@microsoft/fast-element';
|
|
3
|
+
import { List } from '../list';
|
|
4
|
+
List;
|
|
5
|
+
Form;
|
|
6
|
+
/**
|
|
7
|
+
* Defines the html of the entity component as a ViewTemplate object
|
|
8
|
+
* @typeParam EntityManagement - the {@link @genesislcap/foundation-entity-management#EntityManagement | class} the template is defined for
|
|
9
|
+
*/
|
|
10
|
+
export const template = html `
|
|
11
|
+
<div class="container">
|
|
12
|
+
<entity-list
|
|
13
|
+
title=${(x) => x.title}
|
|
14
|
+
persist-column-state-key=${(x) => x.persistColumnStateKey}
|
|
15
|
+
size-columns-to-fit=${(x) => x.sizeColumnsToFit}
|
|
16
|
+
enable-filter-bar=${(x) => x.enableFilterBar}
|
|
17
|
+
resourceName=${(x) => x.resourceName}
|
|
18
|
+
:createEvent=${(x) => x.createEvent}
|
|
19
|
+
:deleteEvent=${(x) => x.deleteEvent}
|
|
20
|
+
:updateEvent=${(x) => x.updateEvent}
|
|
21
|
+
:columns=${(x) => x.columns}
|
|
22
|
+
:datasourceConfig=${(x) => x.datasourceConfig}
|
|
23
|
+
></entity-list>
|
|
24
|
+
<zero-modal
|
|
25
|
+
${ref('editEntityModal')}
|
|
26
|
+
position="right"
|
|
27
|
+
:onCloseCallback=${(x) => x.closeModal.bind(x)}
|
|
28
|
+
>
|
|
29
|
+
<div slot="top">${(x) => x.editDialogTitle}</div>
|
|
30
|
+
|
|
31
|
+
<slot name="edit">
|
|
32
|
+
${when((x) => x.editModalVisible, html `
|
|
33
|
+
<foundation-form
|
|
34
|
+
resourceName=${(x) => x.formResourceName}
|
|
35
|
+
:data=${(x) => x.editedEntity}
|
|
36
|
+
:uischema=${(x) => x.formUiSchema}
|
|
37
|
+
@submit-success=${(x, c) => x.submitEntityChanges(c.event)}
|
|
38
|
+
></foundation-form>
|
|
39
|
+
`)}
|
|
40
|
+
</slot>
|
|
41
|
+
</zero-modal>
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import('./index');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './list';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { __awaiter, __decorate } from "tslib";
|
|
2
|
+
import { Events } from '@ag-grid-community/core';
|
|
3
|
+
import { attr, customElement, FASTElement, observable } from '@microsoft/fast-element';
|
|
4
|
+
import { listStyles } from './list.styles';
|
|
5
|
+
import { buttonCellRenderer, listTemplate } from './list.template';
|
|
6
|
+
let List = class List extends FASTElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.resourceName = '';
|
|
10
|
+
this.title = '';
|
|
11
|
+
this.actionButtonsConfig = [];
|
|
12
|
+
this.edit = (e) => {
|
|
13
|
+
this.$emit('edit-entity', e);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
super.connectedCallback();
|
|
18
|
+
this.grid.addEventListener('onGridReady', () => {
|
|
19
|
+
this.grid.gridApi.addEventListener(Events.EVENT_FIRST_DATA_RENDERED, () => {
|
|
20
|
+
if (this.sizeColumnsToFit) {
|
|
21
|
+
this.grid.gridApi.sizeColumnsToFit();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
this.grid.gridApi.addEventListener('rowClicked', (e) => this.select(e));
|
|
25
|
+
this.actionButtonsConfig = [];
|
|
26
|
+
if (this.deleteEvent) {
|
|
27
|
+
this.actionButtonsConfig.push(buttonCellRenderer('Delete', (e) => this.delete(e)));
|
|
28
|
+
}
|
|
29
|
+
if (this.updateEvent) {
|
|
30
|
+
this.actionButtonsConfig.push(buttonCellRenderer('Edit', this.edit));
|
|
31
|
+
}
|
|
32
|
+
if (this.enableFilterBar) {
|
|
33
|
+
this.addEventListener('filter-changed', this.handleFilterChanged);
|
|
34
|
+
this.addEventListener('filter-cleared', this.handleFilterCleared);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
disconnectedCallback() {
|
|
39
|
+
super.disconnectedCallback();
|
|
40
|
+
if (this.enableFilterBar) {
|
|
41
|
+
this.removeEventListener('filter-changed', this.handleFilterChanged);
|
|
42
|
+
this.removeEventListener('filter-cleared', this.handleFilterCleared);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
handleFilterChanged(e) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
const fieldName = (_a = e === null || e === void 0 ? void 0 : e.detail) === null || _a === void 0 ? void 0 : _a.fieldName;
|
|
48
|
+
const filter = (_b = e === null || e === void 0 ? void 0 : e.detail) === null || _b === void 0 ? void 0 : _b.filter;
|
|
49
|
+
fieldName && filter && this.datasource.setFilter(fieldName, filter);
|
|
50
|
+
}
|
|
51
|
+
handleFilterCleared(e) {
|
|
52
|
+
var _a;
|
|
53
|
+
const fieldName = (_a = e === null || e === void 0 ? void 0 : e.detail) === null || _a === void 0 ? void 0 : _a.fieldName;
|
|
54
|
+
this.datasource.removeFilter(fieldName);
|
|
55
|
+
}
|
|
56
|
+
select(e) {
|
|
57
|
+
this.$emit('rowSelected', e);
|
|
58
|
+
}
|
|
59
|
+
create() {
|
|
60
|
+
this.$emit('edit-entity');
|
|
61
|
+
}
|
|
62
|
+
delete(e) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
this.$emit('delete-entity', e);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
__decorate([
|
|
69
|
+
attr
|
|
70
|
+
], List.prototype, "resourceName", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
attr
|
|
73
|
+
], List.prototype, "title", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
attr({ attribute: 'persist-column-state-key' })
|
|
76
|
+
], List.prototype, "persistColumnStateKey", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
attr({ mode: 'boolean', attribute: 'size-columns-to-fit' })
|
|
79
|
+
], List.prototype, "sizeColumnsToFit", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
attr({ mode: 'boolean', attribute: 'enable-filter-bar' })
|
|
82
|
+
], List.prototype, "enableFilterBar", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
attr({ mode: 'boolean', attribute: 'enable-cell-flashing' })
|
|
85
|
+
], List.prototype, "enableCellFlashing", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
observable
|
|
88
|
+
], List.prototype, "columns", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
observable
|
|
91
|
+
], List.prototype, "datasourceConfig", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
observable
|
|
94
|
+
], List.prototype, "actionButtonsConfig", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
observable
|
|
97
|
+
], List.prototype, "createEvent", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
observable
|
|
100
|
+
], List.prototype, "deleteEvent", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
observable
|
|
103
|
+
], List.prototype, "updateEvent", void 0);
|
|
104
|
+
List = __decorate([
|
|
105
|
+
customElement({
|
|
106
|
+
name: 'entity-list',
|
|
107
|
+
template: listTemplate,
|
|
108
|
+
styles: listStyles,
|
|
109
|
+
})
|
|
110
|
+
], List);
|
|
111
|
+
export { List };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { css } from '@microsoft/fast-element';
|
|
2
|
+
export const listStyles = css `
|
|
3
|
+
:host {
|
|
4
|
+
contain: content;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:host,
|
|
8
|
+
fast-router {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.container {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
height: inherit;
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.heading {
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: space-between;
|
|
25
|
+
align-items: center;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { html, ref, repeat, when } from '@microsoft/fast-element';
|
|
2
|
+
export const buttonCellRenderer = (title, clickHandler) => ({
|
|
3
|
+
width: 100,
|
|
4
|
+
pinned: 'right',
|
|
5
|
+
enableCellChangeFlash: false,
|
|
6
|
+
cellStyle: { padding: '0', lineHeight: '25px' },
|
|
7
|
+
filter: false,
|
|
8
|
+
suppressFiltersToolPanel: true,
|
|
9
|
+
suppressColumnsToolPanel: true,
|
|
10
|
+
headerName: '',
|
|
11
|
+
minWidth: 100,
|
|
12
|
+
maxWidth: 100,
|
|
13
|
+
cellRendererSelector: (params) => params.node.group
|
|
14
|
+
? undefined
|
|
15
|
+
: {
|
|
16
|
+
component: 'action',
|
|
17
|
+
params: {
|
|
18
|
+
actionClick: clickHandler,
|
|
19
|
+
actionName: title,
|
|
20
|
+
appearance: 'accent',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
export const listTemplate = html `
|
|
25
|
+
<div class="heading">
|
|
26
|
+
<h3>${(x) => x.title}</h3>
|
|
27
|
+
${when((x) => x.createEvent, html `
|
|
28
|
+
<zero-button
|
|
29
|
+
appearance="accent"
|
|
30
|
+
@click=${(x) => x.create()}
|
|
31
|
+
?disabled="${(x) => x.addDisabled}"
|
|
32
|
+
>
|
|
33
|
+
Add
|
|
34
|
+
</zero-button>
|
|
35
|
+
`)}
|
|
36
|
+
</div>
|
|
37
|
+
<div class="container">
|
|
38
|
+
${when((x) => x.enableFilterBar, html `
|
|
39
|
+
<zero-filter-bar
|
|
40
|
+
resource=${(x) => x.resourceName}
|
|
41
|
+
only=${(x) => { var _a; return (_a = x.columns) === null || _a === void 0 ? void 0 : _a.map((colDef) => colDef.field).filter((field) => !!field); }}
|
|
42
|
+
labels=${(x) => { var _a; return (_a = x.columns) === null || _a === void 0 ? void 0 : _a.map((colDef) => colDef.headerName || ''); }}
|
|
43
|
+
target="datasource"
|
|
44
|
+
></zero-filter-bar>
|
|
45
|
+
`)}
|
|
46
|
+
<zero-grid-pro
|
|
47
|
+
${ref('grid')}
|
|
48
|
+
auto-cell-renderer-by-type
|
|
49
|
+
rowSelection="single"
|
|
50
|
+
rowHeight="36"
|
|
51
|
+
headerHeight="36"
|
|
52
|
+
persist-column-state-key=${(x) => x.persistColumnStateKey}
|
|
53
|
+
?only-template-col-defs=${(x) => !!x.columns}
|
|
54
|
+
suppressCellFocus="true"
|
|
55
|
+
suppressRowDeselection="true"
|
|
56
|
+
enable-cell-flashing=${(x) => x.enableCellFlashing}
|
|
57
|
+
>
|
|
58
|
+
<grid-pro-genesis-datasource
|
|
59
|
+
${ref('datasource')}
|
|
60
|
+
resource-name=${(x) => x.resourceName}
|
|
61
|
+
criteria=${(x) => { var _a; return (_a = x.datasourceConfig) === null || _a === void 0 ? void 0 : _a.criteria; }}
|
|
62
|
+
fields=${(x) => { var _a; return (_a = x.datasourceConfig) === null || _a === void 0 ? void 0 : _a.fields; }}
|
|
63
|
+
is-snapshot=${(x) => { var _a; return (_a = x.datasourceConfig) === null || _a === void 0 ? void 0 : _a.isSnapshot; }}
|
|
64
|
+
max-rows=${(x) => { var _a; return (_a = x.datasourceConfig) === null || _a === void 0 ? void 0 : _a.maxRows; }}
|
|
65
|
+
max-view=${(x) => { var _a; return (_a = x.datasourceConfig) === null || _a === void 0 ? void 0 : _a.maxView; }}
|
|
66
|
+
order-by=${(x) => { var _a; return (_a = x.datasourceConfig) === null || _a === void 0 ? void 0 : _a.orderBy; }}
|
|
67
|
+
reverse=${(x) => { var _a; return (_a = x.datasourceConfig) === null || _a === void 0 ? void 0 : _a.reverse; }}
|
|
68
|
+
></grid-pro-genesis-datasource>
|
|
69
|
+
${repeat((x) => x.columns, html `
|
|
70
|
+
<grid-pro-column :definition=${(x) => x}></grid-pro-column>
|
|
71
|
+
`)}
|
|
72
|
+
${repeat((x) => x.actionButtonsConfig, html `
|
|
73
|
+
<grid-pro-column :definition=${(x) => x}></grid-pro-column>
|
|
74
|
+
`)}
|
|
75
|
+
</zero-grid-pro>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const editProfileFormSchema = {
|
|
2
|
+
type: 'VerticalLayout',
|
|
3
|
+
elements: [
|
|
4
|
+
{
|
|
5
|
+
type: 'Control',
|
|
6
|
+
label: 'NAME',
|
|
7
|
+
scope: '#/properties/NAME',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
type: 'Control',
|
|
11
|
+
label: 'Description',
|
|
12
|
+
scope: '#/properties/DESCRIPTION',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'Control',
|
|
16
|
+
label: 'Status',
|
|
17
|
+
scope: '#/properties/STATUS',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: 'Control',
|
|
21
|
+
label: 'Rights',
|
|
22
|
+
scope: '#/properties/RIGHT_CODES',
|
|
23
|
+
options: {
|
|
24
|
+
allOptionsResourceName: 'RIGHT',
|
|
25
|
+
valueField: 'CODE',
|
|
26
|
+
labelField: 'CODE',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'Control',
|
|
31
|
+
label: 'Users',
|
|
32
|
+
scope: '#/properties/USER_NAMES',
|
|
33
|
+
options: {
|
|
34
|
+
allOptionsResourceName: 'USER',
|
|
35
|
+
valueField: 'USER_NAME',
|
|
36
|
+
labelField: 'USER_NAME',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|