@memberjunction/ng-form-toolbar 2.42.1 → 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 +327 -77
  2. package/package.json +8 -8
package/README.md CHANGED
@@ -1,18 +1,19 @@
1
1
  # @memberjunction/ng-form-toolbar
2
2
 
3
- The `@memberjunction/ng-form-toolbar` package provides a consistent toolbar component for forms in MemberJunction Explorer applications. It handles standard form operations like editing, saving, deleting records, and provides additional functionality such as favoriting, viewing history, and adding records to lists.
3
+ The `@memberjunction/ng-form-toolbar` package provides a consistent, feature-rich toolbar component for forms in MemberJunction Explorer applications. It handles standard form operations like editing, saving, and deleting records, while providing advanced functionality such as favorites management, record history viewing, AI-powered chat integration, and list management.
4
4
 
5
5
  ## Features
6
6
 
7
- - Context-aware button display based on form state (view/edit mode)
8
- - Save functionality with visual feedback during save operations
9
- - Delete confirmation with dependency checking
10
- - Record history viewing (for trackable entities)
11
- - Ability to add records to lists
12
- - Skip AI chat integration for record-based conversations
13
- - Favorite toggling for quick access to frequently used records
14
- - Consistent UI across all MemberJunction forms
15
- - Permission-based button visibility
7
+ - **Context-aware button display** - Dynamically shows/hides buttons based on form state (view/edit mode)
8
+ - **Save with real-time feedback** - Visual status updates during save operations with elapsed time tracking
9
+ - **Smart delete functionality** - Dependency checking before deletion with confirmation dialog
10
+ - **Record history tracking** - View change history for entities with tracking enabled
11
+ - **Skip AI chat integration** - Discuss records with AI assistant directly from the toolbar
12
+ - **Favorites management** - Mark frequently accessed records as favorites for quick access
13
+ - **List management** - Add records to existing lists for organization
14
+ - **Permission-based visibility** - Buttons respect user permissions (edit, delete, etc.)
15
+ - **Server update notifications** - Real-time status updates from server during long operations
16
+ - **Consistent UX** - Unified toolbar experience across all MemberJunction forms
16
17
 
17
18
  ## Installation
18
19
 
@@ -23,67 +24,92 @@ npm install @memberjunction/ng-form-toolbar
23
24
  ## Requirements
24
25
 
25
26
  - Angular 18+
26
- - @memberjunction/core
27
- - @memberjunction/ng-base-forms
28
- - @memberjunction/ng-shared
29
- - @memberjunction/ng-ask-skip
30
- - @memberjunction/ng-record-changes
31
- - @progress/kendo-angular-buttons
32
- - @progress/kendo-angular-dialog
27
+ - @memberjunction/global ^2.43.0
28
+ - @memberjunction/core ^2.43.0
29
+ - @memberjunction/ng-shared ^2.43.0
30
+ - @memberjunction/ng-base-forms ^2.43.0
31
+ - @memberjunction/ng-ask-skip ^2.43.0
32
+ - @memberjunction/ng-record-changes ^2.43.0
33
+ - @memberjunction/ng-container-directives ^2.43.0
34
+ - @progress/kendo-angular-buttons ^16.2.0
35
+ - @progress/kendo-angular-dialog ^16.2.0
36
+ - ngx-markdown ^18.0.0
33
37
 
34
38
  ## Usage
35
39
 
36
40
  ### Basic Setup
37
41
 
38
- First, import the FormToolbarModule in your module:
42
+ First, import the `FormToolbarModule` in your Angular module:
39
43
 
40
44
  ```typescript
41
45
  import { FormToolbarModule } from '@memberjunction/ng-form-toolbar';
42
46
 
43
47
  @NgModule({
44
48
  imports: [
45
- // other imports...
49
+ CommonModule,
50
+ FormsModule,
51
+ // ... other imports
46
52
  FormToolbarModule
47
53
  ],
54
+ // ... rest of module configuration
48
55
  })
49
56
  export class YourModule { }
50
57
  ```
51
58
 
52
59
  ### Adding the Toolbar to a Form
53
60
 
54
- The toolbar is designed to work with forms that extend `BaseFormComponent`. Simply add it to your form template:
61
+ The toolbar is designed to work seamlessly with forms that extend `BaseFormComponent`. Add it to your form template:
55
62
 
56
63
  ```html
64
+ <!-- Basic usage -->
57
65
  <mj-form-toolbar [form]="this"></mj-form-toolbar>
66
+
67
+ <!-- Your form content -->
68
+ <form>
69
+ <!-- Form fields and controls -->
70
+ </form>
58
71
  ```
