Class: DurationField

DurationField()

The Duration field is a mashup of an auto-complete box and a LookupField for handling duration's of: minutes, hours, days, weeks or years. Meaning a user can type directly into the input area the amount of time or press the lookup button and choose from pre-determined list of times. When typing in a value directly, the Duration field only supports one "measurement" meaning if you wanted to have 1 hour and 30 minutes you would need to type in 90 minutes or 1.5 hours. The auto-complete happens on blur, so if a user types in 5m they would need to go to the next field (or press Save) and the field will auto-complete to 5 minute(s), letting the user know it accepted the value. If a value entered is not accepted, 5abc, it will default to the last known measurement, defaulting to minutes. Setting and getting the value is always in minutes as a Number.

Constructor

new DurationField()

Source:
Requires:
  • module:argos.FieldManager
Example
{
        name: 'Duration',
        property: 'Duration',
        label: this.durationText,
        type: 'duration',
        view: 'durations_list'
    }

Extends

Requires

  • module:argos.FieldManager

Members

alwaysUseValue

Properties:
Name Type Description
Signifies Boolean that the field should always be included when the form calls getValues.
Inherited From:
Source:

applyTo

Properties:
Name Type Description
If String defined it will use the applyTo string when getting and setting properties from the SData object instead of the `property` property.
Inherited From:
Source:

attributeMap

Maps various attributes of nodes to setters.
Overrides:
Source:

autoCompletePhraseRE

Properties:
Name Type Description
Regular RegExp expression for capturing the phrase (text). The first capture group must be non-text part Second capture is the phrase to be used in auto complete
Source:

autoCompleteText

Properties:
Name Type Description
The Object auto completed text and their corresponding values in minutes (SData is always minutes) Override ride this object to change the autocomplete units or their localization.
Source:

autoCompleteValueRE

Properties:
Name Type Description
Regular RegExp expression for capturing the value. Only one capture which should correlate to the value portion
Source:

autoFocus

Properties:
Name Type Description
Flag Boolean to indicate if this field should be focused when the form is shown.
Inherited From:
Source:

completeText

Inherited From:
Deprecated:
  • Yes
Source:

containerNode

Properties:
Name Type Description
The HTMLElement parent container element of the field.
Inherited From:
Source:

currentSelection

Properties:
Name Type Description
The Object entire selected entry from the target view (not just the key/text properties).
Inherited From:
Source:

currentValue

Properties:
Name Type Description
The Number current value, expressed as minutes.
Overrides:
Source:

default

This applies a default value when inserting a new record, the default value is applied after the template entry but before the context and changes are applied. Note the word `default` must be in quotes as default is a reserved word in javascript.
Inherited From:
Source:

dependentErrorText

Properties:
Name Type Description
Error String text shown when validation fails. * `${0}` is the label text of the field
Inherited From:
Source:

dependsOn

Inherited From:
Source:

disabled

Properties:
Name Type Description
Indicates Boolean the disabled state
Inherited From:
Source:

emptyText

Properties:
Name Type Description
Text String used when no value or null is set to the field
Overrides:
Source:

hidden

Properties:
Name Type Description
Indicates Boolean the visibility state
Inherited From:
Source:

invalidDurationErrorText

Properties:
Name Type Description
Text String displayed when an invalid input is detected
Source:

keyProperty

Properties:
Name Type Description
The String default `valueKeyProperty` if `valueKeyProperty` is not defined.
Inherited From:
Source:

label

Properties:
Name Type Description
The String text that will, by default, show to the left of a field.
Inherited From:
Source:

lookupLabelText

Properties:
Name Type Description
The String ARIA label text in the lookup button
Inherited From:
Source:

lookupText

Properties:
Name Type Description
The String text placed inside the lookup button
Inherited From:
Source:

name

Properties:
Name Type Description
The String unique (within the current form) name of the field
Inherited From:
Source:

orderBy

Inherited From:
Source:

owner

Properties:
Name Type Description
View View that controls the field.
Inherited From:
Source:

property

Properties:
Name Type Description
The String SData property that the field will be bound to.
Inherited From:
Source:

required :Boolean

required should be true if the field requires input. Defaults to false.
Type:
  • Boolean
Inherited From:
Source:

