@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.
- package/README.md +185 -36
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
#
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
173
|
-
|
|
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
|
|
180
|
-
2. After debounce, a search is executed
|
|
181
|
-
3.
|
|
182
|
-
4.
|
|
183
|
-
5.
|
|
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
|
|
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
|
-
|
|
192
|
-
- `@memberjunction/core
|
|
193
|
-
- `@memberjunction/
|
|
194
|
-
- `@
|
|
195
|
-
- `@
|
|
196
|
-
- `@
|
|
197
|
-
-
|
|
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.
|
|
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.
|
|
34
|
-
"@memberjunction/global": "2.
|
|
35
|
-
"@memberjunction/core": "2.
|
|
36
|
-
"@memberjunction/ng-container-directives": "2.
|
|
37
|
-
"@memberjunction/ng-shared": "2.
|
|
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
|
},
|