Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DateRangeControl

A Control that obtains a date range from the user.

Capabilities:

  • Request a range, or just the start/end date
  • Change the range, or just the start/end date
  • Validate the range or just the start/end date
  • Confirm the range or just the start/end date
  • Infer specific date(s) for a partially specified date(s).

Intents that can be handled:

  • GeneralControlIntent: E.g. "yes, update my birth date"
  • ConjunctionControlIntent: E.g. "yes, change the start and end dates"
  • DateRangeControlIntent: E.g. "no Tuesday to Saturday".
  • AMAZON_DATE_ValueControlIntent: E.g. "no change it to Tuesday".
  • AMAZON.YesIntent, AMAZON.NoIntent

Hierarchy

Implements

Constructors

constructor

Properties

children

children: DateControl[]

Readonly id

id: string

props

rawProps

selectedHandlingChild

selectedHandlingChild: Control | undefined

selectedInitiativeChild

selectedInitiativeChild: Control | undefined

state

Methods

addChild

  • Add a control as a child.

    The control is appended to the end of the this.children array.

    Parameters

    Returns this

    the container

canHandle

canHandleByChild

  • Determines if a child control can handle the request.

    From the candidates that report canHandle = true, a winner is selected by this.decideHandlingChild(candidates).

    The selected "winner" is recorded in this.selectedHandlingChild.

    Parameters

    Returns Promise<boolean>

canTakeInitiative

canTakeInitiativeByChild

  • canTakeInitiativeByChild(input: ControlInput): Promise<boolean>

decideHandlingChild

  • Decides a winner from the canHandle candidates.

    The candidates should be all the child controls for which canHandle(input) = true

    Default logic:

    1. Choose the most-recent initiative control if is a candidate.
    2. Otherwise, choose the first candidate in the positional order of the this.children array.
    3. In the special case of input===FallbackIntent, only the most-recent initiative control is considered. If it is not a candidate, then no child is selected and this method returns undefined.

    Remarks:

    • The special case for FallbackIntent exists because that intent is not user-initiative -- rather it indicates a failure to understanding the user. In cases of misunderstanding, only active controls should be considered.

    Parameters

    • candidates: Control[]

      The child controls that reported canHandle = true

    • input: ControlInput

      Input

    Returns Promise<Control | undefined>

decideInitiativeChild

  • Decide a winner from the canTakeInitiative candidates.

    The eligible candidates are child controls for which canTakeInitiative(input) = true.

    Default logic:

    1. choose the most-recent initiative control if is a candidate.
    2. otherwise choose the first candidate in the positional order of the this.children array.

    Parameters

    • candidates: Control[]

      The child controls that reported canTakeInitiative = true

    • input: ControlInput

      Input

    Returns Promise<Control | undefined>

evaluateAPLProp

  • Evaluate an APL document/data source prop.

    Parameters

    • act: SystemAct

      act

    • input: ControlInput

      The input object

    • propValue: object | function

      Constant or function producing a map of key:value pairs

    Returns object

    • [key: string]: any

evaluateBooleanProp

  • evaluateBooleanProp(propValue: boolean | function, input: ControlInput): boolean
  • Evaluate a boolean prop.

    Parameters

    • propValue: boolean | function

      Constant or function producing boolean

    • input: ControlInput

      The input object

    Returns boolean

evaluateFunctionProp

  • evaluateFunctionProp<T>(prop: T | function, input: ControlInput): T

evaluatePromptProp

gatherHandlingCandidates

gatherInitiativeCandidates

getSerializableState

  • getSerializableState(): any
  • Gets the Control's state as an object that is serializable.

    Only durable state should be included and the object should be serializable with a straightforward application of JSON.stringify(object).

    Default: {return this.state;}

    Usage:

    • This method must be idempotent (multiple calls must not change the result).
    • The default is sufficient for Controls that use the .state variable and only store simple data.
      • Non-simple data includes functions, and objects with functions, as these will not survive the round trip.
      • Other non-simple data include types with non-enumerable properties.
    • It is safe to pass the actual state object as the framework guarantees to not mutate it.
    • Functions that operate on the Control's state should be defined as member function of the Control type, or as props.

    Framework behavior:

    • During the shutdown phase the state of the control tree is collected by calling this function for each control.
    • The framework serializes the data use a simple application of JSON.stringify.
    • On the subsequent turn the control tree is rebuilt and the state objects are re-attached to each Control via control.setSerializableState(serializedState).

    Returns any

    Serializable object defining the state of the Control

handle

handleByChild

isReady

  • Determines if the Control's value is ready for use by other parts of the skill.

    Note:

    • A basic invariant is isReady === !canTakeInitiative because isReady implies that no further discussion is required and thus there is no need to take the initiative.

    Parameters

    Returns Promise<boolean>

    true if the control has no further questions to ask the user such as elicitation, clarification or confirmation.

reestablishState

  • reestablishState(state: any, controlStateMap: object): void

renderAPLComponent

  • Add response APL component by this control.

    This is intended to be used to provide APL rendering component for a control to process inputs, provide feedback, elicitation etc through touch events on APL screens.

    Parameters

    Returns object

    • [key: string]: any

renderAct

setSerializableState

  • setSerializableState(serializedState: any): void
  • Sets the state from a serialized state object.

    Default: {this.state = serializedState;}

    Usage:

    • This method must be idempotent (multiple calls must not change the result).
    • It is safe to use serializedState without copying as the framework guarantees to not mutate it.

    Framework behavior:

    • During the initialization phase the control tree is rebuilt and state objects are re-attached to controls by calling this method for each control.

    Parameters

    • serializedState: any

      Serializable object defining the state of the Control

    Returns void

stringifyStateForDiagram

  • stringifyStateForDiagram(): string

takeInitiative

takeInitiativeByChild

throwUnhandledActError

  • throwUnhandledActError(act: SystemAct): never

updateInteractionModel

Static mergeWithDefaultProps