fix validation bug in admin

This commit is contained in:
Josh Harvey 2017-05-04 01:22:04 +03:00
parent 9c0d21f66d
commit 1488a60a60
4 changed files with 29 additions and 16 deletions

View file

@ -130,6 +130,7 @@ app.post('/api/machines', (req, res) => {
})
app.get('/api/status', (req, res, next) => {
console.log('DEBUG100')
return Promise.all([server.status(), config.validateCurrentConfig()])
.then(([serverStatus, invalidConfigGroups]) => res.send({
server: serverStatus,

View file

@ -53,9 +53,7 @@ function post (machineTx, pi) {
return postProcess(txVector, pi)
.then(_.tap(pp('DEBUG99')))
.then(changes => update(updatedTx, changes))
.then(_.tap(pp('DEBUG100')))
.then(tx => _.set('bills', machineTx.bills, tx))
.then(_.tap(pp('DEBUG101')))
})
}
@ -86,9 +84,6 @@ function ensureRatchet (oldField, newField, fieldKey) {
return true
}
const tt = r => Object.prototype.toString.call(r)
console.log('DEBUG100: %j', [tt(oldField), tt(newField)])
if (oldField.toString() === newField.toString()) return true
logger.error('This field [%s] should never change', fieldKey)
@ -218,7 +213,7 @@ function registerTrades (pi, newBills) {
function logAction (rec, tx) {
const action = {
tx_id: tx.id,
action: tx.sendCompleted ? 'sendCoins' : 'sendCoinsError',
action: rec.sendConfirmed ? 'sendCoins' : 'sendCoinsError',
error: rec.error,
error_code: rec.errorCode,
tx_hash: rec.txHash

View file

@ -44,10 +44,10 @@ function satisfiesRequire (config, cryptos, machineList, field, refFields) {
return isScopeEnabled(config, cryptos, machineList, refField, scope)
})
const isBlank = () => _.isNil(configManager.scopedValue(scope[0], scope[1], fieldCode, config))
const isBlank = _.isNil(configManager.scopedValue(scope[0], scope[1], fieldCode, config))
const isRequired = refFields.length === 0 || isEnabled()
return isRequired ? !isBlank() : true
return isRequired ? !isBlank : true
})
}
@ -78,8 +78,12 @@ function getGroup (fieldCode) {
return _.find(group => _.includes(fieldCode, group.fields), schema.groups)
}
function getField (group, fieldCode) {
if (!group) group = getGroup(fieldCode)
function getField (fieldCode) {
const group = getGroup(fieldCode)
return getGroupField(group, fieldCode)
}
function getGroupField (group, fieldCode) {
const field = _.find(_.matchesProperty('code', fieldCode), schema.fields)
return _.merge(_.pick(['cryptoScope', 'machineScope'], group), field)
}
@ -126,10 +130,11 @@ function validateRequires (config) {
return schema.groups.filter(group => {
return group.fields.some(fieldCode => {
const field = getField(group, fieldCode)
const field = getGroupField(group, fieldCode)
if (!field.fieldValidation.find(r => r.code === 'required')) return false
const refFields = _.map(_.partial(getField, null), field.enabledIf)
const refFields = _.map(_.partial(getField, group), field.enabledIf)
return !satisfiesRequire(config, cryptos, machineList, field, refFields)
})
})

View file

@ -27207,10 +27207,22 @@ var _user$project$Account$view = function (webModel) {
return '';
}
}();
var fieldSetView = A2(
var fieldSetView = A3(
_elm_lang$html$Html_Keyed$node,
'div',
{ctor: '[]'},
{
ctor: '::',
_0: {
ctor: '_Tuple2',
_0: _p3.account.code,
_1: A2(
_elm_lang$html$Html$map,
_user$project$Account$FieldSetMsg,
_user$project$FieldSet$view(_p3.account.fields));
_user$project$FieldSet$view(_p3.account.fields))
},
_1: {ctor: '[]'}
});
return A2(
_elm_lang$html$Html$div,
{ctor: '[]'},