@memberjunction/ng-entity-form-dialog 4.0.0 → 4.2.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 +73 -226
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
# @memberjunction/ng-entity-form-dialog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A reusable Angular dialog component that displays a MemberJunction entity form for viewing and/or editing any record from any entity. Supports showing the complete form or a specific section.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The `EntityFormDialogComponent` wraps MemberJunction's dynamic form system inside a Kendo UI dialog window. It dynamically loads the registered form component for the given entity (including custom form overrides) and provides configurable Save/Cancel buttons with automatic record handling.
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
graph TD
|
|
11
|
+
PARENT["Parent Component"] --> EFD["EntityFormDialogComponent"]
|
|
12
|
+
EFD --> KD["Kendo Dialog Window"]
|
|
13
|
+
EFD --> CD["ContainerDirective\n(Dynamic Loading)"]
|
|
14
|
+
CD --> BFC["BaseFormComponent\n(or subclass)"]
|
|
15
|
+
BFC --> BFSC["BaseFormSectionComponent"]
|
|
16
|
+
|
|
17
|
+
style PARENT fill:#7c5295,stroke:#563a6b,color:#fff
|
|
18
|
+
style EFD fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
19
|
+
style KD fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
20
|
+
style CD fill:#b8762f,stroke:#8a5722,color:#fff
|
|
21
|
+
style BFC fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
22
|
+
style BFSC fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
23
|
+
```
|
|
4
24
|
|
|
5
25
|
## Features
|
|
6
26
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
- Integration with MemberJunction entity management system
|
|
27
|
+
- **Universal entity support**: Works with any MemberJunction entity
|
|
28
|
+
- **Two display modes**: Complete form or single named section
|
|
29
|
+
- **Configurable buttons**: Show/hide Save and Cancel independently
|
|
30
|
+
- **Automatic save handling**: Optionally saves the record when user clicks Save
|
|
31
|
+
- **Auto-revert on cancel**: Optionally reverts record changes when user cancels
|
|
32
|
+
- **Resizable dialog**: Configurable width and height with user-resizable window
|
|
33
|
+
- **Dynamic form loading**: Uses `@RegisterClass` to load the correct form component
|
|
15
34
|
|
|
16
35
|
## Installation
|
|
17
36
|
|
|
@@ -19,242 +38,70 @@ Angular component for displaying MemberJunction entity forms in a modal dialog,
|
|
|
19
38
|
npm install @memberjunction/ng-entity-form-dialog
|
|
20
39
|
```
|
|
21
40
|
|
|
22
|
-
## Dependencies
|
|
23
|
-
|
|
24
|
-
This package requires the following peer dependencies:
|
|
25
|
-
- `@angular/common`: ^18.0.2
|
|
26
|
-
- `@angular/core`: ^18.0.2
|
|
27
|
-
- `@angular/forms`: ^18.0.2
|
|
28
|
-
- `@angular/router`: ^18.0.2
|
|
29
|
-
|
|
30
|
-
The package also depends on:
|
|
31
|
-
- `@memberjunction/core`: For BaseEntity support
|
|
32
|
-
- `@memberjunction/ng-base-forms`: For form components
|
|
33
|
-
- `@memberjunction/ng-shared`: For shared services
|
|
34
|
-
- `@progress/kendo-angular-dialog`: For dialog UI
|
|
35
|
-
- `@progress/kendo-angular-buttons`: For button UI
|
|
36
|
-
|
|
37
|
-
## Module Setup
|
|
38
|
-
|
|
39
|
-
Import the module in your Angular application:
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import { EntityFormDialogModule } from '@memberjunction/ng-entity-form-dialog';
|
|
43
|
-
|
|
44
|
-
@NgModule({
|
|
45
|
-
imports: [
|
|
46
|
-
CommonModule,
|
|
47
|
-
FormsModule,
|
|
48
|
-
EntityFormDialogModule
|
|
49
|
-
]
|
|
50
|
-
})
|
|
51
|
-
export class YourModule { }
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Usage Examples
|
|
55
|
-
|
|
56
|
-
### Basic Usage
|
|
57
|
-
|
|
58
|
-
```html
|
|
59
|
-
<mj-entity-form-dialog
|
|
60
|
-
[Record]="myEntityRecord"
|
|
61
|
-
[Visible]="showDialog"
|
|
62
|
-
(DialogClosed)="onDialogClosed($event)">
|
|
63
|
-
</mj-entity-form-dialog>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Complete Form Mode
|
|
41
|
+
## Key Dependencies
|
|
67
42
|
|
|
68
|
-
|
|
43
|
+
| Dependency | Purpose |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `@memberjunction/core` | Entity metadata, BaseEntity |
|
|
46
|
+
| `@memberjunction/ng-base-forms` | BaseFormComponent, BaseFormSectionComponent |
|
|
47
|
+
| `@memberjunction/ng-container-directives` | Dynamic component loading |
|
|
48
|
+
| `@memberjunction/ng-shared` | SharedService |
|
|
49
|
+
| `@progress/kendo-angular-dialog` | Kendo UI dialog window |
|
|
50
|
+
| `@progress/kendo-angular-buttons` | Dialog action buttons |
|
|
69
51
|
|
|
70
|
-
|
|
71
|
-
<mj-entity-form-dialog
|
|
72
|
-
Title="Edit User"
|
|
73
|
-
[Record]="userRecord"
|
|
74
|
-
Mode="complete"
|
|
75
|
-
[Visible]="showDialog"
|
|
76
|
-
[Width]="800"
|
|
77
|
-
[Height]="600"
|
|
78
|
-
[HandleSave]="true"
|
|
79
|
-
[AutoRevertOnCancel]="true"
|
|
80
|
-
(DialogClosed)="onDialogClosed($event)">
|
|
81
|
-
</mj-entity-form-dialog>
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Section Mode
|
|
85
|
-
|
|
86
|
-
Display only a specific section of a form:
|
|
52
|
+
## Usage
|
|
87
53
|
|
|
88
54
|
```html
|
|
89
55
|
<mj-entity-form-dialog
|
|
90
|
-
Title="Edit
|
|
91
|
-
[Record]="
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
[
|
|
95
|
-
[
|
|
96
|
-
[Height]="350"
|
|
56
|
+
[Title]="'Edit Contact'"
|
|
57
|
+
[Record]="contactRecord"
|
|
58
|
+
[Visible]="isDialogOpen"
|
|
59
|
+
[Mode]="'complete'"
|
|
60
|
+
[ShowSaveButton]="true"
|
|
61
|
+
[ShowCancelButton]="true"
|
|
97
62
|
[HandleSave]="true"
|
|
98
63
|
[AutoRevertOnCancel]="true"
|
|
64
|
+
[Width]="800"
|
|
65
|
+
[Height]="600"
|
|
99
66
|
(DialogClosed)="onDialogClosed($event)">
|
|
100
67
|
</mj-entity-form-dialog>
|
|
101
68
|
```
|
|
102
69
|
|
|
103
|
-
###
|
|
70
|
+
### Inputs
|
|
104
71
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
@Component({
|
|
110
|
-
selector: 'app-user-management',
|
|
111
|
-
template: `
|
|
112
|
-
<button (click)="editUser()">Edit User</button>
|
|
113
|
-
|
|
114
|
-
<mj-entity-form-dialog
|
|
115
|
-
Title="Edit User"
|
|
116
|
-
[Record]="userRecord"
|
|
117
|
-
[Visible]="showDialog"
|
|
118
|
-
[HandleSave]="true"
|
|
119
|
-
[AutoRevertOnCancel]="true"
|
|
120
|
-
(DialogClosed)="onDialogClosed($event)">
|
|
121
|
-
</mj-entity-form-dialog>
|
|
122
|
-
`
|
|
123
|
-
})
|
|
124
|
-
export class UserManagementComponent {
|
|
125
|
-
userRecord: BaseEntity | null = null;
|
|
126
|
-
showDialog = false;
|
|
127
|
-
|
|
128
|
-
async editUser() {
|
|
129
|
-
// Load user record using MemberJunction metadata system
|
|
130
|
-
const md = new Metadata();
|
|
131
|
-
this.userRecord = await md.GetEntityObject('Users');
|
|
132
|
-
await this.userRecord.Load(userId);
|
|
133
|
-
|
|
134
|
-
// Show the dialog
|
|
135
|
-
this.showDialog = true;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
onDialogClosed(result: 'Save' | 'Cancel') {
|
|
139
|
-
if (result === 'Save') {
|
|
140
|
-
// Handle successful save
|
|
141
|
-
console.log('User saved successfully');
|
|
142
|
-
// Refresh your UI or perform other actions
|
|
143
|
-
} else {
|
|
144
|
-
// Handle cancel - changes are automatically reverted if AutoRevertOnCancel is true
|
|
145
|
-
console.log('Edit cancelled');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Hide the dialog
|
|
149
|
-
this.showDialog = false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## API Reference
|
|
155
|
-
|
|
156
|
-
### Input Properties
|
|
157
|
-
|
|
158
|
-
| Property | Type | Default | Description |
|
|
159
|
-
|----------|------|---------|-------------|
|
|
160
|
-
| `Title` | `string` | `''` | The title displayed in the dialog header |
|
|
161
|
-
| `ShowSaveButton` | `boolean` | `true` | Whether to display the Save button |
|
|
162
|
-
| `ShowCancelButton` | `boolean` | `true` | Whether to display the Cancel button |
|
|
163
|
-
| `Width` | `number` | `800` | Initial dialog width in pixels |
|
|
164
|
-
| `Height` | `number` | `600` | Initial dialog height in pixels |
|
|
165
|
-
| `Mode` | `'complete' \| 'section'` | `'complete'` | Display mode - entire form or specific section |
|
|
166
|
-
| `SectionName` | `string` | `''` | The section name to display (required when Mode is 'section') |
|
|
167
|
-
| `Record` | `BaseEntity \| null` | `null` | The entity record to edit (required) |
|
|
168
|
-
| `HandleSave` | `boolean` | `true` | Automatically save the record when Save is clicked |
|
|
169
|
-
| `AutoRevertOnCancel` | `boolean` | `true` | Automatically revert changes when Cancel is clicked |
|
|
72
|
+
| Input | Type | Default | Description |
|
|
73
|
+
|---|---|---|---|
|
|
74
|
+
| `Title` | `string` | `''` | Dialog title bar text |
|
|
75
|
+
| `Record` | `BaseEntity` | `null` | The entity record to display |
|
|
170
76
|
| `Visible` | `boolean` | `false` | Controls dialog visibility |
|
|
77
|
+
| `Mode` | `'complete' \| 'section'` | `'complete'` | Show entire form or specific section |
|
|
78
|
+
| `SectionName` | `string` | `''` | Section name (when Mode is `'section'`) |
|
|
79
|
+
| `ShowSaveButton` | `boolean` | `true` | Show the Save button |
|
|
80
|
+
| `ShowCancelButton` | `boolean` | `true` | Show the Cancel button |
|
|
81
|
+
| `HandleSave` | `boolean` | `true` | Auto-save record on Save click |
|
|
82
|
+
| `AutoRevertOnCancel` | `boolean` | `true` | Auto-revert record on Cancel click |
|
|
83
|
+
| `Width` | `number` | `800` | Dialog width in pixels |
|
|
84
|
+
| `Height` | `number` | `600` | Dialog height in pixels |
|
|
171
85
|
|
|
172
|
-
###
|
|
173
|
-
|
|
174
|
-
| Event | Type | Description |
|
|
175
|
-
|-------|------|-------------|
|
|
176
|
-
| `DialogClosed` | `EventEmitter<'Save' \| 'Cancel'>` | Emitted when the dialog is closed with the action taken |
|
|
86
|
+
### Outputs
|
|
177
87
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Programmatically shows the form. This is automatically called when the `Visible` property is set to `true`.
|
|
182
|
-
|
|
183
|
-
```typescript
|
|
184
|
-
@ViewChild(EntityFormDialogComponent) formDialog!: EntityFormDialogComponent;
|
|
185
|
-
|
|
186
|
-
showFormProgrammatically() {
|
|
187
|
-
this.formDialog.ShowForm();
|
|
188
|
-
}
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
#### `CloseWindow(status: 'Save' | 'Cancel')`
|
|
192
|
-
Programmatically closes the dialog with the specified status.
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
closeDialogProgrammatically() {
|
|
196
|
-
this.formDialog.CloseWindow('Cancel');
|
|
197
|
-
}
|
|
198
|
-
```
|
|
88
|
+
| Output | Type | Description |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| `DialogClosed` | `EventEmitter<'Save' \| 'Cancel'>` | Emitted when dialog closes with action taken |
|
|
199
91
|
|
|
200
|
-
##
|
|
92
|
+
## Exported API
|
|
201
93
|
|
|
202
|
-
|
|
94
|
+
| Export | Type | Description |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `EntityFormDialogComponent` | Component | The dialog component |
|
|
97
|
+
| `EntityFormDialogModule` | NgModule | Module declaration |
|
|
203
98
|
|
|
204
|
-
|
|
205
|
-
Register a subclass of `BaseFormComponent` with the entity name:
|
|
206
|
-
```typescript
|
|
207
|
-
import { RegisterClass } from '@memberjunction/global';
|
|
208
|
-
import { BaseFormComponent } from '@memberjunction/ng-base-forms';
|
|
99
|
+
## Build
|
|
209
100
|
|
|
210
|
-
@RegisterClass(BaseFormComponent, 'Users')
|
|
211
|
-
export class UserFormComponent extends BaseFormComponent {
|
|
212
|
-
// Your form implementation
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### For Section Mode
|
|
217
|
-
Register a subclass of `BaseFormSectionComponent` with the pattern `EntityName.SectionName`:
|
|
218
|
-
```typescript
|
|
219
|
-
import { RegisterClass } from '@memberjunction/global';
|
|
220
|
-
import { BaseFormSectionComponent } from '@memberjunction/ng-base-forms';
|
|
221
|
-
|
|
222
|
-
@RegisterClass(BaseFormSectionComponent, 'Users.details')
|
|
223
|
-
export class UserDetailsSectionComponent extends BaseFormSectionComponent {
|
|
224
|
-
// Your section implementation
|
|
225
|
-
}
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
## Error Handling
|
|
229
|
-
|
|
230
|
-
The component includes built-in error handling for save operations:
|
|
231
|
-
|
|
232
|
-
- If `HandleSave` is `true` and the save operation fails, the component will:
|
|
233
|
-
1. Display an error notification using `SharedService`
|
|
234
|
-
2. Automatically revert the changes to prevent data corruption
|
|
235
|
-
3. Still emit the `DialogClosed` event with 'Save' status
|
|
236
|
-
|
|
237
|
-
## Best Practices
|
|
238
|
-
|
|
239
|
-
1. **Always provide a Record**: The `Record` property is required and must be a valid BaseEntity instance
|
|
240
|
-
2. **Handle the DialogClosed event**: Always implement a handler to manage dialog visibility
|
|
241
|
-
3. **Use proper entity loading**: Load entities using MemberJunction's Metadata system
|
|
242
|
-
4. **Register form components**: Ensure your custom form components are properly registered
|
|
243
|
-
5. **Consider dialog dimensions**: Adjust `Width` and `Height` based on your form complexity
|
|
244
|
-
|
|
245
|
-
## Integration with Other MemberJunction Packages
|
|
246
|
-
|
|
247
|
-
This package integrates seamlessly with:
|
|
248
|
-
- `@memberjunction/core`: For entity management
|
|
249
|
-
- `@memberjunction/ng-base-forms`: For form component base classes
|
|
250
|
-
- `@memberjunction/ng-shared`: For notification services
|
|
251
|
-
- `@memberjunction/global`: For class factory registration
|
|
252
|
-
|
|
253
|
-
## Building
|
|
254
|
-
|
|
255
|
-
To build the package:
|
|
256
101
|
```bash
|
|
257
|
-
npm run build
|
|
102
|
+
cd packages/Angular/Explorer/entity-form-dialog && npm run build
|
|
258
103
|
```
|
|
259
104
|
|
|
260
|
-
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
ISC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-entity-form-dialog",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "MemberJunction: Dialog component that is able to display a form for display and/or editing for any record from any entity in MemberJunction.",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"@angular/router": "21.1.3"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@memberjunction/core-entities": "4.
|
|
29
|
-
"@memberjunction/global": "4.
|
|
30
|
-
"@memberjunction/core": "4.
|
|
31
|
-
"@memberjunction/ng-container-directives": "4.
|
|
32
|
-
"@memberjunction/ng-shared": "4.
|
|
33
|
-
"@memberjunction/ng-base-forms": "4.
|
|
28
|
+
"@memberjunction/core-entities": "4.2.0",
|
|
29
|
+
"@memberjunction/global": "4.2.0",
|
|
30
|
+
"@memberjunction/core": "4.2.0",
|
|
31
|
+
"@memberjunction/ng-container-directives": "4.2.0",
|
|
32
|
+
"@memberjunction/ng-shared": "4.2.0",
|
|
33
|
+
"@memberjunction/ng-base-forms": "4.2.0",
|
|
34
34
|
"@progress/kendo-angular-buttons": "22.0.1",
|
|
35
35
|
"@progress/kendo-angular-dialog": "22.0.1",
|
|
36
36
|
"tslib": "^2.8.1"
|