@memberjunction/ng-data-context 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.
- package/README.md +78 -146
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
# @memberjunction/ng-data-context
|
|
2
2
|
|
|
3
|
-
Angular
|
|
3
|
+
Angular components for managing MemberJunction Data Contexts -- reusable collections of data sources (views, queries, raw SQL) that can be composed and referenced by reports, dashboards, and AI prompts.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The `@memberjunction/ng-data-context` package provides an interactive component for creating, editing, and previewing data contexts. A data context defines one or more data source items (entity views, stored queries, or raw SQL statements) along with optional filters, and packages them into a named, reusable unit. The package includes both an inline component and a dialog wrapper.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```mermaid
|
|
10
|
+
graph TD
|
|
11
|
+
A[DataContextModule] --> B[DataContextComponent]
|
|
12
|
+
A --> C[DataContextDialogComponent]
|
|
13
|
+
|
|
14
|
+
B --> D["Data Source Items"]
|
|
15
|
+
D --> D1["Entity Views"]
|
|
16
|
+
D --> D2["Stored Queries"]
|
|
17
|
+
D --> D3["Raw SQL"]
|
|
18
|
+
D --> D4["Entity Records"]
|
|
19
|
+
|
|
20
|
+
B --> E["Item Configuration"]
|
|
21
|
+
E --> E1["Filters"]
|
|
22
|
+
E --> E2["Preview"]
|
|
23
|
+
E --> E3["Virtual Scrolling"]
|
|
24
|
+
|
|
25
|
+
C --> B
|
|
10
26
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- **Virtual Scrolling**: Efficiently handle large datasets with Kendo Grid's virtual scrolling
|
|
17
|
-
- **Responsive Design**: Components adapt to different screen sizes
|
|
27
|
+
style A fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
28
|
+
style B fill:#7c5295,stroke:#563a6b,color:#fff
|
|
29
|
+
style C fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
30
|
+
style D fill:#b8762f,stroke:#8a5722,color:#fff
|
|
31
|
+
```
|
|
18
32
|
|
|
19
33
|
## Installation
|
|
20
34
|
|
|
@@ -30,38 +44,31 @@ npm install @memberjunction/ng-data-context
|
|
|
30
44
|
import { DataContextModule } from '@memberjunction/ng-data-context';
|
|
31
45
|
|
|
32
46
|
@NgModule({
|
|
33
|
-
imports: [
|
|
34
|
-
DataContextModule,
|
|
35
|
-
// other imports
|
|
36
|
-
],
|
|
37
|
-
// ...
|
|
47
|
+
imports: [DataContextModule]
|
|
38
48
|
})
|
|
39
49
|
export class YourModule { }
|
|
40
50
|
```
|
|
41
51
|
|
|
42
|
-
###
|
|
52
|
+
### Inline Component
|
|
43
53
|
|
|
44
54
|
```html
|
|
45
|
-
<!-- Display a data context using its ID -->
|
|
46
55
|
<mj-data-context
|
|
47
56
|
[dataContextId]="'your-data-context-id'"
|
|
48
57
|
[Provider]="customMetadataProvider">
|
|
49
58
|
</mj-data-context>
|
|
50
59
|
```
|
|
51
60
|
|
|
52
|
-
### Dialog Component
|
|
61
|
+
### Dialog Component
|
|
53
62
|
|
|
54
63
|
```html
|
|
55
|
-
<!-- Show data context in a dialog -->
|
|
56
64
|
<mj-data-context-dialog
|
|
57
|
-
*ngIf="showDataContextDialog"
|
|
58
65
|
[dataContextId]="selectedDataContextId"
|
|
59
66
|
[Provider]="metadataProvider"
|
|
60
|
-
(dialogClosed)="
|
|
67
|
+
(dialogClosed)="onDialogClosed()">
|
|
61
68
|
</mj-data-context-dialog>
|
|
62
69
|
```
|
|
63
70
|
|
|
64
|
-
### Complete
|
|
71
|
+
### Complete Example
|
|
65
72
|
|
|
66
73
|
```typescript
|
|
67
74
|
import { Component } from '@angular/core';
|
|
@@ -70,82 +77,57 @@ import { IMetadataProvider, Metadata } from '@memberjunction/core';
|
|
|
70
77
|
@Component({
|
|
71
78
|
selector: 'app-data-context-viewer',
|
|
72
79
|
template: `
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<!-- Dialog trigger button -->
|
|
83
|
-
<button (click)="showDialog()">View in Dialog</button>
|
|
84
|
-
|
|
85
|
-
<!-- Dialog component -->
|
|
80
|
+
<mj-data-context
|
|
81
|
+
[dataContextId]="selectedDataContextId"
|
|
82
|
+
[Provider]="metadataProvider">
|
|
83
|
+
</mj-data-context>
|
|
84
|
+
|
|
85
|
+
<button (click)="showDialog()">View in Dialog</button>
|
|
86
|
+
|
|
87
|
+
@if (isDialogVisible) {
|
|
86
88
|
<mj-data-context-dialog
|
|
87
|
-
*ngIf="isDialogVisible"
|
|
88
89
|
[dataContextId]="selectedDataContextId"
|
|
89
90
|
[Provider]="metadataProvider"
|
|
90
91
|
(dialogClosed)="onDialogClose()">
|
|
91
92
|
</mj-data-context-dialog>
|
|
92
|
-
</div>
|
|
93
|
-
`,
|
|
94
|
-
styles: [`
|
|
95
|
-
.data-context-container {
|
|
96
|
-
padding: 20px;
|
|
97
93
|
}
|
|
98
|
-
`
|
|
94
|
+
`
|
|
99
95
|
})
|
|
100
96
|
export class DataContextViewerComponent {
|
|
101
97
|
isDialogVisible = false;
|
|
102
98
|
selectedDataContextId = '12345-67890-abcdef';
|
|
103
99
|
metadataProvider: IMetadataProvider;
|
|
104
|
-
|
|
100
|
+
|
|
105
101
|
constructor() {
|
|
106
|
-
// Use the global metadata provider or inject your own
|
|
107
102
|
this.metadataProvider = Metadata.Provider;
|
|
108
103
|
}
|
|
109
|
-
|
|
104
|
+
|
|
110
105
|
showDialog(): void {
|
|
111
106
|
this.isDialogVisible = true;
|
|
112
107
|
}
|
|
113
|
-
|
|
108
|
+
|
|
114
109
|
onDialogClose(): void {
|
|
115
110
|
this.isDialogVisible = false;
|
|
116
|
-
// Additional cleanup or refresh logic here
|
|
117
111
|
}
|
|
118
112
|
}
|
|
119
113
|
```
|
|
120
114
|
|
|
121
115
|
## API Reference
|
|
122
116
|
|
|
123
|
-
### DataContextComponent
|
|
124
|
-
|
|
125
|
-
The main component for displaying a data context and its items.
|
|
117
|
+
### DataContextComponent (`mj-data-context`)
|
|
126
118
|
|
|
127
|
-
|
|
119
|
+
Main component for displaying a data context and its items.
|
|
128
120
|
|
|
129
121
|
#### Inputs
|
|
130
122
|
|
|
131
123
|
| Input | Type | Required | Default | Description |
|
|
132
124
|
|-------|------|----------|---------|-------------|
|
|
133
125
|
| `dataContextId` | `string` | Yes | - | The ID of the data context to display |
|
|
134
|
-
| `Provider` | `IMetadataProvider \| null` | No | `Metadata.Provider` | Custom metadata provider
|
|
126
|
+
| `Provider` | `IMetadataProvider \| null` | No | `Metadata.Provider` | Custom metadata provider |
|
|
135
127
|
|
|
136
|
-
|
|
128
|
+
### DataContextDialogComponent (`mj-data-context-dialog`)
|
|
137
129
|
|
|
138
|
-
|
|
139
|
-
|----------|------|-------------|
|
|
140
|
-
| `dataContextRecord` | `DataContextEntity \| undefined` | The loaded data context entity |
|
|
141
|
-
| `dataContextItems` | `any[]` | Array of data context items |
|
|
142
|
-
| `showLoader` | `boolean` | Loading state indicator |
|
|
143
|
-
|
|
144
|
-
### DataContextDialogComponent
|
|
145
|
-
|
|
146
|
-
Dialog wrapper component that displays the DataContextComponent in a Kendo dialog.
|
|
147
|
-
|
|
148
|
-
**Selector**: `mj-data-context-dialog`
|
|
130
|
+
Dialog wrapper displaying the DataContextComponent in a Kendo dialog.
|
|
149
131
|
|
|
150
132
|
#### Inputs
|
|
151
133
|
|
|
@@ -160,106 +142,56 @@ Dialog wrapper component that displays the DataContextComponent in a Kendo dialo
|
|
|
160
142
|
|--------|------|-------------|
|
|
161
143
|
| `dialogClosed` | `EventEmitter<void>` | Emitted when the dialog is closed |
|
|
162
144
|
|
|
163
|
-
### DataContextModule
|
|
164
|
-
|
|
165
|
-
The NgModule that exports both components.
|
|
166
|
-
|
|
167
|
-
**Exports**:
|
|
168
|
-
- `DataContextComponent`
|
|
169
|
-
- `DataContextDialogComponent`
|
|
170
|
-
|
|
171
145
|
## Data Context Structure
|
|
172
146
|
|
|
173
147
|
A data context in MemberJunction consists of:
|
|
174
148
|
|
|
175
|
-
1. **Context Record** (`DataContextEntity`)
|
|
176
|
-
|
|
177
|
-
- `
|
|
178
|
-
- `
|
|
179
|
-
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
- `Type`: The type of data item (SQL, View, Query, Entity, Record)
|
|
183
|
-
- `SQL`: Direct SQL query (if applicable)
|
|
184
|
-
- `ViewID`: Reference to a view
|
|
185
|
-
- `QueryID`: Reference to a saved query
|
|
186
|
-
- `EntityID`: Reference to an entity
|
|
187
|
-
- `RecordID`: Specific record reference
|
|
188
|
-
|
|
189
|
-
## Grid Features
|
|
190
|
-
|
|
191
|
-
The component uses Kendo Grid with the following features enabled:
|
|
192
|
-
- **Virtual Scrolling**: Efficiently handles large datasets
|
|
193
|
-
- **Sorting**: Click column headers to sort
|
|
194
|
-
- **Resizable Columns**: Drag column borders to resize
|
|
195
|
-
- **Keyboard Navigation**: Navigate cells with keyboard
|
|
196
|
-
- **Page Size**: Default 100 items per virtual page
|
|
197
|
-
|
|
198
|
-
## Styling
|
|
199
|
-
|
|
200
|
-
The components use Kendo UI for Angular styling. You can override styles by targeting the component selectors:
|
|
201
|
-
|
|
202
|
-
```css
|
|
203
|
-
/* Custom styling example */
|
|
204
|
-
mj-data-context {
|
|
205
|
-
/* Your custom styles */
|
|
206
|
-
}
|
|
149
|
+
1. **Context Record** (`DataContextEntity`) -- ID, Name, Description, and metadata
|
|
150
|
+
2. **Context Items** (`Data Context Items` entity) with the following types:
|
|
151
|
+
- `SQL` -- Direct SQL query
|
|
152
|
+
- `View` -- Reference to a saved view
|
|
153
|
+
- `Query` -- Reference to a stored query
|
|
154
|
+
- `Entity` -- Reference to an entity
|
|
155
|
+
- `Record` -- Specific record reference
|
|
207
156
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
157
|
+
## Features
|
|
158
|
+
|
|
159
|
+
- **Multi-source composition**: Combine entity views, stored queries, raw SQL, and specific records into a single named context
|
|
160
|
+
- **Virtual scrolling**: Efficient handling of large datasets via Kendo Grid
|
|
161
|
+
- **Column sorting and resizing**: Interactive grid features
|
|
162
|
+
- **Metadata integration**: Uses MemberJunction's metadata system for entity loading
|
|
163
|
+
- **Loading state management**: Built-in loading indicators
|
|
164
|
+
- **Custom provider support**: Works with custom metadata providers for multi-tenant scenarios
|
|
165
|
+
- **Error handling**: Logs errors via MemberJunction's `LogError` function
|
|
212
166
|
|
|
213
167
|
## Dependencies
|
|
214
168
|
|
|
215
169
|
### Runtime Dependencies
|
|
216
|
-
- `@memberjunction/core` (v2.43.0): Core MemberJunction functionality
|
|
217
|
-
- `@memberjunction/core-entities` (v2.43.0): Entity type definitions
|
|
218
|
-
- `@memberjunction/global` (v2.43.0): Global utilities
|
|
219
|
-
- `tslib` (^2.3.0): TypeScript runtime helpers
|
|
220
|
-
|
|
221
|
-
### Peer Dependencies
|
|
222
|
-
- `@angular/common` (18.0.2)
|
|
223
|
-
- `@angular/core` (18.0.2)
|
|
224
|
-
- `@progress/kendo-angular-grid` (16.2.0)
|
|
225
|
-
- `@progress/kendo-angular-indicators` (16.2.0)
|
|
226
|
-
- `@progress/kendo-angular-dialog` (imported via module)
|
|
227
|
-
- `@progress/kendo-angular-buttons` (imported via module)
|
|
228
|
-
|
|
229
|
-
## Integration with MemberJunction
|
|
230
170
|
|
|
231
|
-
|
|
171
|
+
| Package | Description |
|
|
172
|
+
|---------|-------------|
|
|
173
|
+
| `@memberjunction/core` | Core MemberJunction framework |
|
|
174
|
+
| `@memberjunction/core-entities` | Entity type definitions |
|
|
175
|
+
| `@memberjunction/global` | Global utilities |
|
|
176
|
+
| `@memberjunction/ng-container-directives` | Container directives |
|
|
177
|
+
| `@memberjunction/ng-shared` | Shared Angular utilities |
|
|
178
|
+
| `@progress/kendo-angular-grid` | Grid with virtual scrolling |
|
|
179
|
+
| `@progress/kendo-angular-indicators` | Loading indicators |
|
|
180
|
+
| `@progress/kendo-angular-dialog` | Dialog component |
|
|
181
|
+
| `@progress/kendo-angular-buttons` | Button components |
|
|
232
182
|
|
|
233
|
-
|
|
234
|
-
- Leverages `RunView` for efficient data retrieval
|
|
235
|
-
- Compatible with MemberJunction's security and permission system
|
|
236
|
-
- Works with custom metadata providers for multi-tenant scenarios
|
|
183
|
+
### Peer Dependencies
|
|
237
184
|
|
|
238
|
-
|
|
185
|
+
- `@angular/common` ^21.x
|
|
186
|
+
- `@angular/core` ^21.x
|
|
239
187
|
|
|
240
|
-
|
|
188
|
+
## Build
|
|
241
189
|
|
|
242
190
|
```bash
|
|
243
191
|
cd packages/Angular/Generic/data-context
|
|
244
192
|
npm run build
|
|
245
193
|
```
|
|
246
194
|
|
|
247
|
-
The package uses Angular CLI's `ngc` compiler for building the library.
|
|
248
|
-
|
|
249
|
-
## Error Handling
|
|
250
|
-
|
|
251
|
-
The component includes built-in error handling:
|
|
252
|
-
- Logs errors using MemberJunction's `LogError` function
|
|
253
|
-
- Hides the loader on error
|
|
254
|
-
- Gracefully handles missing or invalid data context IDs
|
|
255
|
-
|
|
256
|
-
## Best Practices
|
|
257
|
-
|
|
258
|
-
1. **Provider Usage**: Only provide a custom `Provider` if you need to override the global metadata provider
|
|
259
|
-
2. **Dialog Management**: Always handle the `dialogClosed` event to properly manage dialog state
|
|
260
|
-
3. **Performance**: The virtual scrolling is optimized for datasets up to several thousand items
|
|
261
|
-
4. **Error Handling**: Monitor console logs for any data loading errors
|
|
262
|
-
|
|
263
195
|
## License
|
|
264
196
|
|
|
265
|
-
ISC
|
|
197
|
+
ISC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-data-context",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "MemberJunction: Angular component and pop-up window to display and edit the contents of a data context.",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@angular/forms": "21.1.3",
|
|
29
|
-
"@memberjunction/core": "4.
|
|
30
|
-
"@memberjunction/core-entities": "4.
|
|
31
|
-
"@memberjunction/global": "4.
|
|
32
|
-
"@memberjunction/ng-container-directives": "4.
|
|
33
|
-
"@memberjunction/ng-shared-generic": "4.
|
|
29
|
+
"@memberjunction/core": "4.2.0",
|
|
30
|
+
"@memberjunction/core-entities": "4.2.0",
|
|
31
|
+
"@memberjunction/global": "4.2.0",
|
|
32
|
+
"@memberjunction/ng-container-directives": "4.2.0",
|
|
33
|
+
"@memberjunction/ng-shared-generic": "4.2.0",
|
|
34
34
|
"@progress/kendo-angular-buttons": "22.0.1",
|
|
35
35
|
"@progress/kendo-angular-dialog": "22.0.1",
|
|
36
36
|
"@progress/kendo-angular-inputs": "22.0.1",
|