Module: alfresco/forms/controls/NumberSpinner

alfresco/forms/controls/NumberSpinner

This control is for the entry of numbers, while additionally allowing "spinning" to adjust the number value (by scrolling or spinner-buttons).

Author:
  • Dave Draper
License:
Source:

Examples

Minimum configuration

{
   name: "alfresco/forms/controls/NumberSpinner", 
   config: {
      name: "one"
   }
}

Full configuration

{
   name: "alfresco/forms/controls/NumberSpinner", 
   config: {
      name: "two",
      value: 3,
      min: 5,
      max: 10,
      requirementConfig: {
         initialValue: true
      },
      permitEmpty: true,
      permittedDecimalPlaces: 1
   }
},

Members

cssRequirements :object[]

An array of the CSS files to use with this widget.
Type:
  • object[]
Default Value:
  • [{cssFile:"./css/NumberSpinner.css"}]
Source:

delta :number

This is the amount the value will be changed when using the "spin" controls
Type:
  • number
Default Value:
  • 1
Source:

max :number

This is the maximum allowed number
Type:
  • number
Default Value:
  • null
Source:

min :number

This is the minimum allowed number
Type:
  • number
Default Value:
  • null
Source:

permitEmpty :boolean

By default, this control can only be valid when it contains a numerical value. If this configuration property is set to true, then it will be possible to submit a form without any value in this control, at which point its value will be submitted as null.
Type:
  • boolean
Default Value:
  • false
Source:

<inner> permittedDecimalPlaces :number

How many decimal places are permitted in a valid value for this control
Type:
  • number
Default Value:
  • 0
Source:

Methods

_getValueAttr() → {number}

Override the standard value-getter to always return a number if one is provided.
Source:
Returns:
The value, as a number, or null if NaN
Type
number

_removeCommasAndSpaces(value) → {string}

Remove commas and spaces from a string value, ready for number parsing

NOTE: See AKU-341 for details of why we handle commas and spaces
Parameters:
Name Type Description
value string The value to parse
Deprecated:
  • Since 1.0.54 - No longer required - extending modules should prepare for the removal of this function
    Source:
    Returns:
    The cleaned value
    Type
    string

    _setValueAttr(newValue)

    Override the standard value-setter to correctly locale-format the content
    Parameters:
    Name Type Description
    newValue number The new value to set
    Source:

    _valueIsNumber(value) → {boolean}

    Determine whether the supplied value string is a number.
    Parameters:
    Name Type Description
    value string The value to check (should already be trimmed)
    Deprecated:
    • Since 1.0.54 - No longer required - extending modules should prepare for the removal of this function
      Source:
      Returns:
      true if the value is a number
      Type
      boolean

      configureValidation()

      This function is used to set or update the validationConfig as required based on the min and [max]module:alfresco/forms/controls/NumberSpinner#max configuration.
      Source:

      createFormControl()

      Creates a new instance of a dijit/form/NumberSpinner as the wrapped form control.
      Source:

      decimalPlacesValidator(validationConfig)

      This validator checks that the value has no more than the specified number of decimal places (or isn't a number!)
      Parameters:
      Name Type Description
      validationConfig object The configuration for this validator
      Source:

      format(value, constraints) → {string}

      Override the standard format method to avoid rounding decimals.
      Parameters:
      Name Type Argument Description
      value number The number to format
      constraints object <optional>
      The constraints
      Source:
      Returns:
      The formatted number
      Type
      string

      getWidgetConfig()

      Returns the configuration for the widget ensuring that it is valid, in that min and [max]{@link module:alfresco/forms/controls/NumberSpinner#max} but both be numerical values and that min cannot be greater than [max]{@link module:alfresco/forms/controls/NumberSpinner#max}.
      Source:

      isNumberValidator(validationConfig)

      This validator checks that the value provided is a number
      Parameters:
      Name Type Description
      validationConfig object The configuration for this validator
      Source:

      setValue(value)

      Extends the inherited function to ensure that only valid values can be set. Values must be numbers and must not be less than the minimum allowed value nor greater than the maximum allowed value.
      Parameters:
      Name Type Description
      value object The value to set.
      Source: