Bugfix create order lines (#311)

* Bugfix create order lines

* bugfix context boolean value

* validate void label for create entity

* rename variables
pull/3759/head
Leonel Matos 2020-02-11 15:51:57 -04:00 committed by GitHub
parent 7f74235073
commit d55e7b7d4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 35 deletions

View File

@ -195,6 +195,9 @@ const data = {
// overwrite value with column link
if (!isEmptyValue(linkColumnName) && linkColumnName === itemField.columnName) {
valueGetDisplayColumn = valueLink
if (isEmptyValue(values[itemField.columnName])) {
values[itemField.columnName] = valueGetDisplayColumn
}
}
// break this itineration if is empty
@ -209,7 +212,7 @@ const data = {
valueGetDisplayColumn = parseInt(valueGetDisplayColumn, 10)
}
}
if (!isEmptyValue(valueGetDisplayColumn) && String(valueGetDisplayColumn) === '[object Object]') {
if (!isEmptyValue(valueGetDisplayColumn) && String(valueGetDisplayColumn) === '[object Object]' && valueGetDisplayColumn.isSQL) {
// get value from direct Query
dispatch('getRecordBySQL', {
query: valueGetDisplayColumn.query,
@ -226,7 +229,7 @@ const data = {
containerUuid,
isNew,
isEdit,
values
row: values
})
}
})
@ -246,6 +249,9 @@ const data = {
// if there is a lookup option, assign the display column with the label
if (option) {
values[`DisplayColumn_${itemField.columnName}`] = option.label
if (isEmptyValue(option.label) && !itemField.isMandatory) {
values[itemField.columnName] = undefined
}
return
}
if (linkColumnName === itemField.columnName) {
@ -629,8 +635,8 @@ const data = {
notifyRowTableChange({ commit, getters, rootGetters }, objectParams) {
const { parentUuid, containerUuid, isEdit = true } = objectParams
var currentValues = {}
if (objectParams.hasOwnProperty('values')) {
currentValues = objectParams.values
if (objectParams.hasOwnProperty('row')) {
currentValues = objectParams.row
} else {
currentValues = rootGetters.getColumnNamesAndValues({
parentUuid,

View File

@ -1073,14 +1073,14 @@ const panel = {
columnName: fieldItem.columnName,
value: fieldItem.defaultValue,
isSQL
}).value
})
}
valueToReturn = parsedValueComponent({
fieldType: fieldItem.componentPath,
referenceType: fieldItem.referenceType,
isMandatory: fieldItem.isMandatory,
value: valueToReturn
value: String(valueToReturn) === '[object Object]' && valueToReturn.isSQL ? valueToReturn : String(valueToReturn) === '[object Object]' ? valueToReturn.value : valueToReturn
})
attributesObject[fieldItem.columnName] = valueToReturn

View File

@ -73,7 +73,6 @@ export function parseContext({
isSQL = false,
isBooleanToString = false
}) {
// const isBooleanToString = value.includes('@SQL=')
let isError = false
const errorsList = []
value = String(value)
@ -94,74 +93,78 @@ export function parseContext({
// }
var token
var inStr = value
var outStr = ''
var inString = value
var outString = ''
let firstIndexTag = inStr.indexOf('@')
let firstIndexTag = inString.indexOf('@')
while (firstIndexTag !== -1) {
outStr = outStr + inStr.substring(0, firstIndexTag) // up to @
inStr = inStr.substring(firstIndexTag + 1, inStr.length) // from first @
const secondIndexTag = inStr.indexOf('@') // next @
outString = outString + inString.substring(0, firstIndexTag) // up to @
inString = inString.substring(firstIndexTag + 1, inString.length) // from first @
const secondIndexTag = inString.indexOf('@') // next @
// no exists second tag
if (secondIndexTag < 0) {
console.info(`No second tag: ${inStr}`)
console.info(`No second tag: ${inString}`)
return {
value: undefined,
isError: true,
errorsList
errorsList,
isSQL
}
}
token = inStr.substring(0, secondIndexTag)
token = inString.substring(0, secondIndexTag)
columnName = token
var ctxInfo = getContext({
var contextInfo = getContext({
parentUuid,
containerUuid,
columnName
}) // get context
if (isBooleanToString && typeof ctxInfo === 'boolean') {
ctxInfo = 'N'
if (ctxInfo) {
ctxInfo = 'Y'
if (isBooleanToString && typeof contextInfo === 'boolean') {
if (contextInfo) {
contextInfo = 'Y'
} else {
contextInfo = 'N'
}
}
if ((ctxInfo === undefined || ctxInfo.length === 0) &&
if ((contextInfo === undefined || contextInfo.length === 0) &&
(token.startsWith('#') || token.startsWith('$'))) {
ctxInfo = getContext({
contextInfo = getContext({
columnName
}) // get global context
}
if (ctxInfo === undefined || ctxInfo.length === 0) {
if (contextInfo === undefined || contextInfo.length === 0) {
console.info(`No Context for: ${token}`)
isError = true
errorsList.push(token)
} else {
if (typeof ctxInfo === 'object') {
outStr = ctxInfo
if (typeof contextInfo === 'object') {
outString = contextInfo
} else {
outStr = outStr + ctxInfo // replace context with Context
outString = outString + contextInfo // replace context with Context
}
}
inStr = inStr.substring(secondIndexTag + 1, inStr.length) // from second @
firstIndexTag = inStr.indexOf('@')
inString = inString.substring(secondIndexTag + 1, inString.length) // from second @
firstIndexTag = inString.indexOf('@')
}
if (typeof ctxInfo !== 'object') {
outStr = outStr + inStr // add the rest of the string
if (typeof contextInfo !== 'object') {
outString = outString + inString // add the rest of the string
}
if (isSQL) {
return {
query: outStr,
value: ctxInfo
query: outString,
value: contextInfo,
isSQL
}
}
return {
value: outStr,
value: outString,
isError,
errorsList
errorsList,
isSQL
}
} // parseContext