Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set correct boolean value. #1487

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/store/modules/ADempiere/dictionary/window/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ export default {
}, {
root: true
})

if (!attribute.columnName.includes('DisplayColumn')) {
const field = rootGetters.getStoredFieldFromTab({
windowUuid: parentUuid,
tabUuid: containerUuid,
columnName: attribute.columnName
})
// activate logics
dispatch('changeDependentFieldsList', {
field,
fieldsList: tab.fieldsList
})
}
})

dispatch('updateValuesOfContainer', {
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/ADempiere/dictionary/window/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default {

getStoredFieldFromTab: (state, getters) => ({ windowUuid, tabUuid, columnName, fieldUuid }) => {
return getters.getStoredFieldsFromTab(windowUuid, tabUuid)
.map(field => {
.find(field => {
return field.columnName === columnName || field.uuid === fieldUuid
})
},
Expand Down
42 changes: 14 additions & 28 deletions src/store/modules/ADempiere/panel/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
parsedValueComponent
} from '@/utils/ADempiere/valueUtils.js'
import {
ACCOUNTING_COLUMNS,
LOG_COLUMNS_NAME_LIST
} from '@/utils/ADempiere/constants/systemColumns'
import {
Expand Down Expand Up @@ -290,39 +289,26 @@ const getters = {
let attributesList = fieldsList
.map(fieldItem => {
const { columnName, defaultValue } = fieldItem
let isSQL = false
let parsedDefaultValue = fieldItem.parsedDefaultValue
const isSpeciaColumn = ACCOUNTING_COLUMNS.includes(columnName) || ACCOUNTING_COLUMNS.includes(fieldItem.elementName)
const isSQL = String(defaultValue).includes('@SQL=') && isGetServer

if (String(defaultValue).includes('@') || isSpeciaColumn) {
parsedDefaultValue = getDefaultValue({
...fieldItem,
parentUuid,
isSOTrxMenu
})
if (String(defaultValue).includes('@SQL=') && isGetServer) {
isSQL = true
}
}
const parsedDefaultValue = getDefaultValue({
...fieldItem,
parentUuid,
isSOTrxMenu
})
attributesObject[columnName] = parsedDefaultValue

if (fieldItem.isRange && fieldItem.componentPath !== 'FieldNumber') {
const { columnNameTo, elementNameTo, defaultValueTo } = fieldItem
let parsedDefaultValueTo = fieldItem.parsedDefaultValueTo
let isSQLTo = false
if (String(defaultValueTo).includes('@') || isSpeciaColumn) {
if (String(defaultValueTo).includes('@SQL=') && isGetServer) {
isSQLTo = true
}
const isSQLTo = String(defaultValueTo).includes('@SQL=') && isGetServer

parsedDefaultValueTo = getDefaultValue({
...fieldItem,
parentUuid,
isSOTrxMenu,
columnName: columnNameTo,
elementName: elementNameTo
})
}
const parsedDefaultValueTo = getDefaultValue({
...fieldItem,
parentUuid,
isSOTrxMenu,
columnName: columnNameTo,
elementName: elementNameTo
})

attributesObject[columnNameTo] = parsedDefaultValueTo
attributesRangue.push({
Expand Down
19 changes: 14 additions & 5 deletions src/utils/ADempiere/contextUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ import evaluator from '@/utils/ADempiere/evaluator'

export default evaluator

// get context state from vuex store
/**
* Get context state from vuex store
* @param {string} parentUuid UUID Window
* @param {string} containerUuid UUID Tab, Process, SmartBrowser, Report and Form
* @param {boolean} isBooleanToString if convert true to 'Y'
* @param {string} columnName (context) Entity to search
* @returns
*/
export const getContext = ({
parentUuid,
containerUuid,
Expand All @@ -37,14 +44,16 @@ export const getContext = ({
const isPreferenceValue = columnName.startsWith('$') ||
columnName.startsWith('#') ||
columnName.startsWith(`P|`)

// get value to session context
if (isPreferenceValue) {
value = store.getters.getPreference({
parentUuid,
containerUuid,
columnName
})
}
if (!isPreferenceValue && isEmptyValue(value)) {
} else {
// get value to container view
value = store.getters.getValueOfField({
parentUuid,
containerUuid,
Expand Down Expand Up @@ -88,8 +97,8 @@ export function getPreference({
// View Preferences
if (parentUuid) {
value = getContext({
parentUuid: 'P' + parentUuid,
containerUuid,
parentUuid: 'P|' + parentUuid,
containerUuid: 'P|' + containerUuid,
columnName
})
if (!isEmptyValue(value)) {
Expand Down
18 changes: 15 additions & 3 deletions src/utils/ADempiere/dictionaryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import evaluator from '@/utils/ADempiere/evaluator'
import { isEmptyValue, parsedValueComponent } from '@/utils/ADempiere/valueUtils'
import { arrayMatches, isEmptyValue, parsedValueComponent } from '@/utils/ADempiere/valueUtils'
import { getContext, getParentFields, getPreference, parseContext } from '@/utils/ADempiere/contextUtils'
import REFERENCES, { BUTTON, YES_NO, DEFAULT_SIZE, isHiddenField } from '@/utils/ADempiere/references'
import { FIELD_OPERATORS_LIST } from '@/utils/ADempiere/dataUtils'
import {
ACCOUNTING_COLUMNS,
isDocumentStatus,
READ_ONLY_FORM_COLUMNS,
readOnlyColumn
Expand Down Expand Up @@ -307,7 +308,10 @@ export function getDefaultValue({
}) {
let parsedDefaultValue = defaultValue

if (String(parsedDefaultValue).includes('@') &&
const isContextValue = String(parsedDefaultValue).includes('@')
const isSpeciaColumn = !isEmptyValue(arrayMatches(ACCOUNTING_COLUMNS, [columnName, elementName]))
// search value with context
if ((isSpeciaColumn || isContextValue) &&
String(parsedDefaultValue).trim() !== '-1') {
parsedDefaultValue = parseContext({
parentUuid,
Expand All @@ -318,6 +322,7 @@ export function getDefaultValue({
}).value
}

// search value preference with column name
if (isEmptyValue(parsedDefaultValue) && !isKey &&
String(parsedDefaultValue).trim() !== '-1') {
parsedDefaultValue = getPreference({
Expand All @@ -326,7 +331,7 @@ export function getDefaultValue({
columnName
})

// search value preference with elementName
// search value preference with element name
if (!isEmptyValue(elementName) &&
isEmptyValue(parsedDefaultValue)) {
parsedDefaultValue = getPreference({
Expand All @@ -337,13 +342,20 @@ export function getDefaultValue({
}
}

// search value with form read only
if (isColumnReadOnlyForm && isEmptyValue(parsedDefaultValue)) {
const { defaultValue: defaultValueColumn } = READ_ONLY_FORM_COLUMNS.find(columnItem => {
return columnItem.columnName === columnName
})
parsedDefaultValue = defaultValueColumn
}

// set default value
if (isEmptyValue(parsedDefaultValue) && !isContextValue) {
parsedDefaultValue = defaultValue
}

// convert to element-ui compatible value
parsedDefaultValue = parsedValueComponent({
columnName,
componentPath,
Expand Down
21 changes: 21 additions & 0 deletions src/utils/ADempiere/valueUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,27 @@ export function parsedValueComponent({
return returnValue
}

/**
* Returns matching elements of arrays
* @param {array} arrayA
* @param {array} arrayB
* @returns {array}
*/
export function arrayMatches(arrayA = [], arrayB = []) {
const matches = []

if (isEmptyValue(arrayA) || isEmptyValue(arrayB)) {
return matches
}
arrayA.forEach(elementA => {
if (arrayB.includes(elementA)) {
matches.push(elementA)
}
})

return matches
}

/**
* Payment method icon element-ui supported
* @author Elsio Sanchez <elsiosanches@gmail.com>
Expand Down