59
72
 
60
- In your component class:
73
+ Example component implementation:
61
74
 
62
75
  ```typescript
63
76
  import { Component } from '@angular/core';
64
77
  import { BaseFormComponent } from '@memberjunction/ng-base-forms';
65
- import { MyEntityEntity } from '@memberjunction/core-entities';
78
+ import { UserEntity } from '@memberjunction/core-entities';
66
79
 
67
80
  @Component({
68
- selector: 'app-my-entity-form',
69
- templateUrl: './my-entity-form.component.html',
81
+ selector: 'app-user-form',
82
+ templateUrl: './user-form.component.html',
83
+ styleUrls: ['./user-form.component.css']
70
84
  })
71
- export class MyEntityFormComponent extends BaseFormComponent {
72
- public record!: MyEntityEntity;
85
+ export class UserFormComponent extends BaseFormComponent {
86
+ public record!: UserEntity;
87
+
88
+ public async ngOnInit() {
89
+ await super.ngOnInit();
90
+ // Additional initialization logic
91
+ }
73
92
 
74
- // Your form implementation...
93
+ // Override BaseFormComponent methods as needed
75
94
  }
76
95
  ```
77
96
 
78
97
  ### Customizing the Toolbar
79
98
 
80
- You can control whether certain features are displayed:
99
+ Control which features are displayed:
81
100
 
82
101
  ```html
102
+ <!-- Hide Skip chat button -->
83
103
  <mj-form-toolbar
84
104
  [form]="this"
85
105
  [ShowSkipChatButton]="false">
86
106
  </mj-form-toolbar>
107
+
108
+ <!-- Disable toolbar programmatically -->
109
+ <mj-form-toolbar
110
+ [form]="this"
111
+ [Disabled]="isProcessing">
112
+ </mj-form-toolbar>
87
113
  ```
88
114
 
89
115
  ## API Reference
@@ -94,69 +120,293 @@ You can control whether certain features are displayed:
94
120
 
95
121
  | Name | Type | Default | Description |
96
122
  |------|------|---------|-------------|
97
- | `form` | `BaseFormComponent` | (required) | The form component that this toolbar controls |
98
- | `ShowSkipChatButton` | `boolean` | `true` | Whether to show the Skip chat button |
123
+ | `form` | `BaseFormComponent` | Required | The form component instance that this toolbar controls |
124
+ | `ShowSkipChatButton` | `boolean` | `true` | Controls visibility of the Skip AI chat button |
99
125
 
100
126
  #### Properties
101
127
 
102
128
  | Name | Type | Description |
103
129
  |------|------|-------------|
104
- | `Disabled` | `boolean` | Global setting to disable the toolbar |
105
- | `CurrentlyDisabled` | `boolean` | Whether the toolbar is currently disabled |
130
+ | `Disabled` | `boolean` | Global setting to enable/disable the entire toolbar |
131
+ | `CurrentlyDisabled` | `boolean` | Read-only property indicating if toolbar is currently disabled |
132
+ | `listDialogVisible` | `boolean` | Controls visibility of the add-to-list dialog |
133
+ | `showListDialogLoader` | `boolean` | Shows loading indicator in list dialog |
134
+ | `availableLists` | `ListEntity[]` | Lists available for adding the current record |
135
+ | `selectedLists` | `ListEntity[]` | Currently selected lists in the dialog |
106
136
 
107
137
  #### Methods
108
138
 
109
139
  | Name | Parameters | Return Type | Description |
110
140
  |------|------------|-------------|-------------|
111
- | `saveExistingRecord` | `event: MouseEvent` | `Promise<void>` | Saves the current record with visual feedback |
112
- | `ShowSkipChat` | None | `void` | Opens the Skip chat dialog for the current record |
141
+ | `saveExistingRecord` | `event: MouseEvent` | `Promise<void>` | Saves the current record with visual feedback and progress tracking |
142
+ | `ShowSkipChat` | None | `void` | Toggles the Skip AI chat dialog for the current record |
113
143
  | `toggleDeleteDialog` | `show: boolean` | `void` | Shows or hides the delete confirmation dialog |
114
- | `toggleListDialog` | `show: boolean` | `Promise<void>` | Shows or hides the add to list dialog |
144
+ | `toggleListDialog` | `show: boolean` | `Promise<void>` | Shows or hides the add-to-list dialog and loads available lists |
115
145
  | `addRecordToList` | `list: ListEntity` | `Promise<void>` | Adds the current record to the specified list |
