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 (trackedObj:  VuexTrackedObject, entity:  string) → object | null inner

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

Arguments:

# change (state:  VuexTrackedObject, key:  string, value:  *, pathopt:  string) 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 (stateProps:  Array.<string>, submoduleNameopt:  string) 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 (entitySchema:  UBEntity, fieldList:  Array.<string>, requiredAttrs:  Array.<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 (stateDataProps:  Array.<string>, submoduleNameopt:  string) 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 (state:  VuexTrackedObject, key:  string) inner

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

Arguments:

# mergeStore (target:  Vuex.StoreOptions, source:  Vuex.StoreOptions) inner

Assign source store options into target store options

Arguments:
  • target: Vuex.StoreOptions

    Target store

  • source: Vuex.StoreOptions

    Source store

# prepareCopyAddNewExecParams (originalExecParams:  object, entity:  string) → object inner

Return:

execParams

Arguments:

# replaceMultilangParams (execParams:  object) 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 (state:  VuexTrackedInstance, payload:  object) 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 (entityName:  string, instanceID:  number, fieldList:  array.<string>, columnsopt:  array.<object>) → Promise.<void> inner

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

Arguments:

# showRecordHistoryExtForm (entityName:  string, instanceID:  number, fieldList:  array.<string>, columnsopt:  array.<object>) → Promise.<void> inner

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

Arguments:

# transformCollections (collections:  Object.<string, (UbVuexStoreCollectionInfo | UbVuexStoreRepositoryBuilder)>) → void inner

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

# validateWithErrorText (errorLocale:  string, validator:  function) → 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