Class: module:argos/_EditBase

module:argos/_EditBase(options)

An Edit View is a dual purpose view - used for both Creating and Updating records. It is comprised of a layout similar to Detail rows but are instead Edit fields.

A unique part of the Edit view is it's lifecycle in comparison to Detail. The Detail view is torn down and rebuilt with every record. With Edit the form is emptied (HTML left in-tact) and new values are applied to the fields.

Since Edit Views are typically the "last" view (you always come from a List or Detail view) it warrants special attention to the navigation options that are passed, as they greatly control how the Edit view functions and operates.

Constructor

new module:argos/_EditBase(options)

Extends:
Parameters:
Name Type Description
options Object
Source:

Extends

Members

(static) attributeMap

Properties:
Name Type Description
Creates Object

a setter map to html nodes, namely:

  • validationContent => validationContentNode's innerHTML
Source:

(static) cancelTooltipText

Properties:
Name Type Description
Text String

shown in the top toolbar cancel button

Source:

(static) concurrencyErrorText

Properties:
Name Type Description
Text String

alerted to user when the data has been updated since they last fetched the data.

Source:

(static) concurrencySummaryItemTemplate

Properties:
Name Type Description
* Simplate

$ => validation error object

Source:

(static) concurrencySummaryTemplate

Properties:
Name Type Description
HTML Simplate

for the concurrency error area, this div is shown/hidden as needed.

$ => the view instance

Source:

(static) concurrencySummaryText

Source:

(static) customizationSet

Properties:
Name Type Description
The String

customization identifier for this class. When a customization is registered it is passed a path/identifier which is then matched to this property.

Source:

(static) detailsText

Properties:
Name Type Description
Default String

text used in the section header

Source:

(static) diffPropertyIgnores

Array of strings that will get ignored when the diffing runs.

Source:

(static) enableCustomizations

Source:

(static) entry

Properties:
Name Type Description
The Object

saved data response.

Source:

(static) errorText

Properties:
Name Type Description
Localized Object

error messages. One general error message, and messages by HTTP status code.

Source:

(static) expose

Source:

(static) fields

Properties:
Name Type Description
Collection Object

of the fields in the layout where the key is the name of the field.

Source:

(static) id

Source:

(static) inserting

Properties:
Name Type Description
Flags Boolean

if the view is in "insert" (create) mode, or if it is in "update" (edit) mode.

Source:

(static) insertSecurity

Source:

(static) layout

Properties:
Name Type Description
The Object

layout definition that constructs the detail view with sections and rows

Source:

(static) loadingTemplate

Properties:
Name Type Description
HTML Simplate

shown when data is being loaded.

$ => the view instance

Source:

(static) loadingText

Properties:
Name Type Description
Text String

shown while the view is loading.

Source:

(static) multiColumnClass

Properties:
Name Type Description
SoHo string

class to be applied on multi column.

Source:

(static) multiColumnCount

Properties:
Name Type Description
Number number

of columns in view

Source:

(static) multiColumnView

Properties:
Name Type Description
Flags Boolean

if the view is multi column or single column.

Source:

(static) propertyTemplate

Properties:
Name Type Description
HTML Simplate

created for each property (field row).

  • $ => the field row object defined in createLayout.
  • $$ => the view instance
Source:

(static) saveText

Deprecated:
  • Yes
Source:

(static) saveTooltipText

Properties:
Name Type Description
Text String

shown in the top toolbar save button

Source:

(static) sectionBeginTemplate

Properties:
Name Type Description
HTML Simplate

that starts a new section including the collapsible header

$ => the view instance

Source:

(static) sectionEndTemplate

Properties:
Name Type Description
HTML Simplate

that ends a section

$ => the view instance

Source:

(static) titleText

Source:

(static) toggleCollapseText

Properties:
Name Type Description
ARIA String

label text for a collapsible section header

Source:

(static) updateSecurity

Source:

(static) validationSummaryItemTemplate

Properties:
Name Type Description
HTML Simplate

shown when data is being loaded.

  • $ => validation error object
  • $$ => field instance that the error is on
Source:

(static) validationSummaryTemplate

Properties:
Name Type Description
HTML Simplate

for the validation summary area, this div is shown/hidden as needed.

$ => the view instance

Source:

(static) validationSummaryText

Source:

(static) widgetTemplate

Properties:
Name Type Description
The Simplate

template used to render the view's main DOM element when the view is initialized. This template includes loadingTemplate and validationSummaryTemplate.

The default template uses the following properties:

 name                description
 ----------------------------------------------------------------
 id                   main container div id
 title                main container div title attr
 cls                  additional class string added to the main container div
 resourceKind         set to data-resource-kind
Source:

app

A reference to the global App object

Inherited From:
Source:

errorHandlers

Properties:
Name Type Description
errorHandlers Array

Array of objects that should contain a name string property, test function, and handle function.

Inherited From:
Source:

id

The id is used to uniquely define a view and is used in navigating, history and for HTML markup.

Properties:
Type Description
String
Inherited From:
Source:

modelName

Registered model name to use.

Inherited From:
Source:

route

Properties:
Name Type Description
Route String

passed into the router. RegEx expressions are also accepted.

Inherited From:
Source:

security

May be defined along with Application hasAccessTo to incorporate View restrictions.

Inherited From:
Source:

serviceName

May be used to specify the service name to use for data requests. Setting false will force the use of the default service.

Properties:
Type Description
String/Boolean
Inherited From:
Source:

titleText

The titleText string will be applied to the top toolbar during show.

Inherited From:
Source:

tools

This views toolbar layout that defines all toolbar items in all toolbars.

Properties:
Type Description
Object
Inherited From:
Source:

viewType

View type (detail, edit, list, etc)

Inherited From:
Source:

Methods

(static) _onDisableField(field)

Handler for a fields on disable event.

Adds the row-disabled css class.

Parameters:
Name Type Description
field _Field

Field instance that is being disabled

Source:

(static) _onEnableField(field)

Handler for a fields on enable event.

Removes the row-disabled css class.

Parameters:
Name Type Description
field _Field

Field instance that is being enabled

Source:

(static) _onHideField(field)

Handler for a fields on hide event.

Adds the row-hidden css class.

Parameters:
Name Type Description
field _Field

Field instance that is being hidden

Source:

(static) _onShowField(field)

Handler for a fields on show event.

Removes the row-hidden css class.

Parameters:
Name Type Description
field _Field

Field instance that is being shown

Source:

(static) activate()

Empties the activate method which prevents detection of refresh from transititioning.

External navigation (browser back/forward) never refreshes the edit view as it's always a terminal loop. i.e. you never move "forward" from an edit view; you navigate to child editors, from which you always return.

Source:

(static) applyFieldDefaults()

Loops all the fields looking for any with the default property set, if set apply that value as the initial value of the field. If the value is a function, its expanded then applied.

Source:

(static) beforeTransitionTo()

Extends beforeTransitionTo to add the loading styling if refresh is needed

Source:

(static) clearValues()

Loops all fields and calls its clearValue().

Source:

(static) convertEntry(entry) → {Object}

Pre-processes the entry before processEntry runs.

Parameters:
Name Type Description
entry Object

data

Source:
Returns:

entry with actual Date objects

Type
Object

(static) convertValues()

Function to call to tranform values before save

Source:

(static) createEntryForInsert(values) → {Object}

Takes the values object and adds the needed propertiers for creating/inserting.

Parameters:
Name Type Description
values Object
Source:
Returns:

Object with properties for inserting

Type
Object

(static) createEntryForUpdate(values) → {Object}

Takes the values object and adds the needed propertiers for updating.

Parameters:
Name Type Description
values Object
Source:
Returns:

Object with properties for updating

Type
Object

(static) createItem() → {Object}

Gathers the values for the entry to send back and returns the appropriate payload for creating or updating.

Source:
Returns:

Entry/payload

Type
Object

(static) createLayout() → {Array.<Object>}

Sets and returns the Edit view layout by following a standard for section and field:

The this.layout itself is an array of section objects where a section object is defined as such:

{
   name: 'String', // Required. unique name for identification/customization purposes
   title: 'String', // Required. Text shown in the section header
   children: [], // Array of child row objects
}

A child row object has:

{
   name: 'String', // Required. unique name for identification/customization purposes
   property: 'String', // Optional. The property of the current entity to bind to
   label: 'String', // Optional. Text shown in the label to the left of the property
   type: 'String', // Required. The field type as registered with the FieldManager.
   // Examples of type: 'text', 'decimal', 'date', 'lookup', 'select', 'duration'
   'default': value // Optional. If defined the value will be set as the default "unmodified" value (not dirty).
}

All further properties are set by their respective type, please see the individual field for its configurable options.

Source:
Returns:

Edit layout definition

Type
Array.<Object>

(static) createToolLayout() → {Object}

