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 { convertFieldListToShareLink, recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
import { supportedTypes, exportFileFromJson } from '@/utils/ADempiere/exportUtil'
@ -195,6 +195,7 @@ export const contextMixin = {
this.getReferences()
},
methods: {
showMessage,
showNotification,
actionContextMenu(event) {
switch (event.srcKey) {
@ -217,35 +218,9 @@ export const contextMixin = {
})
break
case 'f5':
if (this.panelType === 'window') {
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
})
}
this.refreshData()
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() {
if (this.panelType === 'window') {
@ -256,10 +231,21 @@ export const contextMixin = {
recordUuid: this.recordUuid
})
} else if (this.panelType === 'browser') {
this.$store.dispatch('getBrowserSearch', {
const fieldsEmpty = this.$store.getters.getFieldListEmptyMandatory({
containerUuid: this.containerUuid,
isClearSelection: true
fieldsList: this.getterFieldList
})
if (fieldsEmpty.length) {
this.showMessage({
message: this.$t('notifications.mandatoryFieldMissing') + fieldsEmpty,
type: 'info'
})
} else {
this.$store.dispatch('getBrowserSearch', {
containerUuid: this.containerUuid,
isClearSelection: true
})
}
}
},
getReferences() {

View File

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

View File

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

View File

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

View File

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