Helpers for Forms. Exported by @unitybase/adminui-vue as formHelpers and can be used as

  
      // valid usage
const formHelpers = require('@unitybase/adminui-vue').formHelpers
// WRONG usage
const helpers = require('@unitybase/adminui-vue/utils/Form/helpers')
  

Methods

# buildExecParams (trackedObjVuexTrackedObject, entitystring) → object | null inner

Build "execParams" out of the state tracked by "instance" module.

Arguments:

# change (stateVuexTrackedObject, keystring, value*, pathoptstring) inner

A helper method to update the "tracked" object property

Arguments:
  • state: VuexTrackedObject
  • key: string
  • value: *
  • path: string

    Path could be deep path. Using deep path is only allowed to change or set leaf values, it won't recursively create objects along the path.

# computedVuex (statePropsArray.<string>, submoduleNameoptstring) inner

Create an object with getter and setter for each of passed stateProp from vuex store state. Setter calls a SET mutation what should be implemented in store (imported from helpers for example).

Arguments:
  • stateProps: Array.<string>

    array of store state property names to create a getter/setter for

  • submoduleName: string

    optional submodule name of store state

# enrichFieldList (entitySchemaUBEntity, fieldListArray.<string>, requiredAttrsArray.<string>) → Array.<string> inner

Arguments:

# isDate (value*) → boolean inner

Check if value is a Date

Arguments:
  • value: *

# isEmpty (obj*) → Boolean inner

Check obj is empty (null or {})

Arguments:
  • obj: *

# isEqual (arg1*, arg2*) inner

Check arg1 is strict equal to srg2, can compare primitive values, arrays (deep equal) or Date's. In addition:

  • [] and undefined is equal
  • {} and undefined is equal

Arguments:
  • arg1: *
  • arg2: *

# isObject (value) inner

Check if value is an object and not null

Arguments:
  • value:

# mapInstanceFields (stateDataPropsArray.<string>, submoduleNameoptstring) inner

Create an object with getter and setter for each of passed stateDataProps from vuex store state.data[propName]

Setter perform a validation (if property is a subject for validation in $v - see UForm.validation) and calls SET_DATA store mutation.

Arguments:
  • stateDataProps: Array.<string>

    array of store state.data property names to create a getter/setter for

  • submoduleName: string

    optional submodule name of store state

# markAsTouched (stateVuexTrackedObject, keystring) inner

Mark field as touched (without changing value) If field is not in originalData - save current value to originalData

Arguments:

# mergeStore (targetwindow.Vuex.StoreOptions, sourcewindow.Vuex.StoreOptions) inner

Assign source store options into target store options

Arguments:

# prepareCopyAddNewExecParams (originalExecParamsobject, entitystring) → object inner

Return:

execParams

Arguments:

# replaceMultilangParams (execParamsobject) inner

If execParams includes locale params will replace the locale param with base param.

For example in case userLang === 'en' and execParams includes key 'name_uk^' will replace key 'name' to 'name_en^'

Arguments:

# required (param) inner

throw error on missing required prop of func

Arguments:
  • param:

# SET (stateVuexTrackedInstance, payloadobject) inner

This mutation is needed in order to reuse it in the store modules, since computedVuex will not work in the store module without such a mutation Set base state values

Arguments:

# showRecordHistory (entityNamestring, instanceIDnumber, fieldListarray.<string>, columnsoptarray.<object>) → Promise.<void> inner

Show Vue based form with changes history of specified instance (for entity with dataHistory mixin)

Arguments:

# showRecordHistoryExtForm (entityNamestring, instanceIDnumber, fieldListarray.<string>, columnsoptarray.<object>) → Promise.<void> inner

Show Ext-js based form with changes history of specified instance (for entity with dataHistory mixin)

Arguments:

# transformCollections (collectionsObject.<string, (UbVuexStoreCollectionInfo | UbVuexStoreRepositoryBuilder)>) → void inner

Transform's each collection object to key: { repository: store => UB.Repository(), lazy: true/false }

# validateWithErrorText (errorLocalestring, validatorfunction) → function inner

Assign some error text for validator function.

Arguments:

Types

# UbQueryParams inner

"execParams" and "fieldList"

Properties

# VuexTrackedCollection inner

Properties

  • entity string

    Entity code

  • key string

    Unique collection identifier

  • items Array.<VuexTrackedObject>

    Current items, as it shall be shown on UI

  • deleted Array.<VuexTrackedObject>

    Deleted items, except items which are added (not originally loaded)

  • key string

    Custom unique key which is set on init collection

  • entity string

    Entity code

# VuexTrackedInstance inner

Properties

  • isNew boolean

    Whether master instance was loaded or it is newly created

  • data object

    Master record instance, current values, as shall be shown on UI

  • originalData object

    Shadow copy of modified attributes

  • collections object.<string, VuexTrackedCollection>

    List of tracked detain collections

# VuexTrackedObject inner

Properties

  • isNew boolean

    Indicator of whether master instance was loaded or it is newly created

  • data object

    Master record instance, current values, as shall be shown on UI

  • originalData object

    Shadow copy of modified attributes