@memberjunction/ng-link-directives 0.9.125 → 0.9.128

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.
@@ -3,3 +3,4 @@ import { EntityField } from '@memberjunction/core';
3
3
  export declare abstract class BaseLink {
4
4
  protected CreateLink(el: ElementRef, field: EntityField, renderer: Renderer2, href: string, newTab?: boolean): void;
5
5
  }
6
+ //# sourceMappingURL=ng-base-link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-base-link.d.ts","sourceRoot":"","sources":["../../src/lib/ng-base-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,8BAAsB,QAAQ;IAC1B,SAAS,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,OAAe;CAStH"}
@@ -11,3 +11,4 @@ export declare class EmailLink extends BaseLink implements OnInit {
11
11
  static ɵfac: i0.ɵɵFactoryDeclaration<EmailLink, never>;
12
12
  static ɵdir: i0.ɵɵDirectiveDeclaration<EmailLink, "[mjEmailLink]", never, { "field": { "alias": "field"; "required": false; }; }, {}, never, never, false, never>;
13
13
  }
14
+ //# sourceMappingURL=ng-email-link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-email-link.d.ts","sourceRoot":"","sources":["../../src/lib/ng-email-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,SAAS,EAAS,MAAM,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,WAAW,EAAY,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C,qBAGa,SAAU,SAAQ,QAAS,YAAW,MAAM;IAG3C,OAAO,CAAC,EAAE;IAAc,OAAO,CAAC,QAAQ;IAFpC,KAAK,EAAG,WAAW,CAAC;gBAEhB,EAAE,EAAE,UAAU,EAAU,QAAQ,EAAE,SAAS;IAI/D,QAAQ;yCAPG,SAAS;2CAAT,SAAS;CAcrB"}
@@ -12,6 +12,7 @@ export declare class FieldLink extends BaseLink implements OnInit {
12
12
  fieldName: string;
13
13
  replaceText: boolean;
14
14
  private _targetEntity;
15
+ private _targetEntityInfo;
15
16
  private _targetRecordID;
16
17
  constructor(el: ElementRef, renderer: Renderer2, route: ActivatedRoute, router: Router);
17
18
  get field(): EntityField;
@@ -20,3 +21,4 @@ export declare class FieldLink extends BaseLink implements OnInit {
20
21
  static ɵfac: i0.ɵɵFactoryDeclaration<FieldLink, never>;
21
22
  static ɵdir: i0.ɵɵDirectiveDeclaration<FieldLink, "[mjFieldLink]", never, { "record": { "alias": "record"; "required": false; }; "fieldName": { "alias": "fieldName"; "required": false; }; "replaceText": { "alias": "replaceText"; "required": false; }; }, {}, never, never, false, never>;
22
23
  }
24
+ //# sourceMappingURL=ng-field-link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-field-link.d.ts","sourceRoot":"","sources":["../../src/lib/ng-field-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,SAAS,EAAS,MAAM,EAAgB,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAmC,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C,qBAGa,SAAU,SAAQ,QAAS,YAAW,MAAM;IAU3C,OAAO,CAAC,EAAE;IAAc,OAAO,CAAC,QAAQ;IAAa,OAAO,CAAC,KAAK;IAAkB,OAAO,CAAC,MAAM;IAR7F,MAAM,EAAG,UAAU,CAAC;IACjB,SAAS,EAAG,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;IAEnD,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,eAAe,CAAa;gBAEhB,EAAE,EAAE,UAAU,EAAU,QAAQ,EAAE,SAAS,EAAU,KAAK,EAAE,cAAc,EAAU,MAAM,EAAE,MAAM;IAItH,IAAW,KAAK,IAAI,WAAW,CAM9B;IAED,QAAQ;IA6CR,OAAO,CAAC,KAAK,EAAE,KAAK;yCAnET,SAAS;2CAAT,SAAS;CA6ErB"}
@@ -29,6 +29,10 @@ export class FieldLink extends BaseLink {
29
29
  if (relatedEntity && relatedEntity.length > 0) {
30
30
  this._targetEntity = relatedEntity;
31
31
  this._targetRecordID = this.field.Value;
32
+ const md = new Metadata();
33
+ this._targetEntityInfo = md.Entities.find(e => e.Name === relatedEntity);
34
+ if (!this._targetEntityInfo)
35
+ throw new Error('Related entity not found in metadata: ' + relatedEntity);
32
36
  this.CreateLink(this.el, this.field, this.renderer, '', false);
33
37
  if (this.replaceText) {
34
38
  // replace the value of the field with the record name
@@ -44,8 +48,11 @@ export class FieldLink extends BaseLink {
44
48
  // make sure that this.field.Value is not null or undefined
45
49
  // we didn't have the related field mapping info (above), no related entity name field map provided in the entity field metadata, so do a lookup
46
50
  // requires a server round trip and hitting the DB, so we try to avoid this
47
- const md = new Metadata();
48
- md.GetEntityRecordName(relatedEntity, [{ FieldName: "ID", Value: this.field.Value }]).then(recordName => {
51
+ const pkVals = [{
52
+ FieldName: this._targetEntityInfo.PrimaryKey.Name, // AT THE MOMENT - we only support foreign keys with a single value
53
+ Value: this.field.Value
54
+ }];
55
+ md.GetEntityRecordName(relatedEntity, pkVals).then(recordName => {
49
56
  if (recordName && recordName.length > 0)
50
57
  this.renderer.setProperty(this.el.nativeElement, 'textContent', recordName);
51
58
  });
@@ -58,7 +65,11 @@ export class FieldLink extends BaseLink {
58
65
  }
59
66
  onClick(event) {
60
67
  event.preventDefault();
61
- this.router.navigate(['resource', 'record', this._targetRecordID], { queryParams: { Entity: this._targetEntity } });
68
+ if (!this._targetEntityInfo)
69
+ throw new Error('targetEntityInfo not set');
70
+ // AT THE MOMENT - we only support foreign keys with a single value
71
+ const keyVals = `${this._targetEntityInfo.PrimaryKey.Name}|${this._targetRecordID}`;
72
+ this.router.navigate(['resource', 'record', keyVals], { queryParams: { Entity: this._targetEntity } });
62
73
  }
63
74
  }
64
75
  FieldLink.ɵfac = function FieldLink_Factory(t) { return new (t || FieldLink)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i1.ActivatedRoute), i0.ɵɵdirectiveInject(i1.Router)); };
@@ -8,3 +8,4 @@ export declare class LinkDirectivesModule {
8
8
  static ɵmod: i0.ɵɵNgModuleDeclaration<LinkDirectivesModule, [typeof i1.EmailLink, typeof i2.FieldLink, typeof i3.WebLink], [typeof i4.CommonModule], [typeof i1.EmailLink, typeof i2.FieldLink, typeof i3.WebLink]>;
9
9
  static ɵinj: i0.ɵɵInjectorDeclaration<LinkDirectivesModule>;
10
10
  }
11
+ //# sourceMappingURL=ng-link-directives.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-link-directives.module.d.ts","sourceRoot":"","sources":["../../src/lib/ng-link-directives.module.ts"],"names":[],"mappings":";;;;;AAMA,qBAea,oBAAoB;yCAApB,oBAAoB;0CAApB,oBAAoB;0CAApB,oBAAoB;CAAI"}
@@ -11,3 +11,4 @@ export declare class WebLink extends BaseLink implements OnInit {
11
11
  static ɵfac: i0.ɵɵFactoryDeclaration<WebLink, never>;
12
12
  static ɵdir: i0.ɵɵDirectiveDeclaration<WebLink, "[mjWebLink]", never, { "field": { "alias": "field"; "required": false; }; }, {}, never, never, false, never>;
13
13
  }
14
+ //# sourceMappingURL=ng-web-link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-web-link.d.ts","sourceRoot":"","sources":["../../src/lib/ng-web-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,SAAS,EAAS,MAAM,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,WAAW,EAAY,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C,qBAGa,OAAQ,SAAQ,QAAS,YAAW,MAAM;IAGzC,OAAO,CAAC,EAAE;IAAc,OAAO,CAAC,QAAQ;IAFpC,KAAK,EAAG,WAAW,CAAC;gBAEhB,EAAE,EAAE,UAAU,EAAU,QAAQ,EAAE,SAAS;IAI/D,QAAQ;yCAPG,OAAO;2CAAP,OAAO;CAcnB"}
@@ -3,3 +3,4 @@ export * from './lib/ng-base-link';
3
3
  export * from './lib/ng-email-link';
4
4
  export * from './lib/ng-web-link';
5
5
  export * from './lib/ng-field-link';
6
+ //# sourceMappingURL=public-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAIA,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-link-directives",
3
- "version": "0.9.125",
3
+ "version": "0.9.128",
4
4
  "description": "MemberJunction: Angular Link Directives for turning an element in an angular app into an email, web, or record link",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "tslib": "^2.3.0",
33
- "@memberjunction/core": "^0.9.169"
33
+ "@memberjunction/core": "^0.9.172"
34
34
  },
35
35
  "sideEffects": false
36
36
  }