116
- | `deleteRecord` | None | `Promise<void>` | Deletes the current record after confirmation |
146
+ | `deleteRecord` | None | `Promise<void>` | Deletes the current record after dependency check and confirmation |
117
147
 
118
- ## Toolbar States
119
-
120
- The toolbar adapts to different form states:
148
+ ## Toolbar States and Behavior
121
149
 
122
150
  ### View Mode
123
- When the form is in view mode, the toolbar displays:
124
- - Edit button (if user has edit permission)
125
- - Delete button (if user has delete permission)
126
- - Favorite/Unfavorite toggle
127
- - Record history button (if entity tracks changes)
128
- - Skip chat button (if enabled)
129
- - Add to list button
151
+ When the form is in view mode (`form.EditMode === false`), the toolbar displays:
152
+
153
+ - **Edit button** 🖊️ - Visible if user has edit permission (`form.UserCanEdit`)
154
+ - **Delete button** 🗑️ - Visible if user has delete permission (`form.UserCanDelete`)
155
+ - **Favorite/Unfavorite toggle** - Toggle between filled/outlined star based on favorite status
156
+ - **History button** 🕐 - Visible only if entity tracks changes (`EntityInfo.TrackRecordChanges`)
157
+ - **Skip chat button** 💬 - Visible if `ShowSkipChatButton` is true
158
+ - **Add to list button** ➕ - Always visible in view mode
130
159
 
131
160
  ### Edit Mode
132
- When the form is in edit mode, the toolbar displays:
133
- - Save button
134
- - Cancel button (for existing records)
135
- - Changes button (when there are unsaved changes)
136
-
137
- ## Styling
138
-
139
- The toolbar uses the following CSS classes that can be customized:
140
-
141
- - `.toolbar-container`: Main container for the toolbar
142
- - `.disabled`: Applied when the toolbar is disabled
143
- - `.button-text`: Text labels in buttons
144
- - `.btn-no-border`: Button style without border
145
- - `.list-item`, `.list-text`: Styles for list dialog items
146
- - `.form-toolbar-status-message`: Style for the save status message
147
-
148
- ## Dependencies
149
-
150
- - @angular/common
151
- - @angular/core
152
- - @angular/forms
153
- - @angular/router
154
- - @memberjunction/global
155
- - @memberjunction/core
156
- - @memberjunction/ng-shared
157
- - @memberjunction/ng-base-forms
158
- - @memberjunction/ng-ask-skip
159
- - @memberjunction/ng-record-changes
160
- - @progress/kendo-angular-buttons
161
- - @progress/kendo-angular-dialog
162
- - ngx-markdown
161
+ When the form is in edit mode (`form.EditMode === true`), the toolbar displays:
162
+
163
+ - **Save button** 💾 - Always visible with "Save" label
164
+ - **Cancel button** ↩️ - Only visible for existing records (not new records)
165
+ - **Changes button** 📋 - Only visible when record has unsaved changes (`record.Dirty`)
166
+
167
+ ### Save Operation Features
168
+
169
+ During save operations, the toolbar provides enhanced user feedback:
170
+
171
+ 1. **Visual Feedback**: Form opacity reduced to 75% and interactions disabled
172
+ 2. **Progress Tracking**: Real-time elapsed time counter (updates every 100ms)
173
+ 3. **Server Updates**: Displays server status messages via MJGlobal event system
174
+ 4. **Automatic Cleanup**: Restores form state after save completion
175
+
176
+ Example save feedback display:
177
+ ```
178
+ Saving... (3 secs)
179
+ Processing entity relationships...
180
+ ```
181
+
182
+ ## Styling and Customization
183
+
184
+ ### CSS Classes
185
+
186
+ The component provides several CSS classes for customization:
187
+
188
+ ```css
189
+ /* Main container */
190
+ .toolbar-container {
191
+ border-bottom: solid 1px lightgray;
192
+ padding-bottom: 10px;
193
+ margin-bottom: 5px;
194
+ }
195
+
196
+ /* Button spacing */
197
+ .toolbar-container button {
198
+ margin-right: 7px;
199
+ }
200
+
201
+ /* Text spacing in buttons */
202
+ .toolbar-container .button-text {
203
+ margin-left: 7px;
204
+ }
205
+
206
+ /* Disabled state */
207
+ .toolbar-container.disabled {
208
+ pointer-events: none;
209
+ opacity: 0.8;
210
+ }
211
+
212
+ /* Save status message */
213
+ .form-toolbar-status-message {
214
+ background: #f0f0f0;
215
+ padding: 15px;
216
+ border-radius: 5px;
217
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
218
+ color: #1d7032;
219
+ font-weight: bold;
220
+ text-align: center;
221
+ }
222
+
223
+ /* List dialog items */
224
+ .list-item {
225
+ display: flex;
226
+ justify-content: space-between;
227
+ padding-bottom: 5px;
228
+ align-items: center;
229
+ }
230
+ ```
231
+
232
+ ### Icons
233
+
234
+ The toolbar uses Font Awesome icons for consistent visual language:
235
+
236
+ - Edit: `fa-pen-to-square`
237
+ - Delete: `fa-trash-can`
238
+ - Favorite (filled): `fa-solid fa-star`
239
+ - Favorite (outline): `fa-regular fa-star`
240
+ - Save: `fa-floppy-disk`
241
+ - Cancel: `fa-rotate-left`
242
+ - Changes: `fa-clipboard-list`
243
+ - History: `fa-business-time`
244
+ - Chat: `fa-comment-dots`
245
+ - Add: `fa-plus`
246
+
247
+ ## Integration with MemberJunction Services
248
+
249
+ ### Event System Integration
250
+
251
+ The toolbar integrates with MJGlobal event system for:
252
+
253
+ - **Server status updates**: Listens for `EventCodes.PushStatusUpdates` during save operations
254
+ - **Tab management**: Raises `EventCodes.CloseCurrentTab` after successful deletion
255
+
256
+ ### Skip Chat Integration
257
+
258
+ When Skip chat is enabled, the toolbar embeds the `mj-skip-chat-with-record-window` component:
259
+
260
+ ```html
261
+ <mj-skip-chat-with-record-window
262
+ [LinkedEntityID]="form.EntityInfo.ID"
263
+ [LinkedEntityPrimaryKey]="LinkedEntityPrimaryKey"
264
+ [WindowOpened]="_skipChatDialogVisible"
265
+ (WindowClosed)="ShowSkipChat()">
266
+ </mj-skip-chat-with-record-window>
267
+ ```
268
+
269
+ ### Record Changes Integration
270
+
271
+ For entities with change tracking enabled:
272
+
273
+ ```html
274
+ <mj-record-changes
275
+ [record]="form.record"
276
+ (dialogClosed)="form.handleHistoryDialog()">
277
+ </mj-record-changes>
278
+ ```
279
+
280
+ ## Advanced Usage Examples
281
+
282
+ ### Custom Toolbar with Conditional Features
283
+
284
+ ```typescript
285
+ @Component({
286
+ template: `
287
+ <mj-form-toolbar
288
+ [form]="this"
289
+ [ShowSkipChatButton]="shouldShowChat">
290
+ </mj-form-toolbar>
291
+ `
292
+ })
293
+ export class CustomFormComponent extends BaseFormComponent {
294
+ get shouldShowChat(): boolean {
295
+ // Show chat only for certain record types or user roles
296
+ return this.record?.Status === 'Active' &&
297
+ this.currentUser.hasRole('Manager');
298
+ }
299
+ }
300
+ ```
301
+
302
+ ### Handling Toolbar Events
303
+
304
+ ```typescript
305
+ export class FormWithToolbarComponent extends BaseFormComponent {
306
+ async ngOnInit() {
307
+ await super.ngOnInit();
308
+
309
+ // Listen for toolbar-related events
310
+ MJGlobal.Instance.GetEventListener(false).subscribe((event: MJEvent) => {
311
+ if (event.eventCode === EventCodes.CloseCurrentTab) {
312
+ // Handle tab closure after deletion
313
+ this.handleTabClosure();
314
+ }
315
+ });
316
+ }
317
+ }
318
+ ```
319
+
320
+ ### Programmatic Toolbar Control
321
+
322
+ ```typescript
323
+ export class AdvancedFormComponent extends BaseFormComponent {
324
+ @ViewChild(FormToolbarComponent) toolbar!: FormToolbarComponent;
325
+
326
+ async performBulkOperation() {
327
+ // Disable toolbar during bulk operations
328
+ this.toolbar.Disabled = true;
329
+
330
+ try {
331
+ await this.processBulkData();
332
+ } finally {
333
+ this.toolbar.Disabled = false;
334
+ }
335
+ }
336
+
337
+ // Programmatically show Skip chat
338
+ openAIAssistant() {
339
+ this.toolbar.ShowSkipChat();
340
+ }
341
+ }
342
+ ```
343
+
344
+ ## Error Handling
345
+
346
+ The toolbar implements comprehensive error handling:
347
+
348
+ - **Save errors**: Displays error notifications with server messages when available
349
+ - **Delete errors**: Shows appropriate messages for dependency conflicts
350
+ - **List operations**: Notifies users of success/failure when adding to lists
351
+ - **Network errors**: Gracefully handles connection issues with user-friendly messages
352
+
353
+ ## Best Practices
354
+
355
+ 1. **Always pass the form reference**: The toolbar requires a valid `BaseFormComponent` instance
356
+ 2. **Handle permissions properly**: Ensure your form correctly implements permission checks
357
+ 3. **Test save operations**: Verify your entity's save logic works with the toolbar's feedback system
358
+ 4. **Consider mobile responsiveness**: The toolbar works on mobile but may need custom styling
359
+ 5. **Use consistent icons**: Follow MemberJunction's icon conventions when extending
360
+
361
+ ## Troubleshooting
362
+
363
+ ### Common Issues
364
+
365
+ 1. **Buttons not appearing**: Check that your form properly extends `BaseFormComponent` and implements required properties
366
+ 2. **Save feedback not showing**: Ensure your form's parent element is properly structured
367
+ 3. **Skip chat not working**: Verify `@memberjunction/ng-ask-skip` is properly installed and configured
368
+ 4. **History not available**: Confirm the entity has `TrackRecordChanges` enabled in metadata
369
+
370
+ ### Debug Mode
371
+
372
+ Enable debug logging by adding to your component:
373
+
374
+ ```typescript
375
+ ngOnInit() {
376
+ // Log toolbar state changes
377
+ console.log('Toolbar disabled:', this.toolbar.CurrentlyDisabled);
378
+ console.log('Form edit mode:', this.form.EditMode);
379
+ console.log('User permissions:', {
380
+ canEdit: this.form.UserCanEdit,
381
+ canDelete: this.form.UserCanDelete
382
+ });
383
+ }
384
+ ```
385
+
386
+ ## Version History
387
+
388
+ - **2.43.0** - Current version with full feature set
389
+ - **2.42.0** - Added server status update integration
390
+ - **2.41.0** - Introduced real-time save progress tracking
391
+ - **2.40.0** - Added list management functionality
392
+
393
+ ## Contributing
394
+
395
+ When contributing to this package:
396
+
397
+ 1. Follow the MemberJunction coding standards
398
+ 2. Ensure all buttons use appropriate Font Awesome icons
399
+ 3. Test with various entity types and permissions
400
+ 4. Update this README with any new features
401
+ 5. Add unit tests for new functionality
402
+
403
+ ## License
404
+
405
+ ISC
406
+
407
+ ## Support
408
+
409
+ For issues or questions:
410
+ - Check the [MemberJunction documentation](https://docs.memberjunction.com)
411
+ - Submit issues on the GitHub repository
412
+ - Contact the MemberJunction support team
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-form-toolbar",
3
- "version": "2.42.1",
3
+ "version": "2.44.0",
4
4
  "description": "MemberJunction: Angular Form Toolbar",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -25,13 +25,13 @@
25
25
  "@angular/router": "18.0.2"
26
26
  },
27
27
  "dependencies": {
28
- "@memberjunction/global": "2.42.1",
29
- "@memberjunction/core": "2.42.1",
30
- "@memberjunction/ng-shared": "2.42.1",
31
- "@memberjunction/ng-base-forms": "2.42.1",
32
- "@memberjunction/ng-ask-skip": "2.42.1",
33
- "@memberjunction/ng-record-changes": "2.42.1",
34
- "@memberjunction/ng-container-directives": "2.42.1",
28
+ "@memberjunction/global": "2.44.0",
29
+ "@memberjunction/core": "2.44.0",
30
+ "@memberjunction/ng-shared": "2.44.0",
31
+ "@memberjunction/ng-base-forms": "2.44.0",
32
+ "@memberjunction/ng-ask-skip": "2.44.0",
33
+ "@memberjunction/ng-record-changes": "2.44.0",
34
+ "@memberjunction/ng-container-directives": "2.44.0",
35
35
  "@progress/kendo-angular-buttons": "16.2.0",
36
36
  "@progress/kendo-angular-dialog": "16.2.0",
37
37
  "ngx-markdown": "^18.0.0",