diff --git a/src/store/modules/ADempiere/dictionary/browser/getters.js b/src/store/modules/ADempiere/dictionary/browser/getters.js index 58d59851195..993f96e95d7 100644 --- a/src/store/modules/ADempiere/dictionary/browser/getters.js +++ b/src/store/modules/ADempiere/dictionary/browser/getters.js @@ -178,7 +178,7 @@ export default { } // all optionals (not mandatory) fields - const a = fieldsList + return fieldsList .filter(fieldItem => { const { defaultValue } = fieldItem @@ -201,8 +201,6 @@ export default { return true }) - console.log(a) - return a } } diff --git a/src/store/modules/ADempiere/dictionary/process/getters.js b/src/store/modules/ADempiere/dictionary/process/getters.js index 9dc4a118e67..2bfe2329868 100644 --- a/src/store/modules/ADempiere/dictionary/process/getters.js +++ b/src/store/modules/ADempiere/dictionary/process/getters.js @@ -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 + }) } } diff --git a/src/store/modules/ADempiere/dictionary/window/actions.js b/src/store/modules/ADempiere/dictionary/window/actions.js index 162b765ac75..82f410230cc 100644 --- a/src/store/modules/ADempiere/dictionary/window/actions.js +++ b/src/store/modules/ADempiere/dictionary/window/actions.js @@ -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 diff --git a/src/utils/ADempiere/dictionary/browser.js b/src/utils/ADempiere/dictionary/browser.js index c0628a0ba3f..45f9eeb2160 100644 --- a/src/utils/ADempiere/dictionary/browser.js +++ b/src/utils/ADempiere/dictionary/browser.js @@ -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) } /** diff --git a/src/utils/ADempiere/dictionary/process.js b/src/utils/ADempiere/dictionary/process.js index f341786acc0..7448798527b 100644 --- a/src/utils/ADempiere/dictionary/process.js +++ b/src/utils/ADempiere/dictionary/process.js @@ -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) } /** @@ -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 }, diff --git a/src/utils/ADempiere/dictionaryUtils.js b/src/utils/ADempiere/dictionaryUtils.js index 6279f3f3aae..23f9d13d7b8 100644 --- a/src/utils/ADempiere/dictionaryUtils.js +++ b/src/utils/ADempiere/dictionaryUtils.js @@ -224,7 +224,7 @@ export function generateField({ // if field with value displayed in main panel field.isShowedFromUser = evaluateDefaultFieldShowed({ ...field, - defaultValue: parsedDefaultValueTo + parsedDefaultValue: parsedDefaultValueTo }) } } @@ -233,7 +233,7 @@ export function generateField({ if (!typeRange) { field.isShowedFromUser = evaluateDefaultFieldShowed({ ...field, - defaultValue: parsedDefaultValue + parsedDefaultValue }) } field.isShowedFromUserDefault = field.isShowedFromUser