@memberjunction/ng-simple-record-list 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 +291 -55
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -1,16 +1,18 @@
1
1
  # @memberjunction/ng-simple-record-list
2
2
 
3
- A lightweight, reusable Angular component for displaying, editing, creating, and deleting records in any MemberJunction entity.
3
+ A lightweight, reusable Angular component for displaying, editing, creating, and deleting records in any MemberJunction entity. This component provides a streamlined grid interface with built-in CRUD operations and customizable actions.
4
4
 
5
5
  ## Features
6
6
 
7
- - Simple, streamlined UI for entity data
8
- - Configurable columns display
9
- - Automatic column detection from entity metadata
10
- - Support for creating, editing, and deleting records
11
- - Custom actions with dynamic icons and tooltips
12
- - Confirmation dialogs for delete and custom actions
13
- - Responsive design with loading indicators
7
+ - **Simple Grid Display**: Clean table layout for entity records with automatic column detection
8
+ - **CRUD Operations**: Built-in support for Create, Read, Update, and Delete operations
9
+ - **Automatic Column Detection**: Intelligently selects columns based on entity metadata
10
+ - **Custom Actions**: Support for custom actions with dynamic icons and tooltips
11
+ - **Confirmation Dialogs**: Built-in dialogs for delete and custom action confirmations
12
+ - **Responsive Design**: Loading indicators and scrollable content area
13
+ - **Entity Form Integration**: Seamless integration with MemberJunction's entity form dialog
14
+ - **Sorting Support**: Client-side sorting capability for displayed records
15
+ - **Click-to-Select**: Row selection with event emission for parent handling
14
16
 
15
17
  ## Installation
16
18
 
@@ -20,89 +22,323 @@ npm install @memberjunction/ng-simple-record-list
20
22
 
21
23
  ## Usage
22
24
 
23
- Import the module in your application:
25
+ ### Module Import
26
+
27
+ Import the module in your Angular application:
24
28
 
25
29
  ```typescript
26
30
  import { SimpleRecordListModule } from '@memberjunction/ng-simple-record-list';
27
31
 
28
32
  @NgModule({
29
33
  imports: [
30
- // ...
34
+ CommonModule,
31
35
  SimpleRecordListModule
32
36
  ]
33
37
  })
34
38
  export class YourModule { }
35
39
  ```
36
40
 
37
- Basic implementation example:
41
+ ### Basic Implementation
42
+
43
+ Simple usage with automatic column detection:
38
44
 
39
45
  ```html
40
46
  <mj-simple-record-list
41
47
  EntityName="Users"
42
- SortBy="Name"
43
- [Columns]="['Name', 'Email', 'IsActive']"
44
48
  (RecordSelected)="handleRecordSelected($event)"
45
49
  ></mj-simple-record-list>
46
50
  ```
47
51
 
48
- ## Input Properties
52
+ ### Advanced Implementation
53
+
54
+ Full-featured implementation with custom columns and actions:
55
+
56
+ ```html
57
+ <mj-simple-record-list
58
+ EntityName="Users"
59
+ [Columns]="['Name', 'Email', 'IsActive', 'CreatedAt']"
60
+ SortBy="Name"
61
+ [AllowDelete]="true"
62
+ [AllowNew]="true"
63
+ [AllowEdit]="true"
64
+ EditSectionName="user-details"
65
+ (RecordSelected)="onUserSelected($event)"
66
+ (RecordEdited)="onUserEdited($event)"
67
+ (RecordCreated)="onUserCreated($event)"
68
+ ></mj-simple-record-list>
69
+ ```
70
+
71
+ ### Component Implementation
72
+
73
+ ```typescript
74
+ import { Component } from '@angular/core';
75
+ import { BaseEntity, UserEntity } from '@memberjunction/core-entities';
76
+
77
+ @Component({
78
+ selector: 'app-user-management',
79
+ templateUrl: './user-management.component.html'
80
+ })
81
+ export class UserManagementComponent {
82
+
83
+ onUserSelected(user: BaseEntity): void {
84
+ console.log('User selected:', user.Get('Name'));
85
+ // Navigate to detail view or perform other actions
86
+ }
87
+
88
+ onUserEdited(user: BaseEntity): void {
89
+ console.log('User edited:', user.Get('ID'));
90
+ // Handle post-edit logic
91
+ }
92
+
93
+ onUserCreated(user: BaseEntity): void {
94
+ console.log('New user created:', user.Get('ID'));
95
+ // Handle post-creation logic
96
+ }
97
+ }
98
+ ```
99
+
100
+ ## API Documentation
101
+
102
+ ### Input Properties
49
103
 
50
104
  | Property | Type | Default | Description |
51
105
  |----------|------|---------|-------------|
52
- | EntityName | string | '' | Name of the entity to display records for |
53
- | Columns | string[] | [] | List of columns to display (auto-detected if empty) |
54
- | SortBy | string | '' | Name of the column to sort by |
55
- | AllowDelete | boolean | true | Whether to show delete button |
56
- | AllowNew | boolean | true | Whether to show new button |
57
- | AllowEdit | boolean | true | Whether to show edit button |
58
- | AllowCustomAction | boolean | false | Whether to show custom action button |
59
- | CustomActionIcon | string | '' | Font Awesome class for custom action icon |
60
- | CustomActionIconFunction | Function | null | Function to determine custom action icon based on record |
61
- | CustomActionTooltip | string | '' | Tooltip text for custom action |
62
- | CustomActionTooltipFunction | Function | null | Function to determine tooltip based on record |
63
- | CustomActionDialogTitle | string | 'Confirm Action' | Title for custom action confirmation dialog |
64
- | CustomActionDialogMessage | string | 'Are you sure...' | Message for custom action confirmation dialog |
65
- | CustomActionDialogInfo | string | '' | Additional info for custom action dialog |
66
- | EditSectionName | string | 'details' | Section name for entity form dialog |
67
-
68
- ## Output Events
106
+ | `EntityName` | `string` | `''` | **Required.** Name of the MemberJunction entity to display records for |
107
+ | `Columns` | `string[]` | `[]` | List of column names to display. If empty, columns are auto-detected based on entity metadata |
108
+ | `SortBy` | `string` | `''` | Column name to sort by. Uses client-side string comparison sorting |
109
+ | `AllowDelete` | `boolean` | `true` | Shows/hides delete button for each record |
110
+ | `AllowNew` | `boolean` | `true` | Shows/hides the "New" button above the grid |
111
+ | `AllowEdit` | `boolean` | `true` | Shows/hides edit button for each record |
112
+ | `AllowCustomAction` | `boolean` | `false` | Enables custom action button for each record |
113
+ | `CustomActionIcon` | `string` | `''` | Font Awesome icon class for custom action (e.g., 'fa-user-lock') |
114
+ | `CustomActionIconFunction` | `Function` | `null` | Function to dynamically determine icon based on record |
115
+ | `CustomActionTooltip` | `string` | `''` | Tooltip text for custom action button |
116
+ | `CustomActionTooltipFunction` | `Function` | `null` | Function to dynamically determine tooltip based on record |
117
+ | `CustomActionDialogTitle` | `string` | `'Confirm Action'` | Title for custom action confirmation dialog |
118
+ | `CustomActionDialogMessage` | `string` | `'Are you sure you want to perform this action?'` | Message for custom action dialog. Supports `{{recordName}}` placeholder |
119
+ | `CustomActionDialogInfo` | `string` | `''` | Additional information shown in custom action dialog |
120
+ | `EditSectionName` | `string` | `'details'` | Section name passed to entity form dialog for edit/new operations |
121
+
122
+ ### Output Events
69
123
 
70
124
  | Event | Type | Description |
71
125
  |-------|------|-------------|
72
- | RecordSelected | EventEmitter<BaseEntity> | Emitted when a record is selected |
73
- | RecordEdited | EventEmitter<BaseEntity> | Emitted when a record is edited |
74
- | RecordCreated | EventEmitter<BaseEntity> | Emitted when a record is created |
75
- | CustomActionClicked | EventEmitter<BaseEntity> | Emitted when custom action is clicked |
76
- | CustomActionConfirmed | EventEmitter<BaseEntity> | Emitted when custom action is confirmed |
126
+ | `RecordSelected` | `EventEmitter<BaseEntity>` | Fired when a record row is clicked |
127
+ | `RecordEdited` | `EventEmitter<BaseEntity>` | Fired after a record is successfully edited |
128
+ | `RecordCreated` | `EventEmitter<BaseEntity>` | Fired after a new record is successfully created |
129
+ | `CustomActionClicked` | `EventEmitter<BaseEntity>` | Fired when custom action button is clicked (before confirmation) |
130
+ | `CustomActionConfirmed` | `EventEmitter<BaseEntity>` | Fired when custom action is confirmed in dialog |
131
+
132
+ ## Column Auto-Detection Logic
133
+
134
+ When no columns are specified, the component uses the following logic:
135
+
136
+ 1. If the entity has fewer than 10 fields, all fields are displayed
137
+ 2. If the entity has 10+ fields:
138
+ - Fields with `DefaultInView = true` are selected
139
+ - If no fields have `DefaultInView = true`, the first 10 fields are used
140
+
141
+ ## Custom Actions
142
+
143
+ ### Example: Toggle User Activation
144
+
145
+ ```typescript
146
+ import { Component } from '@angular/core';
147
+ import { BaseEntity, UserEntity } from '@memberjunction/core-entities';
148
+
149
+ @Component({
150
+ selector: 'app-user-list',
151
+ template: `
152
+ <mj-simple-record-list
153
+ EntityName="Users"
154
+ [Columns]="['Name', 'Email', 'IsActive']"
155
+ [AllowDelete]="false"
156
+ [AllowCustomAction]="true"
157
+ [CustomActionIconFunction]="getUserToggleIcon"
158
+ [CustomActionTooltipFunction]="getUserToggleTooltip"
159
+ CustomActionDialogTitle="Toggle User Activation"
160
+ CustomActionDialogMessage="Are you sure you want to toggle activation for {{recordName}}?"
161
+ CustomActionDialogInfo="Active users can log in. Inactive users cannot."
162
+ (CustomActionConfirmed)="toggleUserActivation($event)"
163
+ ></mj-simple-record-list>
164
+ `
165
+ })
166
+ export class UserListComponent {
167
+
168
+ getUserToggleIcon = (record: BaseEntity): string => {
169
+ const user = record as UserEntity;
170
+ return user.IsActive ? 'fa-user-lock' : 'fa-user-check';
171
+ }
172
+
173
+ getUserToggleTooltip = (record: BaseEntity): string => {
174
+ const user = record as UserEntity;
175
+ return user.IsActive ? 'Deactivate user' : 'Activate user';
176
+ }
177
+
178
+ async toggleUserActivation(record: BaseEntity): Promise<void> {
179
+ const user = record as UserEntity;
180
+ user.IsActive = !user.IsActive;
181
+
182
+ if (await user.Save()) {
183
+ console.log('User activation toggled successfully');
184
+ } else {
185
+ console.error('Failed to toggle user activation:', user.LatestResult.Message);
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ ## Record Name Resolution
192
+
193
+ The component determines display names for records using this hierarchy:
194
+
195
+ 1. First field marked with `IsNameField = true` in entity metadata
196
+ 2. Field named "Name" if it exists
197
+ 3. Concatenated primary key values with "Record: " prefix
198
+
199
+ ## Styling
200
+
201
+ The component uses:
202
+ - Font Awesome icons (must be included in your application)
203
+ - Kendo UI Angular theme styles
204
+ - Custom CSS with scrollable table and sticky headers
205
+ - Hover effects for better user interaction
77
206
 
78
- ## Custom Actions Example
207
+ ### CSS Classes
208
+
209
+ - `.wrapper`: Main container with padding and scrolling
210
+ - `.grid`: Table styling with collapsed borders
211
+ - `.sticky-header`: Keeps table headers visible during scroll
212
+ - `.icon`: Styling for action buttons with cursor pointer
213
+
214
+ ## Dependencies
215
+
216
+ ### Production Dependencies
217
+ - `@memberjunction/core`: Core MemberJunction functionality
218
+ - `@memberjunction/core-entities`: Entity base classes
219
+ - `@memberjunction/global`: Global utilities
220
+ - `@memberjunction/ng-container-directives`: Layout directives
221
+ - `@memberjunction/ng-notifications`: Notification service
222
+ - `@memberjunction/ng-entity-form-dialog`: Entity form dialog component
223
+ - `@progress/kendo-angular-*`: Kendo UI components
224
+
225
+ ### Peer Dependencies
226
+ - `@angular/common`: ^18.0.2
227
+ - `@angular/core`: ^18.0.2
228
+ - `@angular/forms`: ^18.0.2
229
+ - `@angular/router`: ^18.0.2
230
+
231
+ ## Integration with MemberJunction
232
+
233
+ This component is designed to work seamlessly with the MemberJunction framework:
234
+
235
+ - **Entity Metadata**: Automatically reads entity configuration from MJ metadata
236
+ - **Entity Objects**: Uses MJ's BaseEntity class for all operations
237
+ - **RunView**: Leverages MJ's RunView for efficient data loading
238
+ - **Entity Forms**: Integrates with MJ's entity form dialog for editing
239
+ - **Notifications**: Uses MJ's notification service for user feedback
240
+
241
+ ## Best Practices
242
+
243
+ 1. **Column Selection**: Specify columns explicitly for better performance and control
244
+ 2. **Custom Actions**: Use function-based icons/tooltips for dynamic UI updates
245
+ 3. **Event Handling**: Always handle the output events for proper integration
246
+ 4. **Error Handling**: Check entity save results and handle failures appropriately
247
+ 5. **Performance**: For large datasets, consider implementing server-side pagination
248
+
249
+ ## Troubleshooting
250
+
251
+ ### Common Issues
252
+
253
+ 1. **No records displayed**: Verify EntityName matches exactly with MJ metadata
254
+ 2. **Columns not showing**: Check that column names match entity field names
255
+ 3. **Edit form not opening**: Ensure EditSectionName exists in entity form configuration
256
+ 4. **Custom actions not working**: Verify function bindings use arrow functions or proper binding
257
+
258
+ ### Debug Tips
259
+
260
+ - Check browser console for entity loading errors
261
+ - Verify MemberJunction metadata is properly initialized
262
+ - Ensure all required Angular and Kendo modules are imported
263
+ - Check that Font Awesome is properly included for icons
264
+
265
+ ## Examples
266
+
267
+ ### Minimal Setup
268
+
269
+ ```typescript
270
+ // app.component.ts
271
+ import { Component } from '@angular/core';
272
+
273
+ @Component({
274
+ selector: 'app-root',
275
+ template: `
276
+ <mj-simple-record-list
277
+ EntityName="Employees"
278
+ ></mj-simple-record-list>
279
+ `
280
+ })
281
+ export class AppComponent { }
282
+ ```
283
+
284
+ ### Read-Only Grid
79
285
 
80
286
  ```html
81
287
  <mj-simple-record-list
82
- EntityName="Users"
83
- [Columns]="['Name', 'Email', 'IsActive']"
288
+ EntityName="AuditLogs"
289
+ [Columns]="['Timestamp', 'User', 'Action', 'Description']"
290
+ SortBy="Timestamp"
291
+ [AllowNew]="false"
292
+ [AllowEdit]="false"
84
293
  [AllowDelete]="false"
85
- [AllowCustomAction]="true"
86
- [CustomActionIconFunction]="getUserToggleIcon"
87
- [CustomActionTooltipFunction]="getUserToggleTooltip"
88
- [CustomActionDialogTitle]="'Toggle User Activation'"
89
- [CustomActionDialogMessage]="'Are you sure you want to toggle activation for this user?'"
90
- [CustomActionDialogInfo]="'Active users can log in to the system. Inactive users cannot log in.'"
91
- (RecordSelected)="selectUser($event)"
92
- (CustomActionConfirmed)="toggleUserActivation($event)"
93
294
  ></mj-simple-record-list>
94
295
  ```
95
296
 
96
- Example of icon and tooltip functions:
297
+ ### With Custom Filtering
97
298
 
98
299
  ```typescript
99
- public getUserToggleIcon(record: BaseEntity): string {
100
- const user = record as UserEntity;
101
- return user.IsActive ? 'fa-user-lock' : 'fa-user-check';
102
- }
300
+ @Component({
301
+ template: `
302
+ <mj-simple-record-list
303
+ EntityName="Products"
304
+ [Columns]="['Name', 'Category', 'Price', 'InStock']"
305
+ [AllowCustomAction]="true"
306
+ CustomActionIcon="fa-filter"
307
+ CustomActionTooltip="Toggle out of stock items"
308
+ (CustomActionConfirmed)="toggleStockFilter($event)"
309
+ ></mj-simple-record-list>
310
+ `
311
+ })
312
+ export class ProductListComponent {
313
+ private showOutOfStock = true;
103
314
 
104
- public getUserToggleTooltip(record: BaseEntity): string {
105
- const user = record as UserEntity;
106
- return user.IsActive ? 'Deactivate user' : 'Activate user';
315
+ async toggleStockFilter(record: BaseEntity): Promise<void> {
316
+ this.showOutOfStock = !this.showOutOfStock;
317
+ // Implement filtering logic
318
+ }
107
319
  }
320
+ ```
321
+
322
+ ## Building
323
+
324
+ To build this package individually:
325
+
326
+ ```bash
327
+ cd packages/Angular/Explorer/simple-record-list
328
+ npm run build
329
+ ```
330
+
331
+ ## Contributing
332
+
333
+ When contributing to this component:
334
+
335
+ 1. Follow the MemberJunction coding standards
336
+ 2. Ensure all TypeScript compiles without errors
337
+ 3. Test with various entity types
338
+ 4. Update this README for any API changes
339
+ 5. Add appropriate TSDoc comments for public methods
340
+
341
+ ## License
342
+
343
+ This package is part of the MemberJunction framework and follows the same license terms.
108
344
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-simple-record-list",
3
- "version": "2.42.1",
3
+ "version": "2.44.0",
4
4
  "description": "MemberJunction: Very simple and reusable Angular component for displaying, editing, creating and deleting records in any entity",
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.42.1",
29
- "@memberjunction/global": "2.42.1",
30
- "@memberjunction/core": "2.42.1",
31
- "@memberjunction/ng-container-directives": "2.42.1",
32
- "@memberjunction/ng-notifications": "2.42.1",
33
- "@memberjunction/ng-entity-form-dialog": "2.42.1",
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-notifications": "2.44.0",
33
+ "@memberjunction/ng-entity-form-dialog": "2.44.0",
34
34
  "@progress/kendo-angular-buttons": "16.2.0",
35
35
  "@progress/kendo-angular-dialog": "16.2.0",
36
36
  "@progress/kendo-angular-layout": "16.2.0",