@memberjunction/ng-base-types 2.32.2 → 2.34.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 +118 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # @memberjunction/ng-base-types
2
+
3
+ Foundational types and base classes for Angular components in the MemberJunction ecosystem, providing common functionality and type definitions.
4
+
5
+ ## Features
6
+
7
+ - Abstract base component for Angular integration
8
+ - Provider management for data access
9
+ - Common event types and coordination
10
+ - Form component event handling
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @memberjunction/ng-base-types
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ### BaseAngularComponent
21
+
22
+ Abstract base class for all MemberJunction Angular components:
23
+
24
+ ```typescript
25
+ import { BaseAngularComponent } from '@memberjunction/ng-base-types';
26
+
27
+ @Component({
28
+ selector: 'your-component',
29
+ templateUrl: './your.component.html',
30
+ styleUrls: ['./your.component.css']
31
+ })
32
+ export class YourComponent extends BaseAngularComponent {
33
+ // Your component implementation
34
+
35
+ ngOnInit() {
36
+ // Access providers through the base class
37
+ const metadata = this.ProviderToUse;
38
+
39
+ // Run views through the base class
40
+ const viewProvider = this.RunViewToUse;
41
+ }
42
+ }
43
+ ```
44
+
45
+ The BaseAngularComponent provides:
46
+
47
+ - Provider management for connecting to different MemberJunction API instances
48
+ - Accessor methods for different provider types:
49
+ - `ProviderToUse`: Access the metadata provider
50
+ - `RunViewToUse`: Access the RunView provider
51
+ - `RunQueryToUse`: Access the RunQuery provider
52
+ - `RunReportToUse`: Access the RunReport provider
53
+
54
+ ### Form Component Events
55
+
56
+ Types for coordinating events between form components:
57
+
58
+ ```typescript
59
+ import {
60
+ BaseFormComponentEventCodes,
61
+ BaseFormComponentEvent,
62
+ FormEditingCompleteEvent,
63
+ PendingRecordItem
64
+ } from '@memberjunction/ng-base-types';
65
+
66
+ // Listen for form events
67
+ handleFormEvent(event: BaseFormComponentEvent) {
68
+ switch(event.subEventCode) {
69
+ case BaseFormComponentEventCodes.EDITING_COMPLETE:
70
+ const editEvent = event as FormEditingCompleteEvent;
71
+ // Process pending changes
72
+ editEvent.pendingChanges.forEach(item => {
73
+ if (item.action === 'save') {
74
+ // Save the entity
75
+ item.entityObject.Save();
76
+ } else if (item.action === 'delete') {
77
+ // Delete the entity
78
+ item.entityObject.Delete();
79
+ }
80
+ });
81
+ break;
82
+
83
+ case BaseFormComponentEventCodes.REVERT_PENDING_CHANGES:
84
+ // Handle reverting changes
85
+ break;
86
+
87
+ case BaseFormComponentEventCodes.POPULATE_PENDING_RECORDS:
88
+ // Handle populating pending records
89
+ break;
90
+ }
91
+ }
92
+
93
+ // Create and emit a form event
94
+ const event = new FormEditingCompleteEvent();
95
+ event.pendingChanges = [
96
+ { entityObject: myEntity, action: 'save' }
97
+ ];
98
+ someEventEmitter.emit(event);
99
+ ```
100
+
101
+ ## Provider Configuration
102
+
103
+ You can customize the data providers used by components by setting the Provider input:
104
+
105
+ ```typescript
106
+ import { GraphQLDataProvider } from '@memberjunction/graphql-dataprovider';
107
+
108
+ // In your component template
109
+ <your-component [Provider]="customProvider"></your-component>
110
+
111
+ // In your component class
112
+ customProvider = new GraphQLDataProvider({
113
+ endpoint: 'https://your-custom-endpoint/graphql',
114
+ // other configuration options
115
+ });
116
+ ```
117
+
118
+ This allows different components to connect to different MemberJunction API instances within the same application.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-base-types",
3
- "version": "2.32.2",
3
+ "version": "2.34.0",
4
4
  "description": "MemberJunction: Simple types that are used across many generic Angular UI components for coordination",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -23,9 +23,9 @@
23
23
  "@angular/core": "18.0.2"
24
24
  },
25
25
  "dependencies": {
26
- "@memberjunction/core-entities": "2.32.2",
27
- "@memberjunction/global": "2.32.2",
28
- "@memberjunction/core": "2.32.2",
26
+ "@memberjunction/core-entities": "2.34.0",
27
+ "@memberjunction/global": "2.34.0",
28
+ "@memberjunction/core": "2.34.0",
29
29
  "tslib": "^2.3.0"
30
30
  },
31
31
  "sideEffects": false