@memberjunction/ng-record-changes 2.32.2 → 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 +194 -0
- package/package.json +5 -5
package/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# @memberjunction/ng-record-changes
|
|
2
|
+
|
|
3
|
+
The `@memberjunction/ng-record-changes` package provides an Angular dialog component that displays a chronological history of changes made to a MemberJunction entity record. It shows field-by-field changes with before and after values in an easy-to-read format.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Modal dialog interface for viewing record change history
|
|
8
|
+
- Chronological display of changes with timestamps
|
|
9
|
+
- Field-by-field change tracking with before and after values
|
|
10
|
+
- Color-coded presentation for easy comparison
|
|
11
|
+
- Sortable grid interface
|
|
12
|
+
- Formatted display of different field types
|
|
13
|
+
- Integration with MemberJunction's audit trail system
|
|
14
|
+
- Support for any entity type with change tracking enabled
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @memberjunction/ng-record-changes
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
- Angular 18+
|
|
25
|
+
- @memberjunction/core
|
|
26
|
+
- @memberjunction/global
|
|
27
|
+
- @progress/kendo-angular-grid
|
|
28
|
+
- @progress/kendo-angular-indicators
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### Basic Setup
|
|
33
|
+
|
|
34
|
+
First, import the RecordChangesModule in your module:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { RecordChangesModule } from '@memberjunction/ng-record-changes';
|
|
38
|
+
|
|
39
|
+
@NgModule({
|
|
40
|
+
imports: [
|
|
41
|
+
// other imports...
|
|
42
|
+
RecordChangesModule
|
|
43
|
+
],
|
|
44
|
+
})
|
|
45
|
+
export class YourModule { }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Basic Usage
|
|
49
|
+
|
|
50
|
+
Use the component in your template to show the change history for a record:
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<button (click)="showChanges()">View History</button>
|
|
54
|
+
|
|
55
|
+
<mj-record-changes
|
|
56
|
+
*ngIf="isHistoryDialogOpen"
|
|
57
|
+
[record]="entityRecord"
|
|
58
|
+
(dialogClosed)="closeChangesDialog()">
|
|
59
|
+
</mj-record-changes>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
In your component:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { Component } from '@angular/core';
|
|
66
|
+
import { BaseEntity, Metadata } from '@memberjunction/core';
|
|
67
|
+
|
|
68
|
+
@Component({
|
|
69
|
+
selector: 'app-record-detail',
|
|
70
|
+
templateUrl: './record-detail.component.html',
|
|
71
|
+
})
|
|
72
|
+
export class RecordDetailComponent {
|
|
73
|
+
entityRecord!: BaseEntity;
|
|
74
|
+
isHistoryDialogOpen: boolean = false;
|
|
75
|
+
|
|
76
|
+
constructor(private metadata: Metadata) {}
|
|
77
|
+
|
|
78
|
+
async ngOnInit() {
|
|
79
|
+
// Load your entity record
|
|
80
|
+
this.entityRecord = await this.metadata.GetEntityObject('Customer', 1);
|
|
81
|
+
await this.entityRecord.Load();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
showChanges() {
|
|
85
|
+
this.isHistoryDialogOpen = true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
closeChangesDialog() {
|
|
89
|
+
this.isHistoryDialogOpen = false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## API Reference
|
|
95
|
+
|
|
96
|
+
### RecordChangesComponent
|
|
97
|
+
|
|
98
|
+
#### Inputs
|
|
99
|
+
|
|
100
|
+
| Name | Type | Description |
|
|
101
|
+
|------|------|-------------|
|
|
102
|
+
| `record` | `BaseEntity` | The entity record whose change history to display |
|
|
103
|
+
|
|
104
|
+
#### Outputs
|
|
105
|
+
|
|
106
|
+
| Name | Type | Description |
|
|
107
|
+
|------|------|-------------|
|
|
108
|
+
| `dialogClosed` | `EventEmitter<void>` | Emitted when the dialog is closed |
|
|
109
|
+
|
|
110
|
+
## How It Works
|
|
111
|
+
|
|
112
|
+
1. When the component is initialized, it makes a query to the `Record Changes` entity in MemberJunction, filtering by the entity name and record ID provided.
|
|
113
|
+
|
|
114
|
+
2. The changes are displayed in reverse chronological order (newest first) with timestamps.
|
|
115
|
+
|
|
116
|
+
3. For each change, the component shows:
|
|
117
|
+
- The field name that was changed
|
|
118
|
+
- The old value (in gray)
|
|
119
|
+
- The new value (in blue)
|
|
120
|
+
|
|
121
|
+
4. For boolean fields, only the new value is shown as the old value is implied.
|
|
122
|
+
|
|
123
|
+
5. The component handles formatting of different field types appropriately:
|
|
124
|
+
- Dates are formatted in a user-friendly way
|
|
125
|
+
- Booleans show clear true/false values
|
|
126
|
+
- Numbers are formatted with appropriate separators
|
|
127
|
+
|
|
128
|
+
## Styling
|
|
129
|
+
|
|
130
|
+
The component uses the following CSS classes that can be customized:
|
|
131
|
+
|
|
132
|
+
- `.kendo-window-custom`: Applied to the main dialog window
|
|
133
|
+
- `.kendo-grid-container`: Container for the changes grid
|
|
134
|
+
|
|
135
|
+
## Advanced Usage
|
|
136
|
+
|
|
137
|
+
### Conditional Display Based on Entity Type
|
|
138
|
+
|
|
139
|
+
You can conditionally show the history button based on whether the entity tracks changes:
|
|
140
|
+
|
|
141
|
+
```html
|
|
142
|
+
<button *ngIf="entityRecord?.EntityInfo?.TrackRecordChanges"
|
|
143
|
+
(click)="showChanges()">
|
|
144
|
+
View History
|
|
145
|
+
</button>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Integration with Form Components
|
|
149
|
+
|
|
150
|
+
The record changes component can be integrated with form components to provide a complete editing and auditing solution:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { Component } from '@angular/core';
|
|
154
|
+
import { BaseFormComponent } from '@memberjunction/ng-base-forms';
|
|
155
|
+
|
|
156
|
+
@Component({
|
|
157
|
+
selector: 'app-customer-form',
|
|
158
|
+
templateUrl: './customer-form.component.html',
|
|
159
|
+
})
|
|
160
|
+
export class CustomerFormComponent extends BaseFormComponent {
|
|
161
|
+
isHistoryDialogOpen: boolean = false;
|
|
162
|
+
|
|
163
|
+
handleHistoryDialog() {
|
|
164
|
+
this.isHistoryDialogOpen = !this.isHistoryDialogOpen;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
```html
|
|
170
|
+
<div class="form-actions">
|
|
171
|
+
<button (click)="handleHistoryDialog()">View History</button>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<mj-record-changes
|
|
175
|
+
*ngIf="isHistoryDialogOpen"
|
|
176
|
+
[record]="record"
|
|
177
|
+
(dialogClosed)="handleHistoryDialog()">
|
|
178
|
+
</mj-record-changes>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Dependencies
|
|
182
|
+
|
|
183
|
+
- @angular/common
|
|
184
|
+
- @angular/core
|
|
185
|
+
- @angular/forms
|
|
186
|
+
- @angular/router
|
|
187
|
+
- @memberjunction/core
|
|
188
|
+
- @memberjunction/global
|
|
189
|
+
- @memberjunction/ng-compare-records
|
|
190
|
+
- @memberjunction/ng-container-directives
|
|
191
|
+
- @progress/kendo-angular-grid
|
|
192
|
+
- @progress/kendo-angular-indicators
|
|
193
|
+
- @progress/kendo-angular-dialog
|
|
194
|
+
- @progress/kendo-angular-buttons
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-record-changes",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
4
4
|
"description": "MemberJunction: Angular pop-up window and grid to show changes made to a specific individual record",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@progress/kendo-angular-indicators": "16.2.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@memberjunction/core": "2.
|
|
31
|
-
"@memberjunction/global": "2.
|
|
32
|
-
"@memberjunction/ng-compare-records": "2.
|
|
33
|
-
"@memberjunction/ng-container-directives": "2.
|
|
30
|
+
"@memberjunction/core": "2.33.0",
|
|
31
|
+
"@memberjunction/global": "2.33.0",
|
|
32
|
+
"@memberjunction/ng-compare-records": "2.33.0",
|
|
33
|
+
"@memberjunction/ng-container-directives": "2.33.0",
|
|
34
34
|
"tslib": "^2.3.0"
|
|
35
35
|
},
|
|
36
36
|
"sideEffects": false
|