@memberjunction/ng-simple-record-list 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.
Files changed (2) hide show
  1. package/README.md +92 -317
  2. package/package.json +8 -8
package/README.md CHANGED
@@ -1,18 +1,45 @@
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. This component provides a streamlined grid interface with built-in CRUD operations and customizable actions.
3
+ A lightweight, reusable Angular component for displaying, creating, editing, and deleting records from any MemberJunction entity. Provides a streamlined grid interface with built-in CRUD operations, custom action buttons, and inline form dialogs.
4
+
5
+ ## Overview
6
+
7
+ The `SimpleRecordListComponent` is designed for settings pages and administrative interfaces where a full data grid is overkill. It renders a simple list of records for a given entity with configurable columns, sorting, and action buttons (edit, delete, custom action). New records and edits are handled via the `EntityFormDialogComponent`.
8
+
9
+ ```mermaid
10
+ graph TD
11
+ SRL["SimpleRecordListComponent\n(<mj-simple-record-list>)"] --> KG["Record Grid\n(Kendo Grid)"]
12
+ SRL --> EFD["EntityFormDialogComponent\n(Edit/New)"]
13
+ SRL --> DEL["Delete Confirmation\n(Kendo Dialog)"]
14
+ SRL --> CA["Custom Action Button"]
15
+
16
+ KG --> EDIT["Edit Button"]
17
+ KG --> DELETE["Delete Button"]
18
+ KG --> CUSTOM["Custom Action"]
19
+
20
+ style SRL fill:#7c5295,stroke:#563a6b,color:#fff
21
+ style KG fill:#2d6a9f,stroke:#1a4971,color:#fff
22
+ style EFD fill:#2d8659,stroke:#1a5c3a,color:#fff
23
+ style DEL fill:#b8762f,stroke:#8a5722,color:#fff
24
+ style CA fill:#b8762f,stroke:#8a5722,color:#fff
25
+ style EDIT fill:#2d8659,stroke:#1a5c3a,color:#fff
26
+ style DELETE fill:#2d8659,stroke:#1a5c3a,color:#fff
27
+ style CUSTOM fill:#2d8659,stroke:#1a5c3a,color:#fff
28
+ ```
4
29
 
5
30
  ## Features
6
31
 
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
32
+ - **Entity-agnostic**: Works with any MemberJunction entity by name
33
+ - **Configurable columns**: Specify which columns to display, or auto-select from metadata
34
+ - **CRUD operations**: Built-in New, Edit, and Delete with confirmation dialogs
35
+ - **Custom action button**: Optional per-row action with configurable icon, tooltip, and handler
36
+ - **Dynamic icons/tooltips**: Custom action icon and tooltip can be functions of the record
37
+ - **Inline form editing**: Opens `EntityFormDialogComponent` for editing individual records
38
+ - **Section-mode editing**: Optionally show only a specific form section in the edit dialog
39
+ - **Default values**: Set default field values for new records
40
+ - **Extra filter**: Apply additional SQL filter to scope the visible records
41
+ - **Delete prevention**: Cancel delete via event handler
42
+ - **Sorting**: Sort by any column
16
43
 
17
44
  ## Installation
18
45
 
@@ -20,325 +47,73 @@ A lightweight, reusable Angular component for displaying, editing, creating, and
20
47
  npm install @memberjunction/ng-simple-record-list
21
48
  ```
22
49
 
23
- ## Usage
24
-
25
- ### Module Import
26
-
27
- Import the module in your Angular application:
28
-
29
- ```typescript
30
- import { SimpleRecordListModule } from '@memberjunction/ng-simple-record-list';
31
-
32
- @NgModule({
33
- imports: [
34
- CommonModule,
35
- SimpleRecordListModule
36
- ]
37
- })
38
- export class YourModule { }
39
- ```
40
-
41
- ### Basic Implementation
42
-
43
- Simple usage with automatic column detection:
50
+ ## Key Dependencies
44
51
 
45
- ```html
46
- <mj-simple-record-list
47
- EntityName="Users"
48
- (RecordSelected)="handleRecordSelected($event)"
49
- ></mj-simple-record-list>
50
- ```
52
+ | Dependency | Purpose |
53
+ |---|---|
54
+ | `@memberjunction/core` | Metadata, BaseEntity, RunView |
55
+ | `@memberjunction/ng-entity-form-dialog` | Record editing dialog |
56
+ | `@memberjunction/ng-notifications` | Notification service |
57
+ | `@progress/kendo-angular-grid` | Grid display |
58
+ | `@progress/kendo-angular-dialog` | Confirmation dialogs |
51
59
 
52
- ### Advanced Implementation
53
-
54
- Full-featured implementation with custom columns and actions:
60
+ ## Usage
55
61
 
56
62
  ```html
57
63
  <mj-simple-record-list
58
- EntityName="Users"
59
- [Columns]="['Name', 'Email', 'IsActive', 'CreatedAt']"
60
- SortBy="Name"
61
- [AllowDelete]="true"
64
+ [EntityName]="'Roles'"
65
+ [Columns]="['Name', 'Description']"
66
+ [SortBy]="'Name'"
62
67
  [AllowNew]="true"
63
68
  [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
103
-
104
- | Property | Type | Default | Description |
105
- |----------|------|---------|-------------|
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
123
-
124
- | Event | Type | Description |
125
- |-------|------|-------------|
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
206
-
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
285
-
286
- ```html
287
- <mj-simple-record-list
288
- EntityName="AuditLogs"
289
- [Columns]="['Timestamp', 'User', 'Action', 'Description']"
290
- SortBy="Timestamp"
291
- [AllowNew]="false"
292
- [AllowEdit]="false"
293
- [AllowDelete]="false"
294
- ></mj-simple-record-list>
295
- ```
296
-
297
- ### With Custom Filtering
298
-
299
- ```typescript
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;
314
-
315
- async toggleStockFilter(record: BaseEntity): Promise<void> {
316
- this.showOutOfStock = !this.showOutOfStock;
317
- // Implement filtering logic
318
- }
319
- }
69
+ [AllowDelete]="true"
70
+ [ExtraFilter]="'IsActive = 1'"
71
+ (RecordSaved)="onSaved($event)"
72
+ (RecordDeleted)="onDeleted($event)">
73
+ </mj-simple-record-list>
320
74
  ```
321
75
 
322
- ## Building
323
-
324
- To build this package individually:
76
+ ### Key Inputs
77
+
78
+ | Input | Type | Default | Description |
79
+ |---|---|---|---|
80
+ | `EntityName` | `string` | `''` | Entity to display records for |
81
+ | `Columns` | `string[]` | `[]` | Column names to display |
82
+ | `SortBy` | `string` | `''` | Column to sort by |
83
+ | `AllowNew` | `boolean` | `true` | Show New button |
84
+ | `AllowEdit` | `boolean` | `true` | Show Edit button per row |
85
+ | `AllowDelete` | `boolean` | `true` | Show Delete button per row |
86
+ | `AllowCustomAction` | `boolean` | `false` | Show custom action button per row |
87
+ | `CustomActionIcon` | `string` | `''` | FA icon class for custom action |
88
+ | `CustomActionIconFunction` | `(record: BaseEntity) => string` | `null` | Dynamic icon per record |
89
+ | `CustomActionTooltip` | `string` | `''` | Tooltip for custom action |
90
+ | `CustomActionTooltipFunction` | `(record: BaseEntity) => string` | `null` | Dynamic tooltip per record |
91
+ | `ExtraFilter` | `string` | `''` | Additional SQL filter |
92
+ | `DefaultValues` | `Record<string, string>` | `{}` | Default values for new records |
93
+ | `EditSectionName` | `string` | `''` | Show only this section in edit dialog |
94
+
95
+ ### Key Outputs
96
+
97
+ | Output | Type | Description |
98
+ |---|---|---|
99
+ | `RecordSaved` | `EventEmitter<BaseEntity>` | Emitted after record save |
100
+ | `RecordDeleted` | `EventEmitter<BaseEntity>` | Emitted after record delete |
101
+ | `CustomActionClicked` | `EventEmitter<BaseEntity>` | Emitted when custom action clicked |
102
+ | `DeleteRequested` | `EventEmitter<{record, cancel}>` | Emitted before delete (cancelable) |
103
+
104
+ ## Exported API
105
+
106
+ | Export | Type | Description |
107
+ |---|---|---|
108
+ | `SimpleRecordListComponent` | Component | The record list component |
109
+ | `SimpleRecordListModule` | NgModule | Module declaration |
110
+
111
+ ## Build
325
112
 
326
113
  ```bash
327
- cd packages/Angular/Explorer/simple-record-list
328
- npm run build
114
+ cd packages/Angular/Explorer/simple-record-list && npm run build
329
115
  ```
330
116
 
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
117
  ## License
342
118
 
343
- This package is part of the MemberJunction framework and follows the same license terms.
344
- ```
119
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-simple-record-list",
3
- "version": "4.0.0",
3
+ "version": "4.2.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,13 +25,13 @@
25
25
  "@angular/router": "21.1.3"
26
26
  },
27
27
  "dependencies": {
28
- "@memberjunction/core": "4.0.0",
29
- "@memberjunction/core-entities": "4.0.0",
30
- "@memberjunction/global": "4.0.0",
31
- "@memberjunction/ng-container-directives": "4.0.0",
32
- "@memberjunction/ng-entity-form-dialog": "4.0.0",
33
- "@memberjunction/ng-notifications": "4.0.0",
34
- "@memberjunction/ng-shared-generic": "4.0.0",
28
+ "@memberjunction/core": "4.2.0",
29
+ "@memberjunction/core-entities": "4.2.0",
30
+ "@memberjunction/global": "4.2.0",
31
+ "@memberjunction/ng-container-directives": "4.2.0",
32
+ "@memberjunction/ng-entity-form-dialog": "4.2.0",
33
+ "@memberjunction/ng-notifications": "4.2.0",
34
+ "@memberjunction/ng-shared-generic": "4.2.0",
35
35
  "@progress/kendo-angular-buttons": "22.0.1",
36
36
  "@progress/kendo-angular-dialog": "22.0.1",
37
37
  "@progress/kendo-angular-dropdowns": "22.0.1",