@memberjunction/ng-entity-form-dialog 2.43.0 → 2.44.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.
Files changed (2) hide show
  1. package/README.md +172 -41
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -1,15 +1,17 @@
1
1
  # @memberjunction/ng-entity-form-dialog
2
2
 
3
- Angular component for displaying MemberJunction entity forms in a dialog, with support for both complete forms and individual form sections.
3
+ Angular component for displaying MemberJunction entity forms in a modal dialog, with support for both complete forms and individual form sections. This component provides a reusable dialog wrapper that dynamically loads the appropriate form component based on the entity type and configuration.
4
4
 
5
5
  ## Features
6
6
 
7
- - Display entity forms in a modal dialog
8
- - Support for displaying the complete form or specific sections
9
- - Configurable save and cancel behavior
10
- - Automatic form component loading based on entity type
7
+ - Display entity forms in a modal dialog powered by Kendo UI
8
+ - Support for displaying complete forms or specific form sections
9
+ - Automatic save functionality with error handling
10
+ - Configurable cancel behavior with automatic change reversion
11
+ - Dynamic form component loading using MemberJunction's class factory system
11
12
  - Customizable dialog dimensions and appearance
12
- - Integration with MemberJunction entity management
13
+ - TypeScript support with full type safety
14
+ - Integration with MemberJunction entity management system
13
15
 
14
16
  ## Installation
15
17
 
@@ -17,22 +19,40 @@ Angular component for displaying MemberJunction entity forms in a dialog, with s
17
19
  npm install @memberjunction/ng-entity-form-dialog
18
20
  ```
19
21
 
20
- ## Usage
22
+ ## Dependencies
21
23
 
22
- Import the module in your application:
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:
23
40
 
24
41
  ```typescript
25
42
  import { EntityFormDialogModule } from '@memberjunction/ng-entity-form-dialog';
26
43
 
27
44
  @NgModule({
28
45
  imports: [
29
- // ...
46
+ CommonModule,
47
+ FormsModule,
30
48
  EntityFormDialogModule
31
49
  ]
32
50
  })
33
51
  export class YourModule { }
34
52
  ```
35
53
 
54
+ ## Usage Examples
55
+
36
56
  ### Basic Usage
37
57
 
38
58
  ```html
@@ -80,50 +100,161 @@ Display only a specific section of a form:
80
100
  </mj-entity-form-dialog>
81
101
  ```
82
102
 
83
- ## Input Properties
103
+ ### Component Implementation
104
+
105
+ ```typescript
106
+ import { Component } from '@angular/core';
107
+ import { BaseEntity, Metadata } from '@memberjunction/core';
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
84
157
 
85
158
  | Property | Type | Default | Description |
86
159
  |----------|------|---------|-------------|
87
- | Title | string | '' | Dialog title |
88
- | ShowSaveButton | boolean | true | Whether to show the Save button |
89
- | ShowCancelButton | boolean | true | Whether to show the Cancel button |
90
- | Width | number | 800 | Dialog width in pixels |
91
- | Height | number | 600 | Dialog height in pixels |
92
- | Mode | 'complete' \| 'section' | 'complete' | Whether to show the entire form or a specific section |
93
- | SectionName | string | '' | The section name to display (when Mode is 'section') |
94
- | Record | BaseEntity | null | The entity record to edit (required) |
95
- | HandleSave | boolean | true | Whether to automatically save the record on Save click |
96
- | AutoRevertOnCancel | boolean | true | Whether to automatically revert changes on Cancel click |
97
- | Visible | boolean | false | Controls dialog visibility |
98
-
99
- ## Output Events
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 |
170
+ | `Visible` | `boolean` | `false` | Controls dialog visibility |
171
+
172
+ ### Output Events
100
173
 
101
174
  | Event | Type | Description |
102
175
  |-------|------|-------------|
103
- | DialogClosed | EventEmitter<'Save' \| 'Cancel'> | Emitted when the dialog is closed |
176
+ | `DialogClosed` | `EventEmitter<'Save' \| 'Cancel'>` | Emitted when the dialog is closed with the action taken |
177
+
178
+ ### Public Methods
104
179
 
105
- ## Handling Dialog Close
180
+ #### `ShowForm()`
181
+ Programmatically shows the form. This is automatically called when the `Visible` property is set to `true`.
106
182
 
107
183
  ```typescript
108
- onDialogClosed(result: 'Save' | 'Cancel') {
109
- if (result === 'Save') {
110
- // Handle successful save
111
- console.log('Record saved');
112
- } else {
113
- // Handle cancel
114
- console.log('Edit cancelled');
115
- }
116
-
117
- // Hide the dialog
118
- this.showDialog = false;
184
+ @ViewChild(EntityFormDialogComponent) formDialog!: EntityFormDialogComponent;
185
+
186
+ showFormProgrammatically() {
187
+ this.formDialog.ShowForm();
119
188
  }
120
189
  ```
121
190
 
122
- ## Dynamic Form Loading
191
+ #### `CloseWindow(status: 'Save' | 'Cancel')`
192
+ Programmatically closes the dialog with the specified status.
123
193
 
124
- The component automatically loads the appropriate form component based on the entity type:
194
+ ```typescript
195
+ closeDialogProgrammatically() {
196
+ this.formDialog.CloseWindow('Cancel');
197
+ }
198
+ ```
125
199
 
126
- - In 'complete' mode, it loads a subclass of `BaseFormComponent` for the entity
127
- - In 'section' mode, it loads a subclass of `BaseFormSectionComponent` for the entity and section
200
+ ## Form Component Registration
201
+
202
+ The dialog dynamically loads form components based on the entity type and mode. These components must be registered with MemberJunction's class factory system:
203
+
204
+ ### For Complete Mode
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';
209
+
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
+ ```bash
257
+ npm run build
258
+ ```
128
259
 
129
- These components must be registered with the MemberJunction class factory system.
260
+ The package uses Angular's `ngc` compiler and outputs to the `dist` directory.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-entity-form-dialog",
3
- "version": "2.43.0",
3
+ "version": "2.44.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": "18.0.2"
26
26
  },
27
27
  "dependencies": {
28
- "@memberjunction/core-entities": "2.43.0",
29
- "@memberjunction/global": "2.43.0",
30
- "@memberjunction/core": "2.43.0",
31
- "@memberjunction/ng-container-directives": "2.43.0",
32
- "@memberjunction/ng-shared": "2.43.0",
33
- "@memberjunction/ng-base-forms": "2.43.0",
28
+ "@memberjunction/core-entities": "2.44.0",
29
+ "@memberjunction/global": "2.44.0",
30
+ "@memberjunction/core": "2.44.0",
31
+ "@memberjunction/ng-container-directives": "2.44.0",
32
+ "@memberjunction/ng-shared": "2.44.0",
33
+ "@memberjunction/ng-base-forms": "2.44.0",
34
34
  "@progress/kendo-angular-buttons": "16.2.0",
35
35
  "@progress/kendo-angular-dialog": "16.2.0",
36
36
  "tslib": "^2.3.0"