fix: #316 Add Smart Browser validation to research with mandatory parameters. (#317)

* fix: Add Smart Browser validation to research with mandatory parameters.

* Delete duplicated code.
pull/3759/head
Edwin Betancourt 2020-02-11 15:54:10 -04:00 committed by GitHub
parent d55e7b7d4d
commit ac4b0df91c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 59 deletions

View File

@ -1,4 +1,4 @@
import { showNotification } from '@/utils/ADempiere/notification' import { showNotification, showMessage } from '@/utils/ADempiere/notification'
import Item from './items' import Item from './items'
import { convertFieldListToShareLink, recursiveTreeSearch } from '@/utils/ADempiere/valueUtils' import { convertFieldListToShareLink, recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
import { supportedTypes, exportFileFromJson } from '@/utils/ADempiere/exportUtil' import { supportedTypes, exportFileFromJson } from '@/utils/ADempiere/exportUtil'
@ -195,6 +195,7 @@ export const contextMixin = {
this.getReferences() this.getReferences()
}, },
methods: { methods: {
showMessage,
showNotification, showNotification,
actionContextMenu(event) { actionContextMenu(event) {
switch (event.srcKey) { switch (event.srcKey) {
@ -217,35 +218,9 @@ export const contextMixin = {
}) })
break break
case 'f5': case 'f5':
if (this.panelType === 'window') { this.refreshData()
this.$store.dispatch('getDataListTab', {
parentUuid: this.parentUuid,
containerUuid: this.containerUuid,
isRefreshPanel: true,
recordUuid: this.recordUuid
})
} else if (this.panelType === 'browser') {
this.$store.dispatch('getBrowserSearch', {
containerUuid: this.containerUuid,
isClearSelection: true
})
}
break break
} }
// this.$store.dispatch('resetPanelToNew', {
// parentUuid: this.parentUuid,
// containerUuid: this.containerUuid,
// recordUuid: this.recordUuid,
// panelType: 'window',
// isNewRecord: true
// })
// this.$store.dispatch('deleteEntity', {
// parentUuid: this.parentUuid,
// containerUuid: this.containerUuid,
// recordUuid: this.recordUuid,
// panelType: 'window',
// isNewRecord: false
// })
}, },
refreshData() { refreshData() {
if (this.panelType === 'window') { if (this.panelType === 'window') {
@ -256,11 +231,22 @@ export const contextMixin = {
recordUuid: this.recordUuid recordUuid: this.recordUuid
}) })
} else if (this.panelType === 'browser') { } else if (this.panelType === 'browser') {
const fieldsEmpty = this.$store.getters.getFieldListEmptyMandatory({
containerUuid: this.containerUuid,
fieldsList: this.getterFieldList
})
if (fieldsEmpty.length) {
this.showMessage({
message: this.$t('notifications.mandatoryFieldMissing') + fieldsEmpty,
type: 'info'
})
} else {
this.$store.dispatch('getBrowserSearch', { this.$store.dispatch('getBrowserSearch', {
containerUuid: this.containerUuid, containerUuid: this.containerUuid,
isClearSelection: true isClearSelection: true
}) })
} }
}
}, },
getReferences() { getReferences() {
if (this.isReferecesContent) { if (this.isReferecesContent) {

View File

@ -67,13 +67,18 @@ const browser = {
field.isShowedFromUser = true field.isShowedFromUser = true
} }
// Only isQueryCriteria fields, displayed in main panel // Only isQueryCriteria fields with values, displayed in main panel
if (field.isQueryCriteria && !isEmptyValue(field.value) && String(field.value) !== '-1') { if (field.isQueryCriteria) {
if (isEmptyValue(field.value)) {
// isMandatory params to showed search criteria
if (field.isMandatory || field.isMandatoryFromLogic) {
isMandatoryParams = true
}
} else {
field.isShowedFromUser = true field.isShowedFromUser = true
} }
}
// TODO: Evaluate if not change when iterate
isMandatoryParams = field.isMandatory
return field return field
}) })
fieldsList = fieldsList.concat(fieldsRangeList) fieldsList = fieldsList.concat(fieldsRangeList)
@ -83,7 +88,7 @@ const browser = {
.filter(field => field.parentFieldsList && field.isActive) .filter(field => field.parentFieldsList && field.isActive)
.forEach((field, index, list) => { .forEach((field, index, list) => {
field.parentFieldsList.forEach(parentColumnName => { field.parentFieldsList.forEach(parentColumnName => {
var parentField = list.find(parentField => { const parentField = list.find(parentField => {
return parentField.columnName === parentColumnName && parentColumnName !== field.columnName return parentField.columnName === parentColumnName && parentColumnName !== field.columnName
}) })
if (parentField) { if (parentField) {
@ -124,11 +129,10 @@ const browser = {
// Panel for save on store // Panel for save on store
const newBrowser = { const newBrowser = {
...browserResponse, ...browserResponse,
containerUuid: browserResponse.uuid, containerUuid,
fieldList: fieldsList, fieldList: fieldsList,
panelType, panelType,
// app attributes // app attributes
isMandatoryParams,
isShowedCriteria: Boolean(fieldsList.length && isMandatoryParams), isShowedCriteria: Boolean(fieldsList.length && isMandatoryParams),
isShowedTotals: true isShowedTotals: true
} }

View File

@ -731,7 +731,8 @@ const panel = {
} }
// Default Value // Default Value
if (fieldDependent.defaultValue.trim() !== '' && if (fieldDependent.defaultValue.trim() !== '' &&
fieldDependent.defaultValue.includes('@')) { fieldDependent.defaultValue.includes('@') &&
String(fieldDependent.defaultValue).trim() !== '-1') {
defaultValue = parseContext({ defaultValue = parseContext({
parentUuid, parentUuid,
containerUuid, containerUuid,

View File

@ -30,13 +30,14 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
value: parsedDefaultValue value: parsedDefaultValue
}).value }).value
} }
if (isEmptyValue(parsedDefaultValue)) { if (isEmptyValue(parsedDefaultValue) && String(parsedDefaultValue).trim() !== '-1') {
parsedDefaultValue = getPreference({ parsedDefaultValue = getPreference({
parentUuid: fieldToGenerate.parentUuid, parentUuid: fieldToGenerate.parentUuid,
containerUuid: fieldToGenerate.containerUuid, containerUuid: fieldToGenerate.containerUuid,
columnName: fieldToGenerate.columnName columnName: fieldToGenerate.columnName
}) })
}
// search value preference with elementName
if (isEmptyValue(parsedDefaultValue) && !isEmptyValue(fieldToGenerate.elementName)) { if (isEmptyValue(parsedDefaultValue) && !isEmptyValue(fieldToGenerate.elementName)) {
parsedDefaultValue = getPreference({ parsedDefaultValue = getPreference({
parentUuid: fieldToGenerate.parentUuid, parentUuid: fieldToGenerate.parentUuid,
@ -45,6 +46,7 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
}) })
} }
} }
}
parsedDefaultValue = parsedValueComponent({ parsedDefaultValue = parsedValueComponent({
fieldType: componentReference.type, fieldType: componentReference.type,
value: parsedDefaultValue, value: parsedDefaultValue,
@ -63,13 +65,14 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
value: parsedDefaultValueTo value: parsedDefaultValueTo
}).value }).value
} }
if (isEmptyValue(parsedDefaultValueTo)) { if (isEmptyValue(parsedDefaultValueTo) && String(parsedDefaultValueTo).trim() !== '-1') {
parsedDefaultValueTo = getPreference({ parsedDefaultValueTo = getPreference({
parentUuid: fieldToGenerate.parentUuid, parentUuid: fieldToGenerate.parentUuid,
containerUuid: fieldToGenerate.containerUuid, containerUuid: fieldToGenerate.containerUuid,
columnName: `${fieldToGenerate.columnName}_To` columnName: `${fieldToGenerate.columnName}_To`
}) })
}
// search value preference with elementName
if (isEmptyValue(parsedDefaultValueTo) && !isEmptyValue(fieldToGenerate.elementName)) { if (isEmptyValue(parsedDefaultValueTo) && !isEmptyValue(fieldToGenerate.elementName)) {
parsedDefaultValueTo = getPreference({ parsedDefaultValueTo = getPreference({
parentUuid: fieldToGenerate.parentUuid, parentUuid: fieldToGenerate.parentUuid,
@ -78,6 +81,7 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
}) })
} }
} }
}
parsedDefaultValueTo = parsedValueComponent({ parsedDefaultValueTo = parsedValueComponent({
fieldType: componentReference.type, fieldType: componentReference.type,
value: parsedDefaultValueTo, value: parsedDefaultValueTo,
@ -101,9 +105,9 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
parsedDefaultValue, parsedDefaultValue,
parsedDefaultValueTo, parsedDefaultValueTo,
// logics to app // logics to app
isDisplayedFromLogic: Boolean(fieldToGenerate.isDisplayed), isDisplayedFromLogic: fieldToGenerate.isDisplayed,
isReadOnlyFromLogic: Boolean(fieldToGenerate.isReadOnly), isReadOnlyFromLogic: false,
isMandatoryFromLogic: Boolean(fieldToGenerate.isMandatory), isMandatoryFromLogic: false,
// //
parentFieldsList: [], parentFieldsList: [],
dependentFieldsList: [], dependentFieldsList: [],

View File

@ -10,7 +10,7 @@ import { convertValueFromGRPC } from '@/api/ADempiere/data'
export function isEmptyValue(value) { export function isEmptyValue(value) {
if (value === undefined || value == null) { if (value === undefined || value == null) {
return true return true
} else if (value === -1 || value === '-1') { } else if (value === -1 || String(value).trim() === '-1') {
return true return true
} else if (typeof value === 'string') { } else if (typeof value === 'string') {
return Boolean(!value.trim().length) return Boolean(!value.trim().length)