@memberjunction/ng-find-record 2.32.1 → 2.33.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 +197 -0
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Find Record Component
|
|
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.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
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
|
|
12
|
+
- **Event Handling**: Events for record selection and dialog closure
|
|
13
|
+
- **Loading States**: Visual feedback during search operations
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @memberjunction/ng-find-record
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Import the Module
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { FindRecordModule } from '@memberjunction/ng-find-record';
|
|
27
|
+
|
|
28
|
+
@NgModule({
|
|
29
|
+
imports: [
|
|
30
|
+
FindRecordModule,
|
|
31
|
+
// other imports
|
|
32
|
+
],
|
|
33
|
+
// ...
|
|
34
|
+
})
|
|
35
|
+
export class YourModule { }
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Basic Component Usage
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<!-- Standalone search component -->
|
|
42
|
+
<mj-find-record
|
|
43
|
+
[EntityName]="'Users'"
|
|
44
|
+
[SearchDebounceTime]="500"
|
|
45
|
+
(OnRecordSelected)="handleRecordSelected($event)">
|
|
46
|
+
</mj-find-record>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Dialog Component Usage
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<!-- Search component in a dialog -->
|
|
53
|
+
<button kendoButton (click)="showFindDialog = true">
|
|
54
|
+
Find User
|
|
55
|
+
</button>
|
|
56
|
+
|
|
57
|
+
<mj-find-record-dialog
|
|
58
|
+
*ngIf="showFindDialog"
|
|
59
|
+
[EntityName]="'Users'"
|
|
60
|
+
[DialogTitle]="'Find User'"
|
|
61
|
+
[DialogVisible]="showFindDialog"
|
|
62
|
+
(DialogClosed)="handleDialogClosed($event)"
|
|
63
|
+
(OnRecordSelected)="handleRecordSelected($event)">
|
|
64
|
+
</mj-find-record-dialog>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### TypeScript Component Example
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { Component } from '@angular/core';
|
|
71
|
+
import { BaseEntity, EntityFieldInfo, Metadata } from '@memberjunction/core';
|
|
72
|
+
|
|
73
|
+
@Component({
|
|
74
|
+
selector: 'app-user-finder',
|
|
75
|
+
template: `
|
|
76
|
+
<h3>Find User</h3>
|
|
77
|
+
<button kendoButton (click)="showDialog()">Open User Finder</button>
|
|
78
|
+
|
|
79
|
+
<div *ngIf="selectedUser">
|
|
80
|
+
<h4>Selected User:</h4>
|
|
81
|
+
<p>{{ selectedUser.Get('UserName') }}</p>
|
|
82
|
+
<p>{{ selectedUser.Get('Email') }}</p>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<mj-find-record-dialog
|
|
86
|
+
*ngIf="dialogVisible"
|
|
87
|
+
[EntityName]="'Users'"
|
|
88
|
+
[DisplayFields]="displayFields"
|
|
89
|
+
[DialogTitle]="'Find User'"
|
|
90
|
+
[DialogVisible]="dialogVisible"
|
|
91
|
+
[DialogWidth]="'800px'"
|
|
92
|
+
[DialogHeight]="'500px'"
|
|
93
|
+
(DialogClosed)="onDialogClosed($event)"
|
|
94
|
+
(OnRecordSelected)="onUserSelected($event)">
|
|
95
|
+
</mj-find-record-dialog>
|
|
96
|
+
`
|
|
97
|
+
})
|
|
98
|
+
export class UserFinderComponent implements OnInit {
|
|
99
|
+
dialogVisible = false;
|
|
100
|
+
selectedUser: BaseEntity | null = null;
|
|
101
|
+
displayFields: EntityFieldInfo[] = [];
|
|
102
|
+
|
|
103
|
+
constructor(private metadata: Metadata) {}
|
|
104
|
+
|
|
105
|
+
ngOnInit() {
|
|
106
|
+
// Get specific fields to display in the grid
|
|
107
|
+
const userEntity = this.metadata.EntityByName('Users');
|
|
108
|
+
if (userEntity) {
|
|
109
|
+
this.displayFields = [
|
|
110
|
+
userEntity.Fields.find(f => f.Name === 'UserName')!,
|
|
111
|
+
userEntity.Fields.find(f => f.Name === 'Email')!,
|
|
112
|
+
userEntity.Fields.find(f => f.Name === 'FirstName')!,
|
|
113
|
+
userEntity.Fields.find(f => f.Name === 'LastName')!
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
showDialog() {
|
|
119
|
+
this.dialogVisible = true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
onUserSelected(user: BaseEntity) {
|
|
123
|
+
this.selectedUser = user;
|
|
124
|
+
console.log('Selected user:', user);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
onDialogClosed(confirmed: boolean) {
|
|
128
|
+
this.dialogVisible = false;
|
|
129
|
+
|
|
130
|
+
if (confirmed && this.selectedUser) {
|
|
131
|
+
console.log('User selection confirmed:', this.selectedUser);
|
|
132
|
+
// Do something with the selected user
|
|
133
|
+
} else {
|
|
134
|
+
console.log('User selection cancelled');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## API Reference
|
|
141
|
+
|
|
142
|
+
### FindRecordComponent
|
|
143
|
+
|
|
144
|
+
Standalone component for searching and selecting records.
|
|
145
|
+
|
|
146
|
+
#### Inputs
|
|
147
|
+
|
|
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)
|
|
151
|
+
|
|
152
|
+
#### Outputs
|
|
153
|
+
|
|
154
|
+
- `OnRecordSelected`: EventEmitter<BaseEntity> - Emitted when a record is selected
|
|
155
|
+
|
|
156
|
+
### FindRecordDialogComponent
|
|
157
|
+
|
|
158
|
+
Dialog wrapper for the FindRecordComponent.
|
|
159
|
+
|
|
160
|
+
#### Inputs
|
|
161
|
+
|
|
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)
|
|
169
|
+
|
|
170
|
+
#### Outputs
|
|
171
|
+
|
|
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
|
|
174
|
+
|
|
175
|
+
## Search Behavior
|
|
176
|
+
|
|
177
|
+
The component uses the MemberJunction RunView functionality with the following behavior:
|
|
178
|
+
|
|
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
|
|
184
|
+
|
|
185
|
+
## Styling
|
|
186
|
+
|
|
187
|
+
The component includes basic CSS styling that can be overridden in your application.
|
|
188
|
+
|
|
189
|
+
## Dependencies
|
|
190
|
+
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-find-record",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.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.33.0",
|
|
34
|
+
"@memberjunction/global": "2.33.0",
|
|
35
|
+
"@memberjunction/core": "2.33.0",
|
|
36
|
+
"@memberjunction/ng-container-directives": "2.33.0",
|
|
37
|
+
"@memberjunction/ng-shared": "2.33.0",
|
|
38
38
|
"rxjs": "^7.8.1",
|
|
39
39
|
"tslib": "^2.3.0"
|
|
40
40
|
},
|