@genesislcap/foundation-entity-management 14.462.0 → 14.463.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/dist/custom-elements.json +348 -111
- package/dist/dts/entities/entities.d.ts +29 -1
- package/dist/dts/entities/entities.d.ts.map +1 -1
- package/dist/dts/entities/entities.template.d.ts.map +1 -1
- package/dist/dts/entities/smartFormModal.d.ts +172 -3
- package/dist/dts/entities/smartFormModal.d.ts.map +1 -1
- package/dist/dts/react.d.ts +2 -2
- package/dist/esm/entities/entities.js +17 -3
- package/dist/esm/entities/entities.template.js +4 -4
- package/dist/esm/entities/smartFormModal.js +150 -4
- package/dist/foundation-entity-management.api.json +382 -7
- package/dist/foundation-entity-management.d.ts +199 -4
- package/dist/react.cjs +11 -11
- package/dist/react.mjs +11 -11
- package/package.json +23 -23
|
@@ -1,10 +1,179 @@
|
|
|
1
|
+
import type { UiSchema } from '@genesislcap/foundation-forms';
|
|
2
|
+
import { CrudMenuPosition } from '../types';
|
|
1
3
|
import { EntityManagement } from './entities';
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* A focused form dialog component that renders a single trigger button which opens a modal
|
|
6
|
+
* containing an auto-generated form.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* `smart-form-modal` is a trimmed-down variant of {@link EntityManagement} intended for
|
|
10
|
+
* single-action use cases — approval submissions, bespoke inserts —
|
|
11
|
+
* where you want a button that opens a form modal without the accompanying data grid.
|
|
12
|
+
*
|
|
13
|
+
* The component inherits the full `entity-management` API but exposes a purpose-fit surface
|
|
14
|
+
* of its own:
|
|
15
|
+
*
|
|
16
|
+
* | `smart-form-modal` attr | Underlying property | Notes |
|
|
17
|
+
* |---|---|---|
|
|
18
|
+
* | `event` | `createEvent` | The Genesis event handler that processes the form submission |
|
|
19
|
+
* | `button-label` | `createLabel` | Button and modal title text; replaces the default "Add {entityLabel}" |
|
|
20
|
+
* | `form-ui-schema` (`:formUiSchema`) | `createFormUiSchema` | UI schema passed as a property binding |
|
|
21
|
+
* | `success-notification-title` | — | Overrides the toast title shown on successful submit |
|
|
22
|
+
* | `success-notification-body` | — | Overrides the toast body shown on successful submit |
|
|
23
|
+
*
|
|
24
|
+
* The underlying `entity-management` attributes (`createEvent`, `createFormUiSchema`,
|
|
25
|
+
* `create-label`, `confirmation-message`, `default-entity-values`, `design-system-prefix`,
|
|
26
|
+
* `set-approval-message`, `approval-message-label`, `form-renderers`,
|
|
27
|
+
* `additional-form-renderers`, `readonly`) all continue to work — the aliases listed above
|
|
28
|
+
* are simply the preferred vocabulary for this component.
|
|
29
|
+
*
|
|
30
|
+
* Attributes that belong to the grid (`updateEvent`, `deleteEvent`, `columns`, `gridOptions`,
|
|
31
|
+
* `datasource-config`, `resource-name`, `enable-search-bar`, `enable-filter-bar`, etc.) are
|
|
32
|
+
* inherited but have no effect because the grid is always hidden.
|
|
33
|
+
*
|
|
34
|
+
* **Defaults that differ from `entity-management`:**
|
|
35
|
+
* - `modalPosition` defaults to `'centre'` (entity-management defaults to `'right'`)
|
|
36
|
+
* - `crudMenuPosition` defaults to `'top'` (entity-management defaults to `'column'`)
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* Minimal usage — form fields are auto-generated from the event schema:
|
|
40
|
+
* ```html
|
|
41
|
+
* <smart-form-modal
|
|
42
|
+
* event="EVENT_TRADE_INSERT"
|
|
43
|
+
* entity-label="Trade"
|
|
44
|
+
* ></smart-form-modal>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* Custom action label with styled button via CSS part:
|
|
49
|
+
* ```html
|
|
50
|
+
* <smart-form-modal
|
|
51
|
+
* event="EVENT_PRICE_REJECT"
|
|
52
|
+
* button-label="Reject Price"
|
|
53
|
+
* success-notification-title="Price Rejected"
|
|
54
|
+
* success-notification-body="The price was successfully rejected."
|
|
55
|
+
* ></smart-form-modal>
|
|
56
|
+
* ```
|
|
57
|
+
* ```css
|
|
58
|
+
* smart-form-modal::part(create-button) {
|
|
59
|
+
* background-color: #d32f2f;
|
|
60
|
+
* color: #fff;
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* Controlled form layout via `formUiSchema` property binding:
|
|
66
|
+
* ```html
|
|
67
|
+
* <smart-form-modal
|
|
68
|
+
* event="EVENT_COUNTERPARTY_INSERT"
|
|
69
|
+
* entity-label="Counterparty"
|
|
70
|
+
* :formUiSchema="${() => myUiSchema}"
|
|
71
|
+
* ></smart-form-modal>
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* Confirmation dialog before submit:
|
|
76
|
+
* ```html
|
|
77
|
+
* <smart-form-modal
|
|
78
|
+
* event="EVENT_COUNTERPARTY_INSERT"
|
|
79
|
+
* entity-label="Counterparty"
|
|
80
|
+
* confirmation-message="Are you sure you want to submit?"
|
|
81
|
+
* ></smart-form-modal>
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* Read-only view mode:
|
|
86
|
+
* ```html
|
|
87
|
+
* <smart-form-modal
|
|
88
|
+
* event="EVENT_TRADE_INSERT"
|
|
89
|
+
* entity-label="Trade"
|
|
90
|
+
* readonly
|
|
91
|
+
* ></smart-form-modal>
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @csspart create-button - The trigger button that opens the modal. Style via `::part(create-button)`.
|
|
95
|
+
*
|
|
96
|
+
* @fires submit-success - Fired when the form is submitted successfully.
|
|
97
|
+
* @fires submit-failure - Fired when the form submission returns an error.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
6
100
|
*/
|
|
7
101
|
export declare class SmartFormModal extends EntityManagement {
|
|
102
|
+
/** @internal */
|
|
8
103
|
gridVisible: boolean;
|
|
104
|
+
/** @internal */
|
|
105
|
+
modalPosition: 'centre' | 'left' | 'right';
|
|
106
|
+
/** @internal */
|
|
107
|
+
crudMenuPosition: CrudMenuPosition;
|
|
108
|
+
/**
|
|
109
|
+
* The Genesis event handler that processes the form submission.
|
|
110
|
+
*
|
|
111
|
+
* @remarks
|
|
112
|
+
* Alias for `createEvent`. Prefer `event` when using `smart-form-modal` — it reads more
|
|
113
|
+
* naturally for single-action components where the CRUD framing of `createEvent` does not apply.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```html
|
|
117
|
+
* <smart-form-modal event="EVENT_TRADE_INSERT"></smart-form-modal>
|
|
118
|
+
* ```
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
event: string;
|
|
122
|
+
eventChanged(_: string, next: string): void;
|
|
123
|
+
/**
|
|
124
|
+
* Label appended to the default button text, producing "Add {entity-label}".
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* Re-declares the inherited `entityLabel` attr explicitly so FAST observes it on this element.
|
|
128
|
+
* Has no effect when `button-label` is also set — `button-label` takes full precedence.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```html
|
|
132
|
+
* <smart-form-modal event="EVENT_TRADE_INSERT" entity-label="Trade"></smart-form-modal>
|
|
133
|
+
* ```
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
entityLabel: string;
|
|
137
|
+
/**
|
|
138
|
+
* UI schema that controls the layout and visibility of form fields.
|
|
139
|
+
*
|
|
140
|
+
* @remarks
|
|
141
|
+
* Alias for `createFormUiSchema`. Must be set as a property binding (`:formUiSchema`) since it
|
|
142
|
+
* accepts a `UiSchema` object, not a plain string attribute.
|
|
143
|
+
*
|
|
144
|
+
* When omitted, the form is auto-generated from the event's server-side schema.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```html
|
|
148
|
+
* <smart-form-modal
|
|
149
|
+
* event="EVENT_COUNTERPARTY_INSERT"
|
|
150
|
+
* :formUiSchema="${() => ({
|
|
151
|
+
* type: 'VerticalLayout',
|
|
152
|
+
* elements: [
|
|
153
|
+
* { type: 'Control', scope: '#/properties/NAME' },
|
|
154
|
+
* { type: 'Control', scope: '#/properties/ENABLED' },
|
|
155
|
+
* ],
|
|
156
|
+
* })}"
|
|
157
|
+
* ></smart-form-modal>
|
|
158
|
+
* ```
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
formUiSchema: UiSchema;
|
|
162
|
+
formUiSchemaChanged(_: UiSchema, next: UiSchema): void;
|
|
163
|
+
/**
|
|
164
|
+
* Text displayed on the trigger button and as the modal title.
|
|
165
|
+
*
|
|
166
|
+
* @remarks
|
|
167
|
+
* Alias for `create-label`. When set, the default "Add {entityLabel}" text is replaced
|
|
168
|
+
* entirely and the `+` icon is hidden so the label stands alone.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```html
|
|
172
|
+
* <smart-form-modal button-label="Reject Price"></smart-form-modal>
|
|
173
|
+
* ```
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
buttonLabel: string;
|
|
177
|
+
buttonLabelChanged(_: string, next: string): void;
|
|
9
178
|
}
|
|
10
179
|
//# sourceMappingURL=smartFormModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartFormModal.d.ts","sourceRoot":"","sources":["../../../src/entities/smartFormModal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"smartFormModal.d.ts","sourceRoot":"","sources":["../../../src/entities/smartFormModal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAI9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AACH,qBAmDa,cAAe,SAAQ,gBAAgB;IAClD,gBAAgB;IAChB,WAAW,UAAS;IACpB,gBAAgB;IAChB,aAAa,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAY;IACtD,gBAAgB;IAChB,gBAAgB,EAAE,gBAAgB,CAAwB;IAE1D;;;;;;;;;;;;OAYG;IAC2B,KAAK,EAAE,MAAM,CAAC;IAC5C,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAIpC;;;;;;;;;;;;OAYG;IACkC,WAAW,EAAE,MAAM,CAAC;IAEzD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACS,YAAY,EAAE,QAAQ,CAAC;IACnC,mBAAmB,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ;IAI/C;;;;;;;;;;;;OAYG;IACkC,WAAW,EAAE,MAAM,CAAC;IACzD,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAG3C"}
|
package/dist/dts/react.d.ts
CHANGED
|
@@ -62,13 +62,13 @@ export declare const SmartFormModal: React.ForwardRefExoticComponent<
|
|
|
62
62
|
React.PropsWithChildren<
|
|
63
63
|
Omit<PublicOf<SmartFormModalWC>, 'children' | 'style'> &
|
|
64
64
|
HTMLWCProps & {
|
|
65
|
+
onSubmitSuccess?: (event: CustomEvent<unknown>) => void;
|
|
66
|
+
onSubmitFailure?: (event: CustomEvent<unknown>) => void;
|
|
65
67
|
onRequestChanged?: (event: CustomEvent<unknown>) => void;
|
|
66
68
|
onCriteriaChanged?: (event: CustomEvent<unknown>) => void;
|
|
67
69
|
onCreateEntity?: (event: CustomEvent<unknown>) => void;
|
|
68
70
|
onEditEntity?: (event: CustomEvent<unknown>) => void;
|
|
69
71
|
onDeleteEntity?: (event: CustomEvent<unknown>) => void;
|
|
70
|
-
onSubmitFailure?: (event: CustomEvent<unknown>) => void;
|
|
71
|
-
onSubmitSuccess?: (event: CustomEvent<unknown>) => void;
|
|
72
72
|
onRowClick?: (event: CustomEvent<unknown>) => void;
|
|
73
73
|
onRowDblClick?: (event: CustomEvent<unknown>) => void;
|
|
74
74
|
onRowSelected?: (event: CustomEvent<unknown>) => void;
|
|
@@ -350,7 +350,7 @@ let EntityManagement = class EntityManagement extends LifecycleMixin(GenesisElem
|
|
|
350
350
|
getTitleBasedOnActionOrType(actionOrType) {
|
|
351
351
|
switch (actionOrType) {
|
|
352
352
|
case ModalFormType.Create:
|
|
353
|
-
return `Add ${this.entityLabel || ''}`;
|
|
353
|
+
return this.createLabel || `Add ${this.entityLabel || ''}`;
|
|
354
354
|
case ModalFormType.Update:
|
|
355
355
|
return `Edit ${this.entityLabel || ''}`;
|
|
356
356
|
case CrudAction.Delete:
|
|
@@ -1016,6 +1016,7 @@ let EntityManagement = class EntityManagement extends LifecycleMixin(GenesisElem
|
|
|
1016
1016
|
* @internal
|
|
1017
1017
|
*/
|
|
1018
1018
|
handleNotify(type, requestError) {
|
|
1019
|
+
var _a, _b;
|
|
1019
1020
|
const notificationCloseTimeout = 5000;
|
|
1020
1021
|
if (requestError) {
|
|
1021
1022
|
logger.error(requestError);
|
|
@@ -1032,9 +1033,13 @@ let EntityManagement = class EntityManagement extends LifecycleMixin(GenesisElem
|
|
|
1032
1033
|
else {
|
|
1033
1034
|
const label = this.entityLabel ? this.entityLabel : 'Entity';
|
|
1034
1035
|
const titleAndBody = getActionNotificationTitleAndBody(type, label);
|
|
1035
|
-
showNotification(
|
|
1036
|
+
showNotification({
|
|
1037
|
+
title: (_a = this.successNotificationTitle) !== null && _a !== void 0 ? _a : titleAndBody.title,
|
|
1038
|
+
body: (_b = this.successNotificationBody) !== null && _b !== void 0 ? _b : titleAndBody.body,
|
|
1039
|
+
config: {
|
|
1036
1040
|
toast: { type: 'success', autoClose: true, closeTimeout: notificationCloseTimeout },
|
|
1037
|
-
}
|
|
1041
|
+
},
|
|
1042
|
+
}, this.prefix);
|
|
1038
1043
|
}
|
|
1039
1044
|
}
|
|
1040
1045
|
/**
|
|
@@ -1215,12 +1220,21 @@ __decorate([
|
|
|
1215
1220
|
__decorate([
|
|
1216
1221
|
observable
|
|
1217
1222
|
], EntityManagement.prototype, "errorNotificationConfig", void 0);
|
|
1223
|
+
__decorate([
|
|
1224
|
+
attr({ attribute: 'success-notification-title' })
|
|
1225
|
+
], EntityManagement.prototype, "successNotificationTitle", void 0);
|
|
1226
|
+
__decorate([
|
|
1227
|
+
attr({ attribute: 'success-notification-body' })
|
|
1228
|
+
], EntityManagement.prototype, "successNotificationBody", void 0);
|
|
1218
1229
|
__decorate([
|
|
1219
1230
|
attr
|
|
1220
1231
|
], EntityManagement.prototype, "title", void 0);
|
|
1221
1232
|
__decorate([
|
|
1222
1233
|
attr
|
|
1223
1234
|
], EntityManagement.prototype, "entityLabel", void 0);
|
|
1235
|
+
__decorate([
|
|
1236
|
+
attr({ attribute: 'create-label' })
|
|
1237
|
+
], EntityManagement.prototype, "createLabel", void 0);
|
|
1224
1238
|
__decorate([
|
|
1225
1239
|
attr({ mode: 'boolean', attribute: 'async-add' })
|
|
1226
1240
|
], EntityManagement.prototype, "asyncAdd", void 0);
|
|
@@ -27,8 +27,8 @@ const customActionButtonTemplate = (prefix, position) => html `
|
|
|
27
27
|
*/
|
|
28
28
|
const addButtonTemplate = (prefix) => html `
|
|
29
29
|
${when((x) => x.createEvent, html `
|
|
30
|
-
<${prefix}-button class="crud-button" appearance="neutral" @click=${(x) => x.createEntity()}>
|
|
31
|
-
|
|
30
|
+
<${prefix}-button part="create-button" class="crud-button" appearance="neutral" @click=${(x) => x.createEntity()}>
|
|
31
|
+
${when((x) => !x.createLabel, html `<${prefix}-icon size="lg" name="plus"></${prefix}-icon>`)}
|
|
32
32
|
${(x) => x.getTitleBasedOnActionOrType(ModalFormType.Create)}
|
|
33
33
|
</${prefix}-button>
|
|
34
34
|
`)}
|
|
@@ -71,13 +71,13 @@ export const crudButtonsTemplate = (prefix, position) => html `
|
|
|
71
71
|
${addButtonTemplate(prefix)}
|
|
72
72
|
${when((x) => x.crudMenuPosition !== CrudMenuPosition.Column, html `
|
|
73
73
|
${when((x) => x.updateEvent && !x.hideEdit, html `
|
|
74
|
-
<${prefix}-button class="crud-button" appearance="neutral" title="Select an item from the grid to enable editing" @click=${(x, y) => x.emitCrud('edit')} disabled=${(x) => (x.hasSelectedEntity ? null : 'disabled')}>
|
|
74
|
+
<${prefix}-button part="edit-button" class="crud-button" appearance="neutral" title="Select an item from the grid to enable editing" @click=${(x, y) => x.emitCrud('edit')} disabled=${(x) => (x.hasSelectedEntity ? null : 'disabled')}>
|
|
75
75
|
<${prefix}-icon size="lg" name="pen"></${prefix}-icon>
|
|
76
76
|
${(x) => x.getTitleBasedOnActionOrType(ModalFormType.Update)}
|
|
77
77
|
</${prefix}-button>
|
|
78
78
|
`)}
|
|
79
79
|
${when((x) => x.deleteEvent && !x.hideDelete, html `
|
|
80
|
-
<${prefix}-button class="crud-button" appearance="neutral" title="Select an item from the grid to enable deleting" @click=${(x, y) => x.emitCrud('delete')} disabled=${(x) => (x.hasSelectedEntity ? null : 'disabled')}>
|
|
80
|
+
<${prefix}-button part="delete-button" class="crud-button" appearance="neutral" title="Select an item from the grid to enable deleting" @click=${(x, y) => x.emitCrud('delete')} disabled=${(x) => (x.hasSelectedEntity ? null : 'disabled')}>
|
|
81
81
|
<${prefix}-icon size="lg" name="trash-alt"></${prefix}-icon>
|
|
82
82
|
${(x) => x.getTitleBasedOnActionOrType(CrudAction.Delete)}
|
|
83
83
|
</${prefix}-button>
|
|
@@ -1,27 +1,155 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { css, customElement } from '@genesislcap/web-core';
|
|
2
|
+
import { attr, css, customElement, observable } from '@genesislcap/web-core';
|
|
3
|
+
import { CrudMenuPosition } from '../types';
|
|
3
4
|
import { EntityManagement } from './entities';
|
|
4
5
|
import { styles } from './entities.styles';
|
|
5
6
|
import { template } from './entities.template';
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* A focused form dialog component that renders a single trigger button which opens a modal
|
|
9
|
+
* containing an auto-generated form.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* `smart-form-modal` is a trimmed-down variant of {@link EntityManagement} intended for
|
|
13
|
+
* single-action use cases — approval submissions, bespoke inserts —
|
|
14
|
+
* where you want a button that opens a form modal without the accompanying data grid.
|
|
15
|
+
*
|
|
16
|
+
* The component inherits the full `entity-management` API but exposes a purpose-fit surface
|
|
17
|
+
* of its own:
|
|
18
|
+
*
|
|
19
|
+
* | `smart-form-modal` attr | Underlying property | Notes |
|
|
20
|
+
* |---|---|---|
|
|
21
|
+
* | `event` | `createEvent` | The Genesis event handler that processes the form submission |
|
|
22
|
+
* | `button-label` | `createLabel` | Button and modal title text; replaces the default "Add {entityLabel}" |
|
|
23
|
+
* | `form-ui-schema` (`:formUiSchema`) | `createFormUiSchema` | UI schema passed as a property binding |
|
|
24
|
+
* | `success-notification-title` | — | Overrides the toast title shown on successful submit |
|
|
25
|
+
* | `success-notification-body` | — | Overrides the toast body shown on successful submit |
|
|
26
|
+
*
|
|
27
|
+
* The underlying `entity-management` attributes (`createEvent`, `createFormUiSchema`,
|
|
28
|
+
* `create-label`, `confirmation-message`, `default-entity-values`, `design-system-prefix`,
|
|
29
|
+
* `set-approval-message`, `approval-message-label`, `form-renderers`,
|
|
30
|
+
* `additional-form-renderers`, `readonly`) all continue to work — the aliases listed above
|
|
31
|
+
* are simply the preferred vocabulary for this component.
|
|
32
|
+
*
|
|
33
|
+
* Attributes that belong to the grid (`updateEvent`, `deleteEvent`, `columns`, `gridOptions`,
|
|
34
|
+
* `datasource-config`, `resource-name`, `enable-search-bar`, `enable-filter-bar`, etc.) are
|
|
35
|
+
* inherited but have no effect because the grid is always hidden.
|
|
36
|
+
*
|
|
37
|
+
* **Defaults that differ from `entity-management`:**
|
|
38
|
+
* - `modalPosition` defaults to `'centre'` (entity-management defaults to `'right'`)
|
|
39
|
+
* - `crudMenuPosition` defaults to `'top'` (entity-management defaults to `'column'`)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* Minimal usage — form fields are auto-generated from the event schema:
|
|
43
|
+
* ```html
|
|
44
|
+
* <smart-form-modal
|
|
45
|
+
* event="EVENT_TRADE_INSERT"
|
|
46
|
+
* entity-label="Trade"
|
|
47
|
+
* ></smart-form-modal>
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* Custom action label with styled button via CSS part:
|
|
52
|
+
* ```html
|
|
53
|
+
* <smart-form-modal
|
|
54
|
+
* event="EVENT_PRICE_REJECT"
|
|
55
|
+
* button-label="Reject Price"
|
|
56
|
+
* success-notification-title="Price Rejected"
|
|
57
|
+
* success-notification-body="The price was successfully rejected."
|
|
58
|
+
* ></smart-form-modal>
|
|
59
|
+
* ```
|
|
60
|
+
* ```css
|
|
61
|
+
* smart-form-modal::part(create-button) {
|
|
62
|
+
* background-color: #d32f2f;
|
|
63
|
+
* color: #fff;
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* Controlled form layout via `formUiSchema` property binding:
|
|
69
|
+
* ```html
|
|
70
|
+
* <smart-form-modal
|
|
71
|
+
* event="EVENT_COUNTERPARTY_INSERT"
|
|
72
|
+
* entity-label="Counterparty"
|
|
73
|
+
* :formUiSchema="${() => myUiSchema}"
|
|
74
|
+
* ></smart-form-modal>
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* Confirmation dialog before submit:
|
|
79
|
+
* ```html
|
|
80
|
+
* <smart-form-modal
|
|
81
|
+
* event="EVENT_COUNTERPARTY_INSERT"
|
|
82
|
+
* entity-label="Counterparty"
|
|
83
|
+
* confirmation-message="Are you sure you want to submit?"
|
|
84
|
+
* ></smart-form-modal>
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* Read-only view mode:
|
|
89
|
+
* ```html
|
|
90
|
+
* <smart-form-modal
|
|
91
|
+
* event="EVENT_TRADE_INSERT"
|
|
92
|
+
* entity-label="Trade"
|
|
93
|
+
* readonly
|
|
94
|
+
* ></smart-form-modal>
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @csspart create-button - The trigger button that opens the modal. Style via `::part(create-button)`.
|
|
98
|
+
*
|
|
99
|
+
* @fires submit-success - Fired when the form is submitted successfully.
|
|
100
|
+
* @fires submit-failure - Fired when the form submission returns an error.
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
10
103
|
*/
|
|
11
104
|
let SmartFormModal = class SmartFormModal extends EntityManagement {
|
|
12
105
|
constructor() {
|
|
13
106
|
super(...arguments);
|
|
107
|
+
/** @internal */
|
|
14
108
|
this.gridVisible = false;
|
|
109
|
+
/** @internal */
|
|
110
|
+
this.modalPosition = 'centre';
|
|
111
|
+
/** @internal */
|
|
112
|
+
this.crudMenuPosition = CrudMenuPosition.Top;
|
|
113
|
+
}
|
|
114
|
+
eventChanged(_, next) {
|
|
115
|
+
this.createEvent = next;
|
|
116
|
+
}
|
|
117
|
+
formUiSchemaChanged(_, next) {
|
|
118
|
+
this.createFormUiSchema = next;
|
|
119
|
+
}
|
|
120
|
+
buttonLabelChanged(_, next) {
|
|
121
|
+
this.createLabel = next;
|
|
15
122
|
}
|
|
16
123
|
};
|
|
124
|
+
__decorate([
|
|
125
|
+
attr({ attribute: 'event' })
|
|
126
|
+
], SmartFormModal.prototype, "event", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
attr({ attribute: 'entity-label' })
|
|
129
|
+
], SmartFormModal.prototype, "entityLabel", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
observable
|
|
132
|
+
], SmartFormModal.prototype, "formUiSchema", void 0);
|
|
133
|
+
__decorate([
|
|
134
|
+
attr({ attribute: 'button-label' })
|
|
135
|
+
], SmartFormModal.prototype, "buttonLabel", void 0);
|
|
17
136
|
SmartFormModal = __decorate([
|
|
18
137
|
customElement({
|
|
19
138
|
name: 'smart-form-modal',
|
|
20
139
|
template,
|
|
21
140
|
styles: css `
|
|
22
141
|
${styles}
|
|
142
|
+
/*
|
|
143
|
+
* The modal variant renders a single trigger button through the shared grid
|
|
144
|
+
* header scaffolding, which is laid out as a right-aligned toolbar. For a
|
|
145
|
+
* single-action launcher there is no toolbar to preserve, so neutralise the
|
|
146
|
+
* inherited right-alignment and let the trigger fill its host/cell. Scoped to
|
|
147
|
+
* this component only — the shared styles keep the grid's right-aligned toolbar.
|
|
148
|
+
*/
|
|
23
149
|
:host {
|
|
24
150
|
padding: 0;
|
|
151
|
+
/* was implicitly inline (only \`contain: content\` set) -> collapsed to content width */
|
|
152
|
+
display: block;
|
|
25
153
|
}
|
|
26
154
|
|
|
27
155
|
.container {
|
|
@@ -30,12 +158,30 @@ SmartFormModal = __decorate([
|
|
|
30
158
|
|
|
31
159
|
:host::part(header) {
|
|
32
160
|
padding: 0;
|
|
161
|
+
margin-left: 0;
|
|
162
|
+
width: 100%;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.search-container {
|
|
166
|
+
justify-content: stretch;
|
|
33
167
|
}
|
|
34
168
|
|
|
35
169
|
.crud-buttons-wrapper-column,
|
|
36
170
|
.crud-buttons-wrapper-top {
|
|
37
171
|
flex: 1;
|
|
38
172
|
padding: 0;
|
|
173
|
+
width: 100%;
|
|
174
|
+
justify-content: stretch;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.crud-buttons-column,
|
|
178
|
+
.crud-buttons-top {
|
|
179
|
+
width: 100%;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
[part~='create-button'] {
|
|
183
|
+
flex: 1 1 auto;
|
|
184
|
+
width: 100%;
|
|
39
185
|
}
|
|
40
186
|
`,
|
|
41
187
|
})
|