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:
trackedObj
: VuexTrackedObjectentity
: string
# change (state: VuexTrackedObject, key: string, value: *, pathopt: string) inner
A helper method to update the "tracked" object property
Arguments:
state
: VuexTrackedObjectkey
: stringvalue
: *path
: stringPath 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).
# enrichFieldList (entitySchema: UBEntity, fieldList: Array.<string>, requiredAttrs: Array.<string>) → Array.<string> inner
# 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.
# 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:
state
: VuexTrackedObjectkey
: string
# mergeStore (target: window.Vuex.StoreOptions, source: window.Vuex.StoreOptions) inner
Assign source store options into target store options
Arguments:
target
: window.Vuex.StoreOptionsTarget store
source
: window.Vuex.StoreOptionsSource store
# prepareCopyAddNewExecParams (originalExecParams: object, entity: string) → object inner
Return:
execParams
# 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:
execParams
: object
# 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:
state
: VuexTrackedInstancepayload
: objectkey
: Stringstate key
value
: *value
# 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)
# 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)
# transformCollections (collections: Object.<string, (UbVuexStoreCollectionInfo | UbVuexStoreRepositoryBuilder)>) → void inner
Transform's each collection object to
key: { repository: store => UB.Repository(), lazy: true/false }
Arguments:
collections
: Object.<string, (UbVuexStoreCollectionInfo | UbVuexStoreRepositoryBuilder)>
# validateWithErrorText (errorLocale: string, validator: function) → function inner
Assign some error text for validator function.
Types
# UbQueryParams inner
"execParams" and "fieldList"
Properties
# VuexTrackedCollection inner
Properties
entity
: stringEntity code
key
: stringUnique 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
: stringCustom unique key which is set on init collection
entity
: stringEntity code
# VuexTrackedInstance inner
Properties
# VuexTrackedObject inner
Properties