Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
fix: Set parent values on report/process. (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt authored Jun 27, 2022
1 parent f54e30f commit 1c5c291
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 17 deletions.
4 changes: 1 addition & 3 deletions src/store/modules/ADempiere/dictionary/browser/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default {
}

// all optionals (not mandatory) fields
const a = fieldsList
return fieldsList
.filter(fieldItem => {
const { defaultValue } = fieldItem

Expand All @@ -201,8 +201,6 @@ export default {

return true
})
console.log(a)
return a
}

}
47 changes: 47 additions & 0 deletions src/store/modules/ADempiere/dictionary/process/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,53 @@ export default {
})

return processParameters
},

/**
* Available fields to showed/hidden
* to show, used in components FilterFields
* @param {string} containerUuid
* @param {array} fieldsList
* @param {function} showedMethod
* @param {boolean} isEvaluateShowed
* @param {boolean} isEvaluateDefaultValue
*/
getProcessParametersListToHidden: (state, getters) => ({
containerUuid,
isTable = false,
fieldsList = [],
showedMethod = isDisplayedField,
isEvaluateDefaultValue = false,
isEvaluateShowed = true
}) => {
if (isEmptyValue(fieldsList)) {
fieldsList = getters.getStoredFieldsFromProcess(containerUuid)
}

// all optionals (not mandatory) fields
return fieldsList
.filter(fieldItem => {
const { defaultValue } = fieldItem

if (fieldItem.isMandatory && !isTable) {
return false
}

if (isEvaluateDefaultValue && isEvaluateShowed) {
return showedMethod(fieldItem) &&
!isEmptyValue(defaultValue)
}

if (isEvaluateDefaultValue) {
return !isEmptyValue(defaultValue)
}

if (isEvaluateShowed) {
return showedMethod(fieldItem)
}

return true
})
}

}
2 changes: 1 addition & 1 deletion src/store/modules/ADempiere/dictionary/window/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default {
let relatedColumns = []
const parentColumns = tabDefinition.fieldsList
.filter(fieldItem => {
return fieldItem.isParent || fieldItem.isKey
return fieldItem.isParent || fieldItem.isKey || fieldItem.isMandatory
})
.map(fieldItem => {
return fieldItem.columnName
Expand Down
8 changes: 4 additions & 4 deletions src/utils/ADempiere/dictionary/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export function isDisplayedField({ displayType, isActive, isQueryCriteria, displ
/**
* Default showed field from user
*/
export function evaluateDefaultFieldShowed({ defaultValue, isMandatory, isShowedFromUser }) {
if (isMandatory || !isEmptyValue(defaultValue)) {
export function evaluateDefaultFieldShowed({ defaultValue, parsedDefaultValue, isMandatory, isShowedFromUser }) {
if (isMandatory) {
return true
}
if (isShowedFromUser) {
if (!isEmptyValue(defaultValue) || !isEmptyValue(parsedDefaultValue)) {
return true
}
return false
return Boolean(isShowedFromUser)
}

/**
Expand Down
16 changes: 9 additions & 7 deletions src/utils/ADempiere/dictionary/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ export function isDisplayedField({ displayType, isActive, isDisplayed, displayLo
/**
* Default showed field from user
*/
export function evaluateDefaultFieldShowed({ name, defaultValue, isMandatory, isShowedFromUser }) {
if (!isEmptyValue(defaultValue) || isMandatory) {
export function evaluateDefaultFieldShowed({ defaultValue, parsedDefaultValue, isMandatory, isShowedFromUser }) {
if (isMandatory) {
return true
}

if (isShowedFromUser) {
if (!isEmptyValue(defaultValue) || !isEmptyValue(parsedDefaultValue)) {
return true
}
return false
return Boolean(isShowedFromUser)
}

/**
Expand Down Expand Up @@ -198,11 +197,14 @@ export const containerManager = {
},

isDisplayedField,
isDisplayedDefault: ({ isMandatory, defaultValue }) => {
isDisplayedDefault: ({ isMandatory, defaultValue, isShowedFromUser }) => {
// add is showed from user
if (isMandatory || !isEmptyValue(defaultValue)) {
if (isMandatory) {
return true
}
if (!isEmptyValue(defaultValue)) {
return isShowedFromUser
}
return false
},

Expand Down
4 changes: 2 additions & 2 deletions src/utils/ADempiere/dictionaryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export function generateField({
// if field with value displayed in main panel
field.isShowedFromUser = evaluateDefaultFieldShowed({
...field,
defaultValue: parsedDefaultValueTo
parsedDefaultValue: parsedDefaultValueTo
})
}
}
Expand All @@ -233,7 +233,7 @@ export function generateField({
if (!typeRange) {
field.isShowedFromUser = evaluateDefaultFieldShowed({
...field,
defaultValue: parsedDefaultValue
parsedDefaultValue
})
}
field.isShowedFromUserDefault = field.isShowedFromUser
Expand Down

0 comments on commit 1c5c291

Please sign in to comment.