requireSelection

Inherited From:
Source:

resourceKind

Inherited From:
Source:

resourcePredicate

Inherited From:
Source:

singleSelect

Properties:
Name Type Description
Sets Boolean the singleSelect navigation option and if true limits gather the value from the target list view to the first selection.
Inherited From:
Source:

singleSelectAction

Properties:
Name Type Description
The String data-action of the toolbar item (which will be hidden) sent in navigation options. This with `singleSelect` is listened to in List so clicking a row invokes the action, which is the function name defined (on the field instance in this case).
Inherited From:
Source:

textProperty

Properties:
Name Type Description
The String default `valueTextProperty` if `valueTextProperty` is not defined.
Inherited From:
Source:

textRenderer

Inherited From:
Source:

textTemplate

Inherited From:
Source:

type

Properties:
Name Type Description
The String registered name of the field that gets mapped in FieldManager when the field is constructed
Inherited From:
Source:

valueKeyProperty

Properties:
Name Type Description
Overrides Boolean the LookupField default to explicitly set it to false forcing the view to use the currentValue instead of a key/descriptor
Overrides:
Source:

valueTextProperty

Properties:
Name Type Description
Overrides Boolean the LookupField default to explicitly set it to false forcing the view to use the currentValue instead of a key/descriptor
Overrides:
Source:

view

Inherited From:
Source:

viewMixin

Inherited From:
Source:

where

Inherited From:
Source:

widgetTemplate

Properties:
Name Type Description
Simplate Simplate that defines the fields HTML Markup * `$` => Field instance * `$$` => Owner View instance
Overrides:
Source:

Methods

_onClick(evt)

Handler for the click event, fires navigateToListView if the field is not disabled.
Parameters:
Name Type Description
evt
Inherited From:
Source:

_onComplete()

Forces onChange to fire
Inherited From:
Source:

clearValue(flag)