Sets and returns the toolbar item layout definition, this method should be overriden in the view so that you may define the views toolbar items.

By default it adds a save button bound to this.save() and cancel that fires ReUI.back()

Source:
Returns:

this.tools

Type
Object

(static) diffs()

Diffs the results from the current values and the previous values. This is done for a concurrency check to indicate what has changed.

Source:
Returns:

Array List of property names that have changed

(static) disable()

Disables the form by setting busy to true and disabling the toolbar.

Source:

(static) enable()

Enables the form by setting busy to false and enabling the toolbar

Source:

(static) getContext()

Extends the getContext function to also include the resourceKind of the view, insert state and key of the entry (false if inserting)

Source:

(static) getSecurity(access)

Wrapper for detecting security for update mode or insert mode

Parameters:
Name Type Description
access String

Can be either "update" or "insert"

Source:

(static) getTag() → {String}

Returns the view key

Source:
Returns:

View key

Type
String

(static) getValues(all) → {Object}

Retrieves the value from every field, skipping the ones excluded, and merges them into a single payload with the key being the fields property attribute, taking into consideration applyTo if defined.

If all is passed as true, it also grabs hidden and unmodified (clean) values.

Parameters:
Name Type Description
all Boolean

True to also include hidden and unmodified values.

Source:
Returns:

A single object payload with all the values.

Type
Object

(static) hasAction(name, evt, node) → {Boolean}

Determines if a field has defined on it the supplied name as a function

Parameters:
Name Type Description
name String

Name of the function to test for

evt Event

The original click/tap event

node HTMLElement

The node that initiated the event

Source:
Returns:

If the field has the named function defined

Type
Boolean

(static) hideConcurrencySummary()

Removes teh summary for concurrency errors

Source:

(static) hideValidationSummary()

Removes the summary validation visible styling and empties its contents of error markup

Source:

(static) init()

Extends init to also init the fields in this.fields.

Source:

(static) insert()

Called by save() when performing an insert (create). Gathers the values, creates the payload for insert, creates the sdata request and calls create.

Source:

(static) invokeAction(name, parameters, evt, node) → {function}

Extends invokeAction to first look for the specified function name on the field instance first before passing it to the view.

Parameters:
Name Type Description
name String

Name of the function to invoke

parameters Object

Parameters of the function to be passed

evt Event

The original click/tap event

node HTMLElement

The node that initiated the event

Source:
Returns:

Either calls the fields action or returns the inherited version which looks at the view for the action

Type
function

(static) isFormDisabled() → {Boolean}

Determines if the form is currently busy/disabled

Source:
Returns:
Type
Boolean

(static) onInsertCompleted(entry)

Handler for insert complete, checks for this.options.returnTo else it simply goes back.

Parameters:
Name Type Description
entry
Source:

(static) onUpdateCompleted(entry)

Handler for update complete, checks for this.options.returnTo else it simply goes back.

Parameters:
Name Type Description
entry
Source:

(static) refresh()

Refresh first clears out any variables set to previous data.

The mode of the Edit view is set and determined via this.options.insert, and the views values are cleared.

Lastly it makes the appropiate data request:

Source:

(static) refreshRequiredFor(options)

Extends refreshRequiredFor to return false if we already have the key the options is passing

Parameters:
Name Type Description
options Object

Navigation options from previous view

Source:

(static) requestData()

Initiates the request.

Source:

(static) save()

Handler for the save toolbar action.

First validates the forms, showing errors and stoping saving if found. Then calls either insert or update based upon this.inserting.

Source:

(static) setValues(values, initial)

Sets the given values by looping the fields and checking if the field property matches a key in the passed values object (after considering a fields applyTo).

The value set is then passed the initial state, true for default/unmodified/clean and false for dirty or altered.

Parameters:
Name Type Description
values Object

data entry, or collection of key/values where key matches a fields property attribute

initial Boolean

Initial state of the value, true for clean, false for dirty

Source:

(static) showValidationSummary()

Creates the markup by applying the validationSummaryItemTemplate to each entry in this.errors then sets the combined result into the summary validation node and sets the styling to visible

Source:

(static) startup()

When the app is started this fires, the Edit view renders its layout immediately, then renders each field instance.

On refresh it will clear the values, but leave the layout intact.

Source:

(static) update()

Called by save() when performing an update (edit). Gathers the values, creates the payload for update, creates the sdata request and calls update.

Source:

(static) validate() → {Array.<Boolean/Object>}

Loops and gathers the validation errors returned from each field and adds them to the validation summary area. If no errors, removes the validation summary.

