fix recursive enabledIf
This commit is contained in:
parent
c78519072b
commit
aed92f0dab
2 changed files with 256 additions and 280 deletions
|
|
@ -2,6 +2,7 @@ const pify = require('pify')
|
|||
const fs = pify(require('fs'))
|
||||
const path = require('path')
|
||||
const R = require('ramda')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const currencies = require('../../currencies.json')
|
||||
const languageRec = require('../../languages.json')
|
||||
|
|
@ -71,6 +72,13 @@ function validateCurrentConfig () {
|
|||
.then(configValidate.validateRequires)
|
||||
}
|
||||
|
||||
function decorateEnabledIf (schemaFields, schemaField) {
|
||||
const code = schemaField.fieldLocator.code
|
||||
const field = _.find(f => f.code === code, schemaFields)
|
||||
console.log('DEBUG200: %j', [schemaField, code, field, schemaFields])
|
||||
return _.set('fieldEnabledIf', field.enabledIf || [], schemaField)
|
||||
}
|
||||
|
||||
function fetchConfigGroup (code) {
|
||||
const fieldLocatorCodeEq = R.pathEq(['fieldLocator', 'code'])
|
||||
return Promise.all([fetchSchema(), fetchData(), fetchConfig(), fetchMachines()])
|
||||
|
|
@ -90,8 +98,11 @@ function fetchConfigGroup (code) {
|
|||
]
|
||||
const configFields = R.uniq(R.flatten(candidateFields)).filter(R.identity)
|
||||
|
||||
const values = configFields
|
||||
.reduce((acc, configField) => acc.concat(config.filter(fieldLocatorCodeEq(configField))), [])
|
||||
const reducer = (acc, configField) => {
|
||||
return acc.concat(config.filter(fieldLocatorCodeEq(configField)))
|
||||
}
|
||||
|
||||
const values = _.map(f => decorateEnabledIf(schema.fields, f), configFields.reduce(reducer, []))
|
||||
|
||||
groupSchema.fields = undefined
|
||||
groupSchema.entries = schemaFields
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue