@memberjunction/ng-link-directives 0.9.34 → 0.9.35
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/package.json +4 -4
- package/dist/lib/ng-base-link.d.ts +0 -5
- package/dist/lib/ng-base-link.js +0 -11
- package/dist/lib/ng-email-link.d.ts +0 -13
- package/dist/lib/ng-email-link.js +0 -29
- package/dist/lib/ng-field-link.d.ts +0 -22
- package/dist/lib/ng-field-link.js +0 -84
- package/dist/lib/ng-link-directives.module.d.ts +0 -10
- package/dist/lib/ng-link-directives.module.js +0 -34
- package/dist/lib/ng-web-link.d.ts +0 -13
- package/dist/lib/ng-web-link.js +0 -29
- package/dist/public-api.d.ts +0 -5
- package/dist/public-api.js +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-link-directives",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.35",
|
|
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",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@angular/common": "^15.2.0",
|
|
25
25
|
"@angular/core": "^15.2.0",
|
|
26
|
-
"@angular/router": "^15.2.0"
|
|
27
|
-
"@memberjunction/core": "^0.9.49"
|
|
26
|
+
"@angular/router": "^15.2.0"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
30
|
-
"tslib": "^2.3.0"
|
|
29
|
+
"tslib": "^2.3.0",
|
|
30
|
+
"@memberjunction/core": "^0.9.58"
|
|
31
31
|
},
|
|
32
32
|
"sideEffects": false
|
|
33
33
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ElementRef, Renderer2 } from '@angular/core';
|
|
2
|
-
import { EntityField } from '@memberjunction/core';
|
|
3
|
-
export declare abstract class BaseLink {
|
|
4
|
-
protected CreateLink(el: ElementRef, field: EntityField, renderer: Renderer2, href: string, newTab?: boolean): void;
|
|
5
|
-
}
|
package/dist/lib/ng-base-link.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export class BaseLink {
|
|
2
|
-
CreateLink(el, field, renderer, href, newTab = false) {
|
|
3
|
-
const parent = el.nativeElement.parentNode;
|
|
4
|
-
const a = renderer.createElement('a');
|
|
5
|
-
renderer.setAttribute(a, 'href', href);
|
|
6
|
-
if (newTab)
|
|
7
|
-
renderer.setAttribute(a, 'target', '_blank');
|
|
8
|
-
renderer.insertBefore(parent, a, el.nativeElement);
|
|
9
|
-
renderer.appendChild(a, el.nativeElement);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ElementRef, Renderer2, OnInit } from '@angular/core';
|
|
2
|
-
import { EntityField } from '@memberjunction/core';
|
|
3
|
-
import { BaseLink } from './ng-base-link';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
export declare class EmailLink extends BaseLink implements OnInit {
|
|
6
|
-
private el;
|
|
7
|
-
private renderer;
|
|
8
|
-
field: EntityField;
|
|
9
|
-
constructor(el: ElementRef, renderer: Renderer2);
|
|
10
|
-
ngOnInit(): void;
|
|
11
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<EmailLink, never>;
|
|
12
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<EmailLink, "[mjEmailLink]", never, { "field": "field"; }, {}, never, never, false, never>;
|
|
13
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Directive, Input } from '@angular/core';
|
|
2
|
-
import { LogError } from '@memberjunction/core';
|
|
3
|
-
import { BaseLink } from './ng-base-link';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
export class EmailLink extends BaseLink {
|
|
6
|
-
constructor(el, renderer) {
|
|
7
|
-
super();
|
|
8
|
-
this.el = el;
|
|
9
|
-
this.renderer = renderer;
|
|
10
|
-
}
|
|
11
|
-
ngOnInit() {
|
|
12
|
-
const extendedType = this.field.EntityFieldInfo.ExtendedType;
|
|
13
|
-
if (extendedType && extendedType.trim().toLowerCase() === 'email')
|
|
14
|
-
this.CreateLink(this.el, this.field, this.renderer, 'mailto:' + this.field.Value, true);
|
|
15
|
-
else
|
|
16
|
-
LogError('Entity Field must have ExtendedType of URL to use the mjWebLink directive. Field:' + this.field.Name);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
EmailLink.ɵfac = function EmailLink_Factory(t) { return new (t || EmailLink)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Renderer2)); };
|
|
20
|
-
EmailLink.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: EmailLink, selectors: [["", "mjEmailLink", ""]], inputs: { field: "field" }, features: [i0.ɵɵInheritDefinitionFeature] });
|
|
21
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EmailLink, [{
|
|
22
|
-
type: Directive,
|
|
23
|
-
args: [{
|
|
24
|
-
selector: '[mjEmailLink]'
|
|
25
|
-
}]
|
|
26
|
-
}], function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }]; }, { field: [{
|
|
27
|
-
type: Input,
|
|
28
|
-
args: ['field']
|
|
29
|
-
}] }); })();
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ElementRef, Renderer2, OnInit } from '@angular/core';
|
|
2
|
-
import { ActivatedRoute, Router } from '@angular/router';
|
|
3
|
-
import { BaseEntity, EntityField } from '@memberjunction/core';
|
|
4
|
-
import { BaseLink } from './ng-base-link';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
export declare class FieldLink extends BaseLink implements OnInit {
|
|
7
|
-
private el;
|
|
8
|
-
private renderer;
|
|
9
|
-
private route;
|
|
10
|
-
private router;
|
|
11
|
-
record: BaseEntity;
|
|
12
|
-
fieldName: string;
|
|
13
|
-
replaceText: boolean;
|
|
14
|
-
private _targetEntity;
|
|
15
|
-
private _targetRecordID;
|
|
16
|
-
constructor(el: ElementRef, renderer: Renderer2, route: ActivatedRoute, router: Router);
|
|
17
|
-
get field(): EntityField;
|
|
18
|
-
ngOnInit(): void;
|
|
19
|
-
onClick(event: Event): void;
|
|
20
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<FieldLink, never>;
|
|
21
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<FieldLink, "[mjFieldLink]", never, { "record": "record"; "fieldName": "fieldName"; "replaceText": "replaceText"; }, {}, never, never, false, never>;
|
|
22
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Directive, Input, HostListener } from '@angular/core';
|
|
2
|
-
import { LogStatus, Metadata } from '@memberjunction/core';
|
|
3
|
-
import { BaseLink } from './ng-base-link';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
import * as i1 from "@angular/router";
|
|
6
|
-
export class FieldLink extends BaseLink {
|
|
7
|
-
constructor(el, renderer, route, router) {
|
|
8
|
-
super();
|
|
9
|
-
this.el = el;
|
|
10
|
-
this.renderer = renderer;
|
|
11
|
-
this.route = route;
|
|
12
|
-
this.router = router;
|
|
13
|
-
this.replaceText = true; //
|
|
14
|
-
this._targetEntity = '';
|
|
15
|
-
this._targetRecordID = 0;
|
|
16
|
-
}
|
|
17
|
-
get field() {
|
|
18
|
-
if (!this.record)
|
|
19
|
-
throw new Error('entity not set');
|
|
20
|
-
if (!this.fieldName)
|
|
21
|
-
throw new Error('fieldName not set');
|
|
22
|
-
const field = this.record.Fields.find(f => f.Name === this.fieldName);
|
|
23
|
-
if (!field)
|
|
24
|
-
throw new Error(`Unable to find field ${this.fieldName} in entity ${this.record.EntityInfo.Name}`);
|
|
25
|
-
return field;
|
|
26
|
-
}
|
|
27
|
-
ngOnInit() {
|
|
28
|
-
const relatedEntity = this.field.EntityFieldInfo.RelatedEntity;
|
|
29
|
-
if (relatedEntity && relatedEntity.length > 0) {
|
|
30
|
-
this._targetEntity = relatedEntity;
|
|
31
|
-
this._targetRecordID = this.field.Value;
|
|
32
|
-
this.CreateLink(this.el, this.field, this.renderer, '', false);
|
|
33
|
-
if (this.replaceText) {
|
|
34
|
-
// replace the value of the field with the record name
|
|
35
|
-
// first see if we already have the value locally using metadata for RelatedEntityNameFieldMap
|
|
36
|
-
if (this.field.EntityFieldInfo.RelatedEntityNameFieldMap &&
|
|
37
|
-
this.field.EntityFieldInfo.RelatedEntityNameFieldMap.length > 0) {
|
|
38
|
-
const nameField = this.field.EntityFieldInfo.RelatedEntityNameFieldMap;
|
|
39
|
-
const nameFieldValue = this.record.Get(nameField);
|
|
40
|
-
if (nameFieldValue && nameFieldValue.length > 0)
|
|
41
|
-
this.renderer.setProperty(this.el.nativeElement, 'textContent', nameFieldValue);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
// no luck, no related entity name field map provided in the entity field metadata, so do a lookup
|
|
45
|
-
// requires a server round trip and hitting the DB, so we try to avoid this
|
|
46
|
-
const md = new Metadata();
|
|
47
|
-
md.GetEntityRecordName(relatedEntity, this.field.Value).then(recordName => {
|
|
48
|
-
if (recordName && recordName.length > 0)
|
|
49
|
-
this.renderer.setProperty(this.el.nativeElement, 'textContent', recordName);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
LogStatus('no linked entity found for field: ' + this.field.Name);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
onClick(event) {
|
|
59
|
-
event.preventDefault();
|
|
60
|
-
this.router.navigate(['resource', 'record', this._targetRecordID], { queryParams: { Entity: this._targetEntity } });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
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)); };
|
|
64
|
-
FieldLink.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: FieldLink, selectors: [["", "mjFieldLink", ""]], hostBindings: function FieldLink_HostBindings(rf, ctx) { if (rf & 1) {
|
|
65
|
-
i0.ɵɵlistener("click", function FieldLink_click_HostBindingHandler($event) { return ctx.onClick($event); });
|
|
66
|
-
} }, inputs: { record: "record", fieldName: "fieldName", replaceText: "replaceText" }, features: [i0.ɵɵInheritDefinitionFeature] });
|
|
67
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldLink, [{
|
|
68
|
-
type: Directive,
|
|
69
|
-
args: [{
|
|
70
|
-
selector: '[mjFieldLink]'
|
|
71
|
-
}]
|
|
72
|
-
}], function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.ActivatedRoute }, { type: i1.Router }]; }, { record: [{
|
|
73
|
-
type: Input,
|
|
74
|
-
args: ['record']
|
|
75
|
-
}], fieldName: [{
|
|
76
|
-
type: Input,
|
|
77
|
-
args: ['fieldName']
|
|
78
|
-
}], replaceText: [{
|
|
79
|
-
type: Input,
|
|
80
|
-
args: ['replaceText']
|
|
81
|
-
}], onClick: [{
|
|
82
|
-
type: HostListener,
|
|
83
|
-
args: ['click', ['$event']]
|
|
84
|
-
}] }); })();
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
import * as i1 from "./ng-email-link";
|
|
3
|
-
import * as i2 from "./ng-field-link";
|
|
4
|
-
import * as i3 from "./ng-web-link";
|
|
5
|
-
import * as i4 from "@angular/common";
|
|
6
|
-
export declare class LinkDirectivesModule {
|
|
7
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<LinkDirectivesModule, never>;
|
|
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
|
-
static ɵinj: i0.ɵɵInjectorDeclaration<LinkDirectivesModule>;
|
|
10
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { EmailLink } from './ng-email-link';
|
|
4
|
-
import { FieldLink } from './ng-field-link';
|
|
5
|
-
import { WebLink } from './ng-web-link';
|
|
6
|
-
import * as i0 from "@angular/core";
|
|
7
|
-
export class LinkDirectivesModule {
|
|
8
|
-
}
|
|
9
|
-
LinkDirectivesModule.ɵfac = function LinkDirectivesModule_Factory(t) { return new (t || LinkDirectivesModule)(); };
|
|
10
|
-
LinkDirectivesModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LinkDirectivesModule });
|
|
11
|
-
LinkDirectivesModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] });
|
|
12
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LinkDirectivesModule, [{
|
|
13
|
-
type: NgModule,
|
|
14
|
-
args: [{
|
|
15
|
-
declarations: [
|
|
16
|
-
EmailLink,
|
|
17
|
-
FieldLink,
|
|
18
|
-
WebLink
|
|
19
|
-
],
|
|
20
|
-
imports: [
|
|
21
|
-
CommonModule
|
|
22
|
-
],
|
|
23
|
-
exports: [
|
|
24
|
-
EmailLink,
|
|
25
|
-
FieldLink,
|
|
26
|
-
WebLink
|
|
27
|
-
]
|
|
28
|
-
}]
|
|
29
|
-
}], null, null); })();
|
|
30
|
-
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LinkDirectivesModule, { declarations: [EmailLink,
|
|
31
|
-
FieldLink,
|
|
32
|
-
WebLink], imports: [CommonModule], exports: [EmailLink,
|
|
33
|
-
FieldLink,
|
|
34
|
-
WebLink] }); })();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ElementRef, Renderer2, OnInit } from '@angular/core';
|
|
2
|
-
import { EntityField } from '@memberjunction/core';
|
|
3
|
-
import { BaseLink } from './ng-base-link';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
export declare class WebLink extends BaseLink implements OnInit {
|
|
6
|
-
private el;
|
|
7
|
-
private renderer;
|
|
8
|
-
field: EntityField;
|
|
9
|
-
constructor(el: ElementRef, renderer: Renderer2);
|
|
10
|
-
ngOnInit(): void;
|
|
11
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<WebLink, never>;
|
|
12
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<WebLink, "[mjWebLink]", never, { "field": "field"; }, {}, never, never, false, never>;
|
|
13
|
-
}
|
package/dist/lib/ng-web-link.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Directive, Input } from '@angular/core';
|
|
2
|
-
import { LogError } from '@memberjunction/core';
|
|
3
|
-
import { BaseLink } from './ng-base-link';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
export class WebLink extends BaseLink {
|
|
6
|
-
constructor(el, renderer) {
|
|
7
|
-
super();
|
|
8
|
-
this.el = el;
|
|
9
|
-
this.renderer = renderer;
|
|
10
|
-
}
|
|
11
|
-
ngOnInit() {
|
|
12
|
-
const extendedType = this.field.EntityFieldInfo.ExtendedType;
|
|
13
|
-
if (extendedType && extendedType.trim().toLowerCase() === 'url')
|
|
14
|
-
this.CreateLink(this.el, this.field, this.renderer, this.field.Value, true);
|
|
15
|
-
else
|
|
16
|
-
LogError('Entity Field must have ExtendedType of URL to use the mjWebLink directive. Field:' + this.field.Name);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
WebLink.ɵfac = function WebLink_Factory(t) { return new (t || WebLink)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Renderer2)); };
|
|
20
|
-
WebLink.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: WebLink, selectors: [["", "mjWebLink", ""]], inputs: { field: "field" }, features: [i0.ɵɵInheritDefinitionFeature] });
|
|
21
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WebLink, [{
|
|
22
|
-
type: Directive,
|
|
23
|
-
args: [{
|
|
24
|
-
selector: '[mjWebLink]'
|
|
25
|
-
}]
|
|
26
|
-
}], function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }]; }, { field: [{
|
|
27
|
-
type: Input,
|
|
28
|
-
args: ['field']
|
|
29
|
-
}] }); })();
|
package/dist/public-api.d.ts
DELETED
package/dist/public-api.js
DELETED