File

projects/wms-framework/src/lib/infra/CommandSource.ts

Description

Command source base class

Index

Properties
Methods
Accessors

Properties

EventName
Type : string
Default value : ''

Event name to trigger

Parameter
Type : unknown
Default value : null

The parameter

ParameterCreationFunc
Type : function
Default value : null

The parameter creation function

SourceElement
Type : FrameworkElement
Default value : null

Source element

Methods

Protected Abstract ResolveCommand
ResolveCommand()

Resolve the command

Returns : ICommand

{ICommand}

Accessors

ParameterResolved
getParameterResolved()

Parameter resolved

Returns : unknown
Command
getCommand()

Gets the commadn

Returns : ICommand
import { FrameworkElement } from '../basecomponentmodel/FrameworkElement';
import { ICommand } from '../baseframework/ICommand';

/**
 *  Command source base class
 *
 * @export
 * @class CommandSource
 * @wType Infragistics.Controls.CommandSource
 */
export abstract class CommandSource {
  /**
   *  Event name to trigger
   *
   * @memberof CommandSource
   */
  EventName = '';

  /**
   * Source element
   *
   * @type {FrameworkElement}
   * @memberof CommandSource
   */
  SourceElement: FrameworkElement = null;

  /**
   * The parameter
   *
   * @type {unknown}
   * @memberof CommandSource
   */
  Parameter: unknown = null;

  /**
   * The parameter creation function
   *
   * @type {unknown}
   * @memberof CommandSource
   * @wIgnore
   */
  ParameterCreationFunc: () => unknown = null;

  /**
   *  Parameter resolved
   *
   * @type {unknown}
   * @memberof CommandSource
   */
  get ParameterResolved(): unknown {
    if (this.ParameterCreationFunc) {
      return this.ParameterCreationFunc();
    } else {
      return this.Parameter;
    }
  }

  /**
   *  Gets the commadn
   *
   * @return {*}  {ICommand}
   * @memberof CommandSource
   */
  public get Command(): ICommand {
    const result = this.ResolveCommand();
    if ('CommandSource' in (result as any)) {
      (result as any).CommandSource = this;
    }
    return result;
  }

  /**
   *  Resolve the command
   *
   * @protected
   * @abstract
   * @return {*}  {ICommand}
   * @memberof CommandSource
   */
  protected abstract ResolveCommand(): ICommand;
}

result-matching ""

    No results matching ""