Source:
Returns:

Returns the array of errors if present or false for no errors.

Type
Array.<Boolean/Object>

beforeTransitionAway()

Called before the view is transitioned (slide animation complete) away from.

Inherited From:
Source:

beforeTransitionTo()

Called before the view is transitioned (slide animation complete) to.

Inherited From:
Source:

buildRoute() → {String}

Show method calls this to build a route that it can navigate to. If you add a custom route, this should change to build a route that can match that.

Inherited From:
Source:
Returns:
Type
String

createErrorHandlers() → {Array}

Inherited From:
Source:
Returns:

Returns an array of error handlers

Type
Array

createToolLayout() → {Object}

Returns the tool layout that defines all toolbar items for the view

Inherited From:
Source:
Returns:

The toolbar layout

Type
Object

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

getContext() → {Object}

Returns the context of the view which is a small summary of key properties.

Inherited From:
Source:
Returns:

Vital View properties.

Type
Object

getErrorMessage()

Gets the general error message, or the error message for the status code.

Inherited From:
Source:

getModel()

Returns a new instance of a model for the view.

Inherited From:
Source:

getOptionsContext() → {Object}

Returns the options used for the View getContext().

Inherited From:
Source:
Returns:

Options to be used for context.

Type
Object

getRoute()

Gets the route associated with this view. Returns this.id if no route is defined.

Inherited From:
Source:

getSecurity(access)

Returns the defined security.

Parameters:
Name Type Description
access
Inherited From:
Source:

getService() → {Object}

Returns the primary SDataService instance for the view.

Inherited From:
Source:
Returns:

The Sage.SData.Client.SDataService instance.

Type
Object

getTools() → {Object}

Called from Applications view transition handler and returns the fully customized toolbar layout.

Inherited From:
Source:
Returns:

The toolbar layout

Type
Object

handleError(error)

Starts matching and executing errorHandlers.

Parameters:
Name Type Description
error Error

Error to pass to the errorHandlers

Inherited From:
Source:

init()

Called on loading of the application.

Inherited From:
Source:

initConnects()

Establishes this views connections to various events

Inherited From:
Source:

initModel()

Initializes the model instance that is returned with the current view.

Inherited From:
Source:

isDisabled() → {Boolean}

Returns true if view is disabled.

Inherited From:
Source:
Returns:

.

Type
Boolean

load()

Called once the first time the view is about to be transitioned to.

Inherited From:
Deprecated:
  • Yes
Source:

onActivate(self)

The onActivate event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onBeforeTransitionAway(self)

The onBeforeTransitionAway event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onBeforeTransitionTo(self)

The onBeforeTransitionTo event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onShow(self)

The onShow event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onToolLayoutCreated()

Called after toolBar layout is created;

Inherited From:
Source:

onTransitionAway(self)

The onTransitionAway event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onTransitionTo(self)

The onTransitionTo event.

Parameters:
Name Type Description
self
Inherited From:
Source:

open()

Available Options: horizontal: True if the transition is horizontal, False otherwise. reverse: True if the transition is a reverse transition (right/down), False otherwise. track: False if the transition should not be tracked in history, True otherwise. update: False if the transition should not update title and back button, True otherwise. scroll: False if the transition should not scroll to the top, True otherwise.

Inherited From:
Source:

refresh()

Should refresh the view, such as but not limited to: Emptying nodes, requesting data, rendering new content

Inherited From:
Source:

refreshRequiredFor(options) → {Boolean}

Called in show() before route is invoked.

Parameters:
Name Type Description
options Object

Navigation options passed from the previous view.

Inherited From:
Source:
Returns:

True indicates view needs to be refreshed.

Type
Boolean

routeLoad(ctx, next)

Fires first when a route is triggered. Any pre-loading should happen here.

Parameters:
Name Type Description
ctx Object
next function
Inherited From:
Source:

routeShow(ctx, next)

Fires second when a route is triggered. Any pre-loading should happen here.

Parameters:
Name Type Description
ctx Object
next function
Inherited From:
Source:

show(options, transitionOptions)

Shows the view using pagejs in order to transition to the new element.

Parameters:
Name Type Description
options Object

The navigation options passed from the previous view.

transitionOptions Object

Optional transition object that is forwarded to open.

Inherited From:
Source:

transitionAway()

Called after the view has been transitioned (slide animation complete) away from.

Inherited From:
Source:

transitionTo()

Called after the view has been transitioned (slide animation complete) to.

Inherited From:
Source: