File

src/lib/components/hyperlink-field/hyperlink-field.component.ts

Description

Angular Component for the HyperLinkField Control.

Extends

DataControlFieldComponent

Metadata

Index

Properties
Methods
Inputs
Outputs
Accessors

Constructor

constructor(refChange: ChangeDetectorRef, render2: Renderer2, elem: ElementRef, webComponents: WebComponentsService, bringTopServ1: BringTopService)

Creates an instance of HyperlinkFieldComponent.

Parameters :
Name Type Optional
refChange ChangeDetectorRef No
render2 Renderer2 No
elem ElementRef No
webComponents WebComponentsService No
bringTopServ1 BringTopService No

Inputs

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

Gets/sets the headerText property.

sortExpression
Type : string

Gets/sets the sortExpression property.

visible
Type : boolean

Gets/sets the visible property.

Outputs

NavigateToPage
Type : EventEmitter<EventData>

Emitter for the NavigateToPage event.

Methods

clickHandler
clickHandler(dataItem: any, rowIndex: number)

Handler for the HyperLinkField click.

Parameters :
Name Type Optional
dataItem any No
rowIndex number No
Returns : void
getTarget
getTarget(dataItem: any)

Returns the target page with the correct format/params.

Parameters :
Name Type Optional
dataItem any No
Returns : string

{string}

getTargetParams
getTargetParams(target: string)

Returns the parameters in the target URL.

Parameters :
Name Type Optional
target string No
Returns : any

{*}

Static NavigateToPageEventArgsExtractor
NavigateToPageEventArgsExtractor(event: any, component: HyperlinkFieldComponent)

NavigateToPage Extractor.

Parameters :
Name Type Optional
event any No
component HyperlinkFieldComponent No
Returns : any

{*}

triggerNavigateToPage
triggerNavigateToPage(event: any)
Decorators :
@serverEvent('NavigateToPage', HyperlinkFieldComponent.NavigateToPageEventArgsExtractor)

Triggers the NavigateToPage event.

Parameters :
Name Type Optional
event any No
Returns : void
isBindedEvent
isBindedEvent(event: string)

Override the isBindedEvent to get the event from the Field model

Parameters :
Name Type Optional
event string No
Returns : boolean

{boolean}

Properties

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 : ''

Property to save the headerText value.

Private sortExpressionInternal
Type : string
Default value : ''

Property to save the sortExpression value.

Private visibleInternal
Default value : true

Property to save the visible value.

Accessors

text
gettext()
settext(value: string)

Gets/sets the text property

Parameters :
Name Type Optional
value string No
Returns : void
dataTextField
getdataTextField()
setdataTextField(value: string)

Gets/sets the dataTextField property.

Parameters :
Name Type Optional
value string No
Returns : void
dataNavigateUrlFields
setdataNavigateUrlFields(value: string)

Sets the dataNavigateUrlFields property.

Parameters :
Name Type Optional
value string No
Returns : void
dataNavigateUrlFieldsValue
getdataNavigateUrlFieldsValue()

Gets the dataNavigateUrlFields property value.

Returns : string[]
dataNavigateUrlFormatString
getdataNavigateUrlFormatString()
setdataNavigateUrlFormatString(value: string)

Gets/sets the dataNavigateUrlFormatString property.

Parameters :
Name Type Optional
value string No
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

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""