diff --git a/src/components/ADempiere/DataTable/index.vue b/src/components/ADempiere/DataTable/index.vue index 158e6f9b..93aec2e7 100644 --- a/src/components/ADempiere/DataTable/index.vue +++ b/src/components/ADempiere/DataTable/index.vue @@ -239,7 +239,7 @@ @keyup.enter.native="confirmEdit(scope.row)" /> - + {{ displayedValue(scope.row, fieldAttributes) }} @@ -281,6 +281,7 @@ import MainPanel from '@/components/ADempiere/Panel' import { sortFields } from '@/utils/ADempiere' import { FIELD_READ_ONLY_FORM } from '@/components/ADempiere/Field/references' import { fieldIsDisplayed } from '@/utils/ADempiere' +import evaluator from '@/utils/ADempiere/evaluator' export default { name: 'DataTable', @@ -919,6 +920,26 @@ export default { } }) } + }, + getFieldDefinition(fieldDefinition, row) { + var styleSheet = '' + if (fieldDefinition && (fieldDefinition.id !== null || fieldDefinition.conditions.length)) { + fieldDefinition.conditions.forEach(condition => { + var columns = evaluator.parseDepends(condition.condition) + var conditionLogic = condition.condition + columns.forEach(column => { + conditionLogic = conditionLogic.replace(/@/g, '') + conditionLogic = conditionLogic.replace(column, row[column]) + conditionLogic = evaluator.evaluateLogic({ + logic: conditionLogic + }) + }) + if (conditionLogic && condition.isActive) { + styleSheet = condition.styleSheet + } + }) + } + return styleSheet } } } diff --git a/src/utils/ADempiere/index.js b/src/utils/ADempiere/index.js index cf3bb8c3..57b18ea7 100644 --- a/src/utils/ADempiere/index.js +++ b/src/utils/ADempiere/index.js @@ -90,6 +90,40 @@ export function convertField(fieldGRPC, moreAttributes = {}, typeRange = false) } } + var fieldDefinition = fieldGRPC.getFielddefinition() + var fieldConditions = [] + var fieldDefinitionValue = { + id: null, + uuid: '', + value: '', + name: '', + fieldGroupType: '', + conditions: fieldConditions, + isActive: false + } + if (fieldDefinition) { + if (fieldDefinition.getConditionsList()) { + fieldConditions = fieldDefinition.getConditionsList().map(condition => { + return { + id: condition.getId(), + uuid: condition.getUuid(), + condition: condition.getCondition(), + styleSheet: condition.getStylesheet(), + isActive: condition.getIsactive() + } + }) + } + fieldDefinitionValue = { + id: fieldDefinition.getId(), + uuid: fieldDefinition.getUuid(), + value: fieldDefinition.getValue(), + name: fieldDefinition.getName(), + fieldGroupType: fieldDefinition.getFieldgrouptype(), + conditions: fieldConditions, + isActive: fieldDefinition.getIsactive() + } + } + var componentReference = evalutateTypeField(fieldGRPC.getDisplaytype(), true) var parsedDefaultValue = fieldGRPC.getDefaultvalue() @@ -137,6 +171,7 @@ export function convertField(fieldGRPC, moreAttributes = {}, typeRange = false) isActive: fieldGRPC.getIsactive(), // displayed attributes fieldGroup: group, + fieldDefinition: fieldDefinitionValue, displayType: fieldGRPC.getDisplaytype(), componentPath: componentReference.type, isSupport: componentReference.support, @@ -513,6 +548,40 @@ export function convertMessageTextFromGRPC(messageTextGRPC) { return messageText } +export function convertFieldDefinitionFromGRPC(contextInfoGRPC) { + // int32 id = 1; + // string uuid = 2; + // string value = 3; + // string name = 4; + // string fieldGroupType = 5; + // repeated FieldCondition conditions = 6; + // bool isActive = 7; + var contextInfo = { + id: null, + uuid: '', + value: '', + name: '', + fieldGroupType: '', + sqlStatement: '', + isActive: false, + messageText: convertMessageTextFromGRPC(undefined) + } + if (contextInfoGRPC !== undefined) { + contextInfo = { + id: contextInfoGRPC.getId(), + uuid: contextInfoGRPC.getUuid(), + name: contextInfoGRPC.getName(), + description: contextInfoGRPC.getDescription(), + sqlStatement: contextInfoGRPC.getSqlstatement(), + isActive: contextInfoGRPC.getIsactive(), + messageText: convertMessageTextFromGRPC( + contextInfoGRPC.getMessagetext() + ) + } + } + return contextInfo +} + /** * [assignedGroup] * @param {array} fieldList Field of List with