Clears the value by setting null (which triggers usage of `this.emptyText`. Flag is used to indicate if to set null as the initial value (unmodified) or not.
Parameters:
Name Type Description
flag Boolean
Inherited From:
Source:

complete()

Called from the target list view when a row is selected. The intent of the complete function is to gather the value(s) from the list view and transfer them to the field - then handle navigating back to the Edit view. The target view must be the currently active view and must have a selection model. The values are gathered and passed to setSelection, `ReUI.back()` is fired and lastly _onComplete is called in a setTimeout due to bizarre transition issues, namely in IE.
Inherited From:
Source:

convertUnit(val, to) → {Number}

Divides two numbers and fixes the decimal point to two places.
Parameters:
Name Type Description
val Number
to Number
Source:
Returns:
Type
Number

createNavigationOptions() → {Object}

Extends the parent implementation to explicitly set hide search to true and data to `this.data`.
Overrides:
Source:
Returns:
Navigation options object to be passed
Type
Object

disable()

Extends disable to also set the disabled attribute
Inherited From:
Source:

enable()

Extends enable to also remove the disabled attribute
Inherited From:
Source:

expandExpression(expression) → {String}

Expands the passed expression if it is a function.
Parameters:
Name Type Description
expression String/Function Returns string directly, if function it is called and the result returned.
Inherited From:
Source:
Returns:
String expression.
Type
String

focus()

Focuses the input for the field
Inherited From:
Source:

formatUnit(unit) → {string}

Formats the unit with correct decimal separator.
Parameters:
Name Type Description
unit Number
Source:
Returns:
Type
string

formatValue(values) → {Object/String}

If using a multi-select enabled lookup then the view will return multiple objects as the value. This function takes that array and returns the single value that should be used for `this.currentValue`.
Parameters:
Name Type Description
values Array.<Object>
Inherited From:
Source:
Returns:
Type
Object/String

getDependentLabel() → {String}

Retrieves the label string of the field named with `this.dependsOn`
Inherited From:
Source:
Returns:
Type
String

getDependentValue() → {String/Object/Number/Boolean}

Retrieves the value of the field named with `this.dependsOn`
Inherited From:
Source:
Returns:
Type
String/Object/Number/Boolean

getMultiplier() → {Number}

Returns the corresponding value in minutes to the passed key (currentKey)
Source:
Returns:
Type
Number

getSelection() → {Object}

Returns the current selection that was set from the target list view.
Inherited From:
Source:
Returns:
Type
Object

getText() → {String}

Returns the string text of the field (note, not the value of the field)
Inherited From:
Source:
Returns:
Type
String

getValue() → {Number}

Returns the current value in minutes
Overrides:
Source:
Returns:
Type
Number

hide()

Sets hidden to true and fires onHide.
Inherited From:
Source:

hideAutoComplete()

Clears the autocomplete input
Source:

init()

Overrides the parent to skip the connections and alter the base capture RegExp's to account for localization
Overrides:
Source:

isDirty() → {Boolean}

Determines if the field has been altered from the default/template value.
Inherited From:
Source:
Returns:
Type
Boolean

isDisabled() → {Boolean}

Returns the disabled state
Inherited From:
Source:
Returns:
Type
Boolean

isHidden() → {Boolean}

Returns the hidden state
Inherited From:
Source:
Returns:
Type
Boolean

isReadOnly() → {Boolean}

Determines if the field is readonly by checking for a target view
Inherited From:
Source:
Returns:
Type
Boolean

isWordMatch(val, word) → {Boolean}

Determines if the two provided values are the same word, ignoring capitalization and length: * h, hour(s) = true * hou, hour(s) = true * minn, minute(s) = false * year, year(s) = true
Parameters:
Name Type Description
val String First string to compare
word String Second string to compare
Source:
Returns:
True if they are equal.
Type
Boolean
Navigates to the `this.view` id passing the options created from createNavigationOptions.
Inherited From:
Source:

onChange(field)

Event that fires when the field is changed
Parameters:
Name Type Description
field _Field The field itself
Inherited From:
Source:

onDisable(field)

Event that fires when the field is disabled
Parameters:
Name Type Description
field _Field The field itself
Inherited From:
Source:

onEnable(field)

Event that fires when the field is enabled
Parameters:
Name Type Description
field _Field The field itself
Inherited From:
Source:

onHide(field)

Event that fires when the field is hidden
Parameters:
Name Type Description
field _Field The field itself
Inherited From:
Source:

onNotificationTrigger(evt)

Called from onkeyup and onblur handlers if the trigger is set. Checks the current value against `this.previousValue` and if different fires onChange.
Parameters:
Name Type Description
evt Event
Inherited From:
Source:

onShow(field)

Event that fires when the field is shown
Parameters:
Name Type Description
field _Field The field itself
Inherited From:
Source:

renderTo(node)

Inserts the field into the given DOM node using dijit Widget `placeAt(node)` and saves a reference to it to `this.containerNode`.
Parameters:
Name Type Description
node HTMLElement Target node to insert the field into
Inherited From:
Source:

setSelection(val, key)

If used as a Lookup, this is invoked with the value of the lookup item.
Parameters:
Name Type Description
val
key String/Number Number of minutes (will be converted via parseFloat)
Overrides:
Source:

setSelections(values, unloadedValues)

If using a multi-select enabled lookup this function will be called by complete in that the target view returned multiple entries. Sets the currentValue using formatValue. Sets the displayed text using `this.textRenderer`.
Parameters:
Name Type Description
values Array.<Object>
unloadedValues Array.<Object> option.previousSelections that were not loaded by the view.
Inherited From:
Source:

setText(text)

Sets the displayed text of the field
Parameters:
Name Type Description
text String
Inherited From:
Source:

setValue(val, init)

Sets the currentValue to the passed value, but sets the displayed value after formatting with textFormat.
Parameters:
Name Type Description
val Number Number of minutes
init
Overrides:
Source:

show()

Sets hidden to false and fires onShow.
Inherited From:
Source:

showAutoComplete(word)

Shows the auto-complete version of the phrase
Parameters:
Name Type Description
word String Text to put in the autocomplete
Source:

textFormat(val) → {String}

Takes the number of minutes and converts it into a textual representation using the `autoCompleteText` collection as aguide
Parameters:
Name Type Description
val Number Number of minutes
Source:
Returns:
Type
String

validate() → {Boolean}

Validets the field by verifying it matches one of the auto complete text.
Overrides:
Source:
Returns:
False for no-errors, true for error.
Type
Boolean