@memberjunction/ng-find-record 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 +185 -36
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,16 +1,22 @@
1
- # Find Record Component
1
+ # @memberjunction/ng-find-record
2
2
 
3
- An Angular component for searching and selecting records from any MemberJunction entity. This package provides both a standalone search component and a dialog wrapper component for easy integration into applications.
3
+ An Angular component library for searching and selecting records from any MemberJunction entity. This package provides both a standalone search component and a dialog wrapper component for easy integration into Angular applications.
4
+
5
+ ## Purpose and Overview
6
+
7
+ The `@memberjunction/ng-find-record` package simplifies the process of implementing entity record search functionality in MemberJunction-based Angular applications. It provides a reusable component that can search any entity using the MemberJunction metadata system and RunView API, displaying results in a Kendo UI grid for easy selection.
4
8
 
5
9
  ## Features
6
10
 
7
- - **Entity-Agnostic**: Works with any MemberJunction entity
8
- - **Debounced Search**: Real-time search with configurable debounce time
9
- - **Grid Display**: Results displayed in a searchable, sortable grid
10
- - **Customizable Fields**: Configure which fields to display in the results
11
- - **Dialog Integration**: Optional dialog wrapper for modal usage
11
+ - **Entity-Agnostic**: Works with any MemberJunction entity without modification
12
+ - **Debounced Search**: Real-time search with configurable debounce time (default: 300ms)
13
+ - **Grid Display**: Results displayed in a searchable, sortable Kendo UI grid
14
+ - **Customizable Fields**: Configure which fields to display in the results grid
15
+ - **Dialog Integration**: Optional dialog wrapper for modal usage scenarios
12
16
  - **Event Handling**: Events for record selection and dialog closure
13
17
  - **Loading States**: Visual feedback during search operations
18
+ - **TypeScript Support**: Full TypeScript support with proper typing
19
+ - **MemberJunction Integration**: Seamlessly integrates with MemberJunction's metadata and entity systems
14
20
 
15
21
  ## Installation
16
22
 
@@ -67,7 +73,7 @@ export class YourModule { }
67
73
  ### TypeScript Component Example
68
74
 
69
75
  ```typescript
70
- import { Component } from '@angular/core';
76
+ import { Component, OnInit } from '@angular/core';
71
77
  import { BaseEntity, EntityFieldInfo, Metadata } from '@memberjunction/core';
72
78
 
73
79
  @Component({
@@ -141,57 +147,200 @@ export class UserFinderComponent implements OnInit {
141
147
 
142
148
  ### FindRecordComponent
143
149
 
144
- Standalone component for searching and selecting records.
150
+ Standalone component for searching and selecting records. This component provides a search input with a grid display of results.
151
+
152
+ #### Selector
153
+ `mj-find-record`
145
154
 
146
155
  #### Inputs
147
156
 
148
- - `EntityName`: string - The name of the entity to search
149
- - `DisplayFields`: EntityFieldInfo[] - Fields to display in the results grid (optional)
150
- - `SearchDebounceTime`: number - Debounce time in milliseconds for search (default: 300)
157
+ | Property | Type | Default | Description |
158
+ |----------|------|---------|-------------|
159
+ | `EntityName` | `string` | `''` | **Required.** The name of the MemberJunction entity to search |
160
+ | `DisplayFields` | `EntityFieldInfo[]` | `[]` | Optional. Fields to display in the results grid. If not specified, defaults to fields marked as `DefaultInView`, `IsPrimaryKey`, `IsNameField`, or `IncludeInUserSearchAPI` |
161
+ | `SearchDebounceTime` | `number` | `300` | Optional. Debounce time in milliseconds for search input |
151
162
 
152
163
  #### Outputs
153
164
 
154
- - `OnRecordSelected`: EventEmitter<BaseEntity> - Emitted when a record is selected
165
+ | Event | Type | Description |
166
+ |-------|------|-------------|
167
+ | `OnRecordSelected` | `EventEmitter<BaseEntity>` | Emitted when a user selects a record from the search results grid |
155
168
 
156
169
  ### FindRecordDialogComponent
157
170
 
158
- Dialog wrapper for the FindRecordComponent.
171
+ Dialog wrapper for the FindRecordComponent. Provides a modal dialog containing the search functionality.
172
+
173
+ #### Selector
174
+ `mj-find-record-dialog`
159
175
 
160
176
  #### Inputs
161
177
 
162
- - `EntityName`: string - The name of the entity to search
163
- - `DisplayFields`: EntityFieldInfo[] - Fields to display in the results grid (optional)
164
- - `DialogTitle`: string - Title of the dialog (default: 'Find Record')
165
- - `DialogWidth`: string - Width of the dialog (default: '700px')
166
- - `DialogHeight`: string - Height of the dialog (default: '450px')
167
- - `DialogVisible`: boolean - Controls the visibility of the dialog
168
- - `SelectedRecord`: BaseEntity | null - Currently selected record (optional)
178
+ | Property | Type | Default | Description |
179
+ |----------|------|---------|-------------|
180
+ | `EntityName` | `string` | `''` | **Required.** The name of the MemberJunction entity to search |
181
+ | `DisplayFields` | `EntityFieldInfo[]` | `[]` | Optional. Fields to display in the results grid |
182
+ | `DialogTitle` | `string` | `'Find Record'` | Optional. Title displayed in the dialog header |
183
+ | `DialogWidth` | `string` | `'700px'` | Optional. Width of the dialog |
184
+ | `DialogHeight` | `string` | `'450px'` | Optional. Height of the dialog |
185
+ | `DialogVisible` | `boolean` | `false` | **Required.** Controls the visibility of the dialog |
186
+ | `SelectedRecord` | `BaseEntity \| null` | `null` | Optional. Currently selected record. Can be set to pre-select a record |
169
187
 
170
188
  #### Outputs
171
189
 
172
- - `DialogClosed`: EventEmitter<boolean> - Emitted when the dialog is closed (true if confirmed, false if canceled)
173
- - `OnRecordSelected`: EventEmitter<BaseEntity> - Emitted when a record is selected
190
+ | Event | Type | Description |
191
+ |-------|------|-------------|
192
+ | `DialogClosed` | `EventEmitter<boolean>` | Emitted when the dialog is closed. `true` if OK was clicked, `false` if cancelled |
193
+ | `OnRecordSelected` | `EventEmitter<BaseEntity>` | Emitted when a user selects a record from the search results |
174
194
 
175
195
  ## Search Behavior
176
196
 
177
197
  The component uses the MemberJunction RunView functionality with the following behavior:
178
198
 
179
- 1. As the user types, the search input is debounced (default 300ms)
180
- 2. After debounce, a search is executed against the specified entity
181
- 3. Results are displayed in a grid with the specified fields
182
- 4. User can select a record from the grid
183
- 5. The selected record is emitted via the OnRecordSelected event
199
+ 1. As the user types in the search input, the input is debounced (default 300ms) to prevent excessive API calls
200
+ 2. After the debounce period, a search is executed using `RunView` with the `UserSearchString` parameter
201
+ 3. The search leverages MemberJunction's entity metadata to search across appropriate fields
202
+ 4. Results are displayed in a Kendo UI grid with the specified or default fields
203
+ 5. Users can select a record by clicking on a row in the grid
204
+ 6. The selected record (as a `BaseEntity` instance) is emitted via the `OnRecordSelected` event
205
+
206
+ ### Search Implementation Details
207
+
208
+ The component uses the following RunView configuration:
209
+ ```typescript
210
+ {
211
+ EntityName: this.EntityName,
212
+ UserSearchString: searchTerm,
213
+ ResultType: 'entity_object' // Returns BaseEntity instances
214
+ }
215
+ ```
184
216
 
185
217
  ## Styling
186
218
 
187
- The component includes basic CSS styling that can be overridden in your application.
219
+ The component includes basic CSS styling with the following classes:
220
+ - `.find-textbox` - Styles the search input field
221
+ - `.find-button` - Styles the Find button
222
+
223
+ You can override these styles in your application's global styles or component-specific stylesheets.
188
224
 
189
225
  ## Dependencies
190
226
 
191
- - `@memberjunction/core`: For metadata and entity access
192
- - `@memberjunction/core-entities`: For entity types
193
- - `@memberjunction/global`: For global utilities
194
- - `@progress/kendo-angular-grid`: For displaying search results
195
- - `@progress/kendo-angular-buttons`: For UI buttons
196
- - `@progress/kendo-angular-inputs`: For search input
197
- - `@progress/kendo-angular-dialog`: For dialog wrapper
227
+ ### Production Dependencies
228
+ - `@memberjunction/core`: ^2.43.0 - Core MemberJunction functionality including metadata, RunView, and BaseEntity
229
+ - `@memberjunction/core-entities`: ^2.43.0 - Entity type definitions
230
+ - `@memberjunction/global`: ^2.43.0 - Global utilities and helpers
231
+ - `@memberjunction/ng-container-directives`: ^2.43.0 - Angular container directives
232
+ - `@memberjunction/ng-shared`: ^2.43.0 - Shared Angular utilities
233
+ - `rxjs`: ^7.8.1 - Reactive programming support for debouncing and search handling
234
+ - `tslib`: ^2.3.0 - TypeScript runtime library
235
+
236
+ ### Peer Dependencies (must be installed in your application)
237
+ - `@angular/common`: 18.0.2
238
+ - `@angular/core`: 18.0.2
239
+ - `@angular/forms`: 18.0.2
240
+ - `@angular/router`: 18.0.2
241
+ - `@progress/kendo-angular-grid`: 16.2.0
242
+ - `@progress/kendo-angular-buttons`: 16.2.0
243
+ - `@progress/kendo-angular-inputs`: 16.2.0
244
+ - `@progress/kendo-angular-dialog`: 16.2.0
245
+ - `@progress/kendo-angular-listbox`: 16.2.0
246
+
247
+ ## Integration with MemberJunction
248
+
249
+ This package is designed to work seamlessly with the MemberJunction ecosystem:
250
+
251
+ 1. **Metadata Integration**: Uses MemberJunction's Metadata class to retrieve entity information and field definitions
252
+ 2. **Entity System**: Works with any entity registered in the MemberJunction metadata system
253
+ 3. **RunView API**: Leverages the powerful RunView API for searching, which respects entity permissions and field-level security
254
+ 4. **BaseEntity**: Returns actual BaseEntity instances, allowing full access to entity methods and properties
255
+
256
+ ## Build and Development
257
+
258
+ This package is part of the MemberJunction monorepo. To build:
259
+
260
+ ```bash
261
+ # From the package directory
262
+ npm run build
263
+
264
+ # Or from the monorepo root
265
+ turbo build --filter="@memberjunction/ng-find-record"
266
+ ```
267
+
268
+ The package uses Angular's `ngc` compiler for building Angular libraries.
269
+
270
+ ## Module Configuration
271
+
272
+ The package exports a `FindRecordModule` that includes both components. Import this module in your Angular application:
273
+
274
+ ```typescript
275
+ import { FindRecordModule } from '@memberjunction/ng-find-record';
276
+
277
+ @NgModule({
278
+ imports: [
279
+ FindRecordModule,
280
+ // ... other imports
281
+ ]
282
+ })
283
+ export class YourFeatureModule { }
284
+ ```
285
+
286
+ ## Advanced Usage
287
+
288
+ ### Custom Field Selection
289
+
290
+ You can programmatically select which fields to display based on your requirements:
291
+
292
+ ```typescript
293
+ // Display only specific fields
294
+ const entity = this.metadata.EntityByName('Products');
295
+ this.displayFields = entity.Fields.filter(f =>
296
+ ['Name', 'SKU', 'Price', 'Category'].includes(f.Name)
297
+ );
298
+ ```
299
+
300
+ ### Pre-selecting Records
301
+
302
+ You can pre-select a record in the dialog component:
303
+
304
+ ```typescript
305
+ // Load a record and pre-select it
306
+ const md = new Metadata();
307
+ const user = await md.GetEntityObject<UserEntity>('Users');
308
+ await user.Load(userId);
309
+ this.selectedRecord = user;
310
+ ```
311
+
312
+ ### Handling Selection Events
313
+
314
+ Process selected records with full type safety:
315
+
316
+ ```typescript
317
+ onRecordSelected(record: BaseEntity) {
318
+ // Cast to specific entity type if needed
319
+ if (record.EntityInfo.Name === 'Users') {
320
+ const user = record as UserEntity;
321
+ console.log('Selected user email:', user.Email);
322
+ }
323
+
324
+ // Or use generic BaseEntity methods
325
+ console.log('Selected record ID:', record.Get('ID'));
326
+ console.log('Selected record name:', record.Get(record.EntityInfo.NameField));
327
+ }
328
+ ```
329
+
330
+ ## Error Handling
331
+
332
+ The component includes built-in error handling:
333
+
334
+ - Failed searches will log errors using MemberJunction's `LogError` function
335
+ - Loading states provide visual feedback during searches
336
+ - Empty search results display a user-friendly message
337
+
338
+ ## Performance Considerations
339
+
340
+ - **Debouncing**: The default 300ms debounce prevents excessive API calls during typing
341
+ - **Entity Objects**: Using `ResultType: 'entity_object'` in RunView ensures efficient object creation
342
+ - **Grid Virtualization**: The Kendo Grid component provides built-in virtualization for large result sets
343
+
344
+ ## License
345
+
346
+ This package is part of the MemberJunction open-source project. See the root repository for license information.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-find-record",
3
- "version": "2.42.1",
3
+ "version": "2.44.0",
4
4
  "description": "MemberJunction: Angular Component to allow a user to find a single record in any entity",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -30,11 +30,11 @@
30
30
  "@progress/kendo-angular-listbox": "16.2.0"
31
31
  },
32
32
  "dependencies": {
33
- "@memberjunction/core-entities": "2.42.1",
34
- "@memberjunction/global": "2.42.1",
35
- "@memberjunction/core": "2.42.1",
36
- "@memberjunction/ng-container-directives": "2.42.1",
37
- "@memberjunction/ng-shared": "2.42.1",
33
+ "@memberjunction/core-entities": "2.44.0",
34
+ "@memberjunction/global": "2.44.0",
35
+ "@memberjunction/core": "2.44.0",
36
+ "@memberjunction/ng-container-directives": "2.44.0",
37
+ "@memberjunction/ng-shared": "2.44.0",
38
38
  "rxjs": "^7.8.1",
39
39
  "tslib": "^2.3.0"
40
40
  },