src/lib/components/hyperlink-field/hyperlink-field.component.ts
Angular Component for the HyperLinkField Control.
changeDetection | ChangeDetectionStrategy.OnPush |
providers |
{ provide: DataControlFieldComponent, useExisting: HyperlinkFieldComponent }
|
selector | wm-hyperlink-field |
styleUrls | ./hyperlink-field.component.scss |
templateUrl | ./hyperlink-field.component.html |
Properties |
|
Methods |
Inputs |
Outputs |
Accessors |
constructor(refChange: ChangeDetectorRef, render2: Renderer2, elem: ElementRef, webComponents: WebComponentsService, bringTopServ1: BringTopService)
|
||||||||||||||||||
Creates an instance of HyperlinkFieldComponent.
Parameters :
|
dataNavigateUrlFields | |
Type : string
|
|
Sets the dataNavigateUrlFields property. |
dataNavigateUrlFormatString | |
Type : string
|
|
Gets/sets the dataNavigateUrlFormatString property. |
dataTextField | |
Type : string
|
|
Gets/sets the dataTextField property. |
text | |
Type : string
|
|
Gets/sets the text property |
headerText | |
Type : string
|
|
Inherited from
DataControlFieldComponent
|
|
Defined in
DataControlFieldComponent:94
|
|
Gets/sets the headerText property. |
sortExpression | |
Type : string
|
|
Inherited from
DataControlFieldComponent
|
|
Defined in
DataControlFieldComponent:108
|
|
Gets/sets the sortExpression property. |
visible | |
Type : boolean
|
|
Inherited from
DataControlFieldComponent
|
|
Defined in
DataControlFieldComponent:144
|
|
Gets/sets the visible property. |
NavigateToPage | |
Type : EventEmitter<EventData>
|
|
Emitter for the NavigateToPage event. |
clickHandler |
clickHandler(dataItem: any, rowIndex: number)
|
Handler for the HyperLinkField click.
Returns :
void
|
getTarget | ||||||
getTarget(dataItem: any)
|
||||||
Returns the target page with the correct format/params.
Parameters :
Returns :
string
{string} |
getTargetParams | ||||||
getTargetParams(target: string)
|
||||||
Returns the parameters in the target URL.
Parameters :
Returns :
any
{*} |
Static NavigateToPageEventArgsExtractor | |||||||||
NavigateToPageEventArgsExtractor(event: any, component: HyperlinkFieldComponent)
|
|||||||||
NavigateToPage Extractor.
Parameters :
Returns :
any
{*} |
triggerNavigateToPage | ||||||
triggerNavigateToPage(event: any)
|
||||||
Decorators :
@serverEvent('NavigateToPage', HyperlinkFieldComponent.NavigateToPageEventArgsExtractor)
|
||||||
Triggers the NavigateToPage event.
Parameters :
Returns :
void
|
isBindedEvent | ||||||
isBindedEvent(event: string)
|
||||||
Inherited from
DataControlFieldComponent
|
||||||
Defined in
DataControlFieldComponent:170
|
||||||
Override the isBindedEvent to get the event from the Field model
Parameters :
Returns :
boolean
{boolean} |
Private dataNavigateUrlFieldsInternal |
Type : string[]
|
Default value : []
|
Property to save the dataNavigateUrlFields array value. |
Private dataNavigateUrlFormatStringInternal |
Type : string
|
Default value : ''
|
Property to save the dataNavigateUrlFormatString value. |
Private dataTextFieldInternal |
Type : string
|
Default value : ''
|
Property to save the dataTextField value. |
Private textInternal |
Type : string
|
Default value : ''
|
Property to save the text value. |
Private headerTextInternal |
Type : string
|
Default value : ''
|
Inherited from
DataControlFieldComponent
|
Defined in
DataControlFieldComponent:50
|
Property to save the headerText value. |
Private sortExpressionInternal |
Type : string
|
Default value : ''
|
Inherited from
DataControlFieldComponent
|
Defined in
DataControlFieldComponent:58
|
Property to save the sortExpression value. |
Private visibleInternal |
Default value : true
|
Inherited from
DataControlFieldComponent
|
Defined in
DataControlFieldComponent:66
|
Property to save the visible value. |
text | ||||||
gettext()
|
||||||
settext(value: string)
|
||||||
Gets/sets the text property
Parameters :
Returns :
void
|
dataTextField | ||||||
getdataTextField()
|
||||||
setdataTextField(value: string)
|
||||||
Gets/sets the dataTextField property.
Parameters :
Returns :
void
|
dataNavigateUrlFields | ||||||
setdataNavigateUrlFields(value: string)
|
||||||
Sets the dataNavigateUrlFields property.
Parameters :
Returns :
void
|
dataNavigateUrlFieldsValue |
getdataNavigateUrlFieldsValue()
|
Gets the dataNavigateUrlFields property value.
Returns :
string[]
|
dataNavigateUrlFormatString | ||||||
getdataNavigateUrlFormatString()
|
||||||
setdataNavigateUrlFormatString(value: string)
|
||||||
Gets/sets the dataNavigateUrlFormatString property.
Parameters :
Returns :
void
|
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
Input,
Optional,
Output,
Renderer2
} from '@angular/core';
import {
dataTransfer,
BringTopService,
EventData,
serverEvent
} from '@mobilize/base-components';
import { ErrorCodes, ExceptionHandlerClass } from '@mobilize/webmap-core';
import { WebComponentsService } from '@mobilize/winforms-components';
import { DataControlFieldComponent } from '../data-control-field/data-control-field.component';
/**
* Angular Component for the HyperLinkField Control.
*
* @export
* @class HyperlinkFieldComponent
* @extends {DataControlFieldComponent}
*/
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'wm-hyperlink-field',
templateUrl: './hyperlink-field.component.html',
styleUrls: ['./hyperlink-field.component.scss'],
providers: [
{ provide: DataControlFieldComponent, useExisting: HyperlinkFieldComponent }
],
inputs: ['model']
})
@dataTransfer(['hyprlnkfld'])
@ExceptionHandlerClass(ErrorCodes.Winforms)
export class HyperlinkFieldComponent extends DataControlFieldComponent {
/**
* NavigateToPage Extractor.
*
* @static
* @param {*} event
* @param {HyperlinkFieldComponent} component
* @return {*} {*}
* @memberof HyperlinkFieldComponent
*/
static NavigateToPageEventArgsExtractor(
event: any,
component: HyperlinkFieldComponent
): any {
return [
{
Id: event.Id,
MapperId: event.mapperId
},
{
RowIndex: event.args.rowIndex,
MapperId: 'NavigateToPageEventArgs'
}
];
}
/**
* Property to save the text value.
*
* @private
* @memberof HyperlinkFieldComponent
*/
private textInternal = '';
/**
* Property to save the dataTextField value.
*
* @private
* @memberof HyperlinkFieldComponent
*/
private dataTextFieldInternal = '';
/**
* Property to save the dataNavigateUrlFields array value.
*
* @private
* @type {string[]}
* @memberof HyperlinkFieldComponent
*/
private dataNavigateUrlFieldsInternal: string[] = [];
/**
* Property to save the dataNavigateUrlFormatString value.
*
* @private
* @memberof HyperlinkFieldComponent
*/
private dataNavigateUrlFormatStringInternal = '';
/**
* Emitter for the NavigateToPage event.
*
* @type {EventEmitter<EventData>}
* @memberof HyperlinkFieldComponent
*/
@Output()
NavigateToPage: EventEmitter<EventData> = new EventEmitter<EventData>();
/**
* Creates an instance of HyperlinkFieldComponent.
*
* @param {ChangeDetectorRef} refChange
* @param {Renderer2} render2
* @param {ElementRef} elem
* @param {WebComponentsService} webComponents
* @param {BringTopService} bringTopServ1
* @memberof HyperlinkFieldComponent
*/
constructor(
private refChange: ChangeDetectorRef,
private render2: Renderer2,
private elem: ElementRef,
webComponents: WebComponentsService,
@Optional() private bringTopServ1: BringTopService
) {
super(refChange, render2, elem, webComponents, bringTopServ1);
}
/**
* Gets/sets the text property
*
* @memberof HyperlinkFieldComponent
*/
@Input()
set text(value: string) {
this.textInternal = value;
}
get text(): string {
return this.model.Text ?? this.textInternal;
}
/**
* Gets/sets the dataTextField property.
*
* @memberof HyperlinkFieldComponent
*/
@Input()
set dataTextField(value: string) {
this.dataTextFieldInternal = value;
}
get dataTextField(): string {
return this.model.DataTextField ?? this.dataTextFieldInternal;
}
/**
* Sets the dataNavigateUrlFields property.
*
* @memberof HyperlinkFieldComponent
*/
@Input()
set dataNavigateUrlFields(value: string) {
const array: string[] = value.split(',');
this.dataNavigateUrlFieldsInternal = array.map((item) => item.trim());
}
/**
* Gets the dataNavigateUrlFields property value.
*
* @readonly
* @type {string[]}
* @memberof HyperlinkFieldComponent
*/
get dataNavigateUrlFieldsValue(): string[] {
return (
this.model.DataNavigateUrlFields ?? this.dataNavigateUrlFieldsInternal
);
}
/**
* Gets/sets the dataNavigateUrlFormatString property.
*
* @memberof HyperlinkFieldComponent
*/
@Input()
set dataNavigateUrlFormatString(value: string) {
this.dataNavigateUrlFormatStringInternal = value;
}
get dataNavigateUrlFormatString(): string {
return (
this.model.DataNavigateUrlFormatString ??
this.dataNavigateUrlFormatStringInternal
);
}
/**
* Returns the target page with the correct format/params.
*
* @param {*} dataItem
* @return {*} {string}
* @memberof HyperlinkFieldComponent
*/
getTarget(dataItem: any): string {
const StringFormat = (str: string, args: string[]) =>
str.replace(/{(\d+)}/g, (match, index) => args[index] || '');
const values: string[] = [];
for (const field of this.dataNavigateUrlFieldsValue) {
const itemValue: string = dataItem[field];
values.push(itemValue);
}
return StringFormat(this.dataNavigateUrlFormatString, values);
}
/**
* Returns the parameters in the target URL.
*
* @param {string} target
* @return {*} {*}
* @memberof HyperlinkFieldComponent
*/
getTargetParams(target: string): any {
const params = new URLSearchParams(
target.substring(target.indexOf('?') + 1)
);
const result: any = {};
params.forEach((value, key) => {
result[key] = value;
});
return result;
}
/**
* Handler for the HyperLinkField click.
*
* @param {*} dataItem
* @memberof HyperlinkFieldComponent
*/
clickHandler(dataItem: any, rowIndex: number) {
const eventData = new EventData('NavigateToPage', this.id);
eventData.mapperId = 'hprlnkfld';
eventData.args = { rowIndex: rowIndex };
this.triggerNavigateToPage(eventData);
}
/**
* Triggers the NavigateToPage event.
*
* @param {*} event
* @memberof HyperlinkFieldComponent
*/
@serverEvent(
'NavigateToPage',
HyperlinkFieldComponent.NavigateToPageEventArgsExtractor
)
triggerNavigateToPage(event: any): void {
this.NavigateToPage.emit(new EventData(event, this.id));
}
}
<div></div>
./hyperlink-field.component.scss