mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 20:39:48 +08:00
fix: Default values that are @SQL= on the first load (#391)
This commit is contained in:
parent
b2c5f894ec
commit
206fedb198
@ -12,15 +12,6 @@ function Instance() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converted the gRPC value to the value needed
|
|
||||||
* @param {object} grpcValue Value get of gRPC
|
|
||||||
* @returns {mixed}
|
|
||||||
*/
|
|
||||||
export function convertValueFromGRPC(grpcValue) {
|
|
||||||
return Instance.call(this).convertValueFromGRPC(grpcValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create entity
|
* Create entity
|
||||||
* @param {string} parameters.tableName
|
* @param {string} parameters.tableName
|
||||||
@ -213,13 +204,13 @@ export function runProcess({ uuid, reportType, tableName, recordId, parameters:
|
|||||||
* @param {string} whereClause
|
* @param {string} whereClause
|
||||||
* @param {string} orderByClause
|
* @param {string} orderByClause
|
||||||
* @param {string} nextPageToken
|
* @param {string} nextPageToken
|
||||||
* @param {array} parameters, This allows follow structure:
|
* @param {array} parametersList, This allows follow structure:
|
||||||
* [{
|
* [{
|
||||||
* columnName,
|
* columnName,
|
||||||
* value
|
* value
|
||||||
* }]
|
* }]
|
||||||
*/
|
*/
|
||||||
export function getBrowserSearch({ uuid, parameters: parametersList = [], query, whereClause, orderByClause, nextPageToken: pageToken, pageSize }) {
|
export function getBrowserSearch({ uuid, parametersList = [], query, whereClause, orderByClause, nextPageToken: pageToken, pageSize }) {
|
||||||
// Run browser
|
// Run browser
|
||||||
return Instance.call(this).requestListBrowserSearch({
|
return Instance.call(this).requestListBrowserSearch({
|
||||||
uuid,
|
uuid,
|
||||||
|
@ -7,7 +7,7 @@ export const fieldMixin = {
|
|||||||
},
|
},
|
||||||
// value received from data result
|
// value received from data result
|
||||||
valueModel: {
|
valueModel: {
|
||||||
type: [String, Number, Boolean, Date, Array],
|
type: [String, Number, Boolean, Date, Array, Object],
|
||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -39,6 +39,16 @@ export const fieldMixin = {
|
|||||||
return Boolean(this.metadata.readonly || this.metadata.disabled)
|
return Boolean(this.metadata.readonly || this.metadata.disabled)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async created() {
|
||||||
|
if (this.metadata.isSQLValue && (this.isEmptyValue(this.metadata.value) || this.metadata.value.isSQL || isNaN(this.metadata.value))) {
|
||||||
|
const value = await this.$store.dispatch('getValueBySQL', {
|
||||||
|
parentUuid: this.metadata.parentUuid,
|
||||||
|
containerUuid: this.metadata.containerUuid,
|
||||||
|
query: this.metadata.defaultValue
|
||||||
|
})
|
||||||
|
this.preHandleChange(value)
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
activeFocus() {
|
activeFocus() {
|
||||||
this.$refs[this.metadata.columnName].focus()
|
this.$refs[this.metadata.columnName].focus()
|
||||||
|
@ -16,8 +16,12 @@ const browser = {
|
|||||||
dictionaryResetCacheBrowser(state) {
|
dictionaryResetCacheBrowser(state) {
|
||||||
state.browser = []
|
state.browser = []
|
||||||
},
|
},
|
||||||
changeBrowser(state, payload) {
|
changeBrowserAttribute(state, payload) {
|
||||||
payload.browser = payload.newBrowser
|
let value = payload.attributeValue
|
||||||
|
if (payload.attributeNameControl) {
|
||||||
|
value = payload.browser[payload.attributeNameControl]
|
||||||
|
}
|
||||||
|
payload.browser[payload.attributeName] = value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -41,7 +45,8 @@ const browser = {
|
|||||||
|
|
||||||
// Convert from gRPC
|
// Convert from gRPC
|
||||||
const fieldsRangeList = []
|
const fieldsRangeList = []
|
||||||
let isMandatoryParams = false
|
let isShowedCriteria = false
|
||||||
|
let awaitForValues = 0
|
||||||
let fieldsList = browserResponse.fieldsList.map((fieldItem, index) => {
|
let fieldsList = browserResponse.fieldsList.map((fieldItem, index) => {
|
||||||
const someAttributes = {
|
const someAttributes = {
|
||||||
...additionalAttributes,
|
...additionalAttributes,
|
||||||
@ -65,24 +70,29 @@ const browser = {
|
|||||||
fieldsRangeList.push(fieldRange)
|
fieldsRangeList.push(fieldRange)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((query.includes(`@${field.columnName}@`) ||
|
|
||||||
query.includes(`@${field.columnName}_To@`) ||
|
|
||||||
whereClause.includes(`@${field.columnName}@`) ||
|
|
||||||
whereClause.includes(`@${field.columnName}_To@`)) &&
|
|
||||||
field.isQueryCriteria) {
|
|
||||||
field.isMandatory = true
|
|
||||||
field.isMandatoryFromLogic = true
|
|
||||||
field.isShowedFromUser = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only isQueryCriteria fields with values, displayed in main panel
|
// Only isQueryCriteria fields with values, displayed in main panel
|
||||||
if (field.isQueryCriteria) {
|
if (field.isQueryCriteria) {
|
||||||
|
if (field.isSQLValue) {
|
||||||
|
isShowedCriteria = true
|
||||||
|
field.isShowedFromUser = true
|
||||||
|
awaitForValues++
|
||||||
|
}
|
||||||
|
if (query.includes(`@${field.columnName}@`) ||
|
||||||
|
query.includes(`@${field.columnName}_To@`) ||
|
||||||
|
whereClause.includes(`@${field.columnName}@`) ||
|
||||||
|
whereClause.includes(`@${field.columnName}_To@`)) {
|
||||||
|
field.isMandatory = true
|
||||||
|
field.isMandatoryFromLogic = true
|
||||||
|
field.isShowedFromUser = true
|
||||||
|
}
|
||||||
|
|
||||||
if (isEmptyValue(field.value)) {
|
if (isEmptyValue(field.value)) {
|
||||||
// isMandatory params to showed search criteria
|
// isMandatory params to showed search criteria
|
||||||
if (field.isMandatory || field.isMandatoryFromLogic) {
|
if (field.isMandatory || field.isMandatoryFromLogic) {
|
||||||
isMandatoryParams = true
|
isShowedCriteria = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// with value
|
||||||
field.isShowedFromUser = true
|
field.isShowedFromUser = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +101,7 @@ const browser = {
|
|||||||
})
|
})
|
||||||
fieldsList = fieldsList.concat(fieldsRangeList)
|
fieldsList = fieldsList.concat(fieldsRangeList)
|
||||||
|
|
||||||
// Get dependent fields
|
// Get dependent fields
|
||||||
fieldsList
|
fieldsList
|
||||||
.forEach((field, index, list) => {
|
.forEach((field, index, list) => {
|
||||||
if (field.isActive && field.parentFieldsList.length) {
|
if (field.isActive && field.parentFieldsList.length) {
|
||||||
@ -106,7 +116,7 @@ const browser = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Convert from gRPC process list
|
// Convert from gRPC process list
|
||||||
const actions = []
|
const actions = []
|
||||||
if (process) {
|
if (process) {
|
||||||
actions.push({
|
actions.push({
|
||||||
@ -127,7 +137,7 @@ const browser = {
|
|||||||
// containerUuidAssociated: containerUuid
|
// containerUuidAssociated: containerUuid
|
||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
// Add process menu
|
// Add process menu
|
||||||
dispatch('setContextMenu', {
|
dispatch('setContextMenu', {
|
||||||
containerUuid,
|
containerUuid,
|
||||||
relations: [],
|
relations: [],
|
||||||
@ -135,14 +145,16 @@ const browser = {
|
|||||||
references: []
|
references: []
|
||||||
})
|
})
|
||||||
|
|
||||||
// Panel for save on store
|
// Panel for save on store
|
||||||
const newBrowser = {
|
const newBrowser = {
|
||||||
...browserResponse,
|
...browserResponse,
|
||||||
containerUuid,
|
containerUuid,
|
||||||
fieldList: fieldsList,
|
fieldList: fieldsList,
|
||||||
panelType,
|
panelType,
|
||||||
// app attributes
|
// app attributes
|
||||||
isShowedCriteria: Boolean(fieldsList.length && isMandatoryParams),
|
awaitForValues, // control to values
|
||||||
|
awaitForValuesToQuery: awaitForValues, // get values from request search
|
||||||
|
isShowedCriteria,
|
||||||
isShowedTotals: true
|
isShowedTotals: true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,16 +178,17 @@ const browser = {
|
|||||||
containerUuid,
|
containerUuid,
|
||||||
browser,
|
browser,
|
||||||
attributeName,
|
attributeName,
|
||||||
|
attributeNameControl,
|
||||||
attributeValue
|
attributeValue
|
||||||
}) {
|
}) {
|
||||||
if (isEmptyValue(browser)) {
|
if (isEmptyValue(browser)) {
|
||||||
browser = getters.getBrowser(containerUuid)
|
browser = getters.getBrowser(containerUuid)
|
||||||
}
|
}
|
||||||
const newBrowser = browser
|
commit('changeBrowserAttribute', {
|
||||||
newBrowser[attributeName] = attributeValue
|
|
||||||
commit('changeBrowser', {
|
|
||||||
browser,
|
browser,
|
||||||
newBrowser
|
attributeName,
|
||||||
|
attributeValue,
|
||||||
|
attributeNameControl
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -28,7 +28,7 @@ const browserControl = {
|
|||||||
|
|
||||||
const browser = rootGetters.getBrowser(containerUuid)
|
const browser = rootGetters.getBrowser(containerUuid)
|
||||||
// parameters isQueryCriteria
|
// parameters isQueryCriteria
|
||||||
const finalParameters = rootGetters.getParametersToServer({
|
const parametersList = rootGetters.getParametersToServer({
|
||||||
containerUuid,
|
containerUuid,
|
||||||
fieldList: browser.fieldList
|
fieldList: browser.fieldList
|
||||||
})
|
})
|
||||||
@ -62,7 +62,7 @@ const browserControl = {
|
|||||||
query: parsedQuery,
|
query: parsedQuery,
|
||||||
whereClause: parsedWhereClause,
|
whereClause: parsedWhereClause,
|
||||||
orderByClause: browser.orderByClause,
|
orderByClause: browser.orderByClause,
|
||||||
parameters: finalParameters,
|
parametersList,
|
||||||
nextPageToken: nextPageToken
|
nextPageToken: nextPageToken
|
||||||
})
|
})
|
||||||
.then(browserSearchResponse => {
|
.then(browserSearchResponse => {
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
unlockPrivateAccessFromServer
|
unlockPrivateAccessFromServer
|
||||||
} from '@/api/ADempiere/data'
|
} from '@/api/ADempiere/data'
|
||||||
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
||||||
|
import { parseContext } from '@/utils/ADempiere/contextUtils'
|
||||||
import { showMessage } from '@/utils/ADempiere/notification'
|
import { showMessage } from '@/utils/ADempiere/notification'
|
||||||
import language from '@/lang'
|
import language from '@/lang'
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ const data = {
|
|||||||
* @param {boolean} isPanelValues, define if used values form panel
|
* @param {boolean} isPanelValues, define if used values form panel
|
||||||
* @param {boolean} isEdit, define if used values form panel
|
* @param {boolean} isEdit, define if used values form panel
|
||||||
*/
|
*/
|
||||||
addNewRow({ commit, getters, rootGetters, dispatch }, {
|
async addNewRow({ commit, getters, rootGetters, dispatch }, {
|
||||||
parentUuid,
|
parentUuid,
|
||||||
containerUuid,
|
containerUuid,
|
||||||
isPanelValues = false,
|
isPanelValues = false,
|
||||||
@ -145,7 +146,9 @@ const data = {
|
|||||||
if (!isEmptyValue(currentNewRow)) {
|
if (!isEmptyValue(currentNewRow)) {
|
||||||
values = currentNewRow
|
values = currentNewRow
|
||||||
return values
|
return values
|
||||||
} if (isEmptyValue(row)) {
|
}
|
||||||
|
|
||||||
|
if (isEmptyValue(row)) {
|
||||||
const tabPanel = rootGetters.getPanel(containerUuid)
|
const tabPanel = rootGetters.getPanel(containerUuid)
|
||||||
|
|
||||||
if (isEmptyValue(fieldList)) {
|
if (isEmptyValue(fieldList)) {
|
||||||
@ -192,26 +195,28 @@ const data = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get display column
|
// get display column and/or sql value
|
||||||
if (fieldList.length) {
|
if (fieldList.length) {
|
||||||
fieldList
|
fieldList
|
||||||
// TODO: Evaluate if is field is read only and FieldSelect
|
// TODO: Evaluate if is field is read only and FieldSelect
|
||||||
.filter(itemField => itemField.componentPath === 'FieldSelect' || String(values[itemField.columnName]) === '[object Object]')
|
.filter(itemField => itemField.componentPath === 'FieldSelect' || String(values[itemField.columnName]) === '[object Object]' || itemField.isSQLValue)
|
||||||
.forEach(itemField => {
|
.map(async itemField => {
|
||||||
let valueGetDisplayColumn = values[itemField.columnName]
|
const { columnName, componentPath } = itemField
|
||||||
if (String(values[itemField.columnName]) === '[object Object]') {
|
let valueGetDisplayColumn = values[columnName]
|
||||||
if (itemField.componentPath === 'FieldSelect') {
|
|
||||||
values[itemField.columnName] = ' '
|
if (String(values[columnName]) === '[object Object]') {
|
||||||
values[`DisplayColumn_${itemField.columnName}`] = ' '
|
if (componentPath === 'FieldSelect') {
|
||||||
} else if (itemField.componentPath === 'FieldNumber') {
|
values[columnName] = ' '
|
||||||
values[itemField.columnName] = 0
|
values[`DisplayColumn_${columnName}`] = ' '
|
||||||
|
} else if (componentPath === 'FieldNumber') {
|
||||||
|
values[columnName] = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// overwrite value with column link
|
// overwrite value with column link
|
||||||
if (!isEmptyValue(linkColumnName) && linkColumnName === itemField.columnName) {
|
if (!isEmptyValue(linkColumnName) && linkColumnName === columnName) {
|
||||||
valueGetDisplayColumn = valueLink
|
valueGetDisplayColumn = valueLink
|
||||||
if (isEmptyValue(values[itemField.columnName])) {
|
if (isEmptyValue(values[columnName])) {
|
||||||
values[itemField.columnName] = valueGetDisplayColumn
|
values[columnName] = valueGetDisplayColumn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,29 +232,22 @@ const data = {
|
|||||||
valueGetDisplayColumn = parseInt(valueGetDisplayColumn, 10)
|
valueGetDisplayColumn = parseInt(valueGetDisplayColumn, 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmptyValue(valueGetDisplayColumn) && String(valueGetDisplayColumn) === '[object Object]' && valueGetDisplayColumn.isSQL) {
|
if (!isEmptyValue(valueGetDisplayColumn) && String(valueGetDisplayColumn) === '[object Object]' && valueGetDisplayColumn.isSQL) {
|
||||||
// get value from direct Query
|
// get value from Query
|
||||||
dispatch('getRecordBySQL', {
|
valueGetDisplayColumn = await dispatch('getValueBySQL', {
|
||||||
query: valueGetDisplayColumn.query,
|
parentUuid,
|
||||||
field: itemField
|
containerUuid,
|
||||||
|
query: itemField.defaultValue
|
||||||
})
|
})
|
||||||
.then(defaultValue => {
|
values[columnName] = valueGetDisplayColumn
|
||||||
if (itemField.componentPath === 'FieldSelect') {
|
}
|
||||||
values[itemField.columnName] = defaultValue.key
|
|
||||||
values[`DisplayColumn_${itemField.columnName}`] = defaultValue.label
|
// break to next itineration if not select field
|
||||||
} else {
|
if (componentPath !== 'FieldSelect') {
|
||||||
values[itemField.columnName] = defaultValue.key
|
|
||||||
dispatch('notifyRowTableChange', {
|
|
||||||
parentUuid,
|
|
||||||
containerUuid,
|
|
||||||
isNew,
|
|
||||||
isEdit,
|
|
||||||
row: values
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// get label (DisplayColumn) from vuex store
|
// get label (DisplayColumn) from vuex store
|
||||||
const options = rootGetters.getLookupAll({
|
const options = rootGetters.getLookupAll({
|
||||||
parentUuid,
|
parentUuid,
|
||||||
@ -263,41 +261,33 @@ const data = {
|
|||||||
const option = options.find(itemOption => itemOption.key === valueGetDisplayColumn)
|
const option = options.find(itemOption => itemOption.key === valueGetDisplayColumn)
|
||||||
// if there is a lookup option, assign the display column with the label
|
// if there is a lookup option, assign the display column with the label
|
||||||
if (option) {
|
if (option) {
|
||||||
values[`DisplayColumn_${itemField.columnName}`] = option.label
|
values[`DisplayColumn_${columnName}`] = option.label
|
||||||
if (isEmptyValue(option.label) && !itemField.isMandatory) {
|
// if (isEmptyValue(option.label) && !itemField.isMandatory) {
|
||||||
values[itemField.columnName] = undefined
|
// values[columnName] = undefined
|
||||||
}
|
// }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (linkColumnName === itemField.columnName) {
|
if (linkColumnName === columnName) {
|
||||||
// get context value if link column exists and does not exist in row
|
// get context value if link column exists and does not exist in row
|
||||||
const nameParent = rootGetters.getContext({
|
const nameParent = rootGetters.getContext({
|
||||||
parentUuid,
|
parentUuid,
|
||||||
containerUuid,
|
containerUuid,
|
||||||
columnName: 'Name'
|
columnName: 'Name'
|
||||||
})
|
})
|
||||||
if (nameParent) {
|
if (!isEmptyValue(nameParent)) {
|
||||||
values[`DisplayColumn_${itemField.columnName}`] = nameParent
|
values[`DisplayColumn_${columnName}`] = nameParent
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get from server
|
// get value to displayed from server
|
||||||
dispatch('getLookupItemFromServer', {
|
const { label } = await dispatch('getLookupItemFromServer', {
|
||||||
parentUuid,
|
parentUuid,
|
||||||
containerUuid,
|
containerUuid,
|
||||||
tableName: itemField.reference.tableName,
|
tableName: itemField.reference.tableName,
|
||||||
directQuery: itemField.reference.directQuery,
|
directQuery: itemField.reference.directQuery,
|
||||||
value: valueGetDisplayColumn
|
value: valueGetDisplayColumn
|
||||||
})
|
})
|
||||||
.then(responseLookup => {
|
values[`DisplayColumn_${columnName}`] = label
|
||||||
if (responseLookup) {
|
|
||||||
dispatch('addDisplayColumn', {
|
|
||||||
containerUuid,
|
|
||||||
columnName: itemField.columnName,
|
|
||||||
displayColumn: responseLookup.label
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,8 +304,17 @@ const data = {
|
|||||||
data: dataStore
|
data: dataStore
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addDisplayColumn({ commit, getters }, parameters) {
|
/**
|
||||||
const { containerUuid, columnName, displayColumn } = parameters
|
* Add or change display column in table of records
|
||||||
|
* @param {string} containerUuid
|
||||||
|
* @param {string} columnName
|
||||||
|
* @param {string} displayColumn
|
||||||
|
*/
|
||||||
|
addDisplayColumn({ commit, getters }, {
|
||||||
|
containerUuid,
|
||||||
|
columnName,
|
||||||
|
displayColumn
|
||||||
|
}) {
|
||||||
const dataStore = getters.getDataRecordsList(containerUuid)
|
const dataStore = getters.getDataRecordsList(containerUuid)
|
||||||
const rowRecord = dataStore.find(itemData => itemData.isNew)
|
const rowRecord = dataStore.find(itemData => itemData.isNew)
|
||||||
|
|
||||||
@ -393,13 +392,16 @@ const data = {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Set selection in data list associated in container
|
* Set selection in data list associated in container
|
||||||
* @param {string} parameters.containerUuid
|
* @param {string} containerUuid
|
||||||
* @param {string} parameters.selection
|
* @param {array} selection
|
||||||
*/
|
*/
|
||||||
setSelection({ commit, getters }, parameters) {
|
setSelection({ commit, getters }, {
|
||||||
const recordSelection = getters.getDataRecordAndSelection(parameters.containerUuid)
|
containerUuid,
|
||||||
|
selection = []
|
||||||
|
}) {
|
||||||
|
const recordSelection = getters.getDataRecordAndSelection(containerUuid)
|
||||||
commit('setSelection', {
|
commit('setSelection', {
|
||||||
newSelection: parameters.selection,
|
newSelection: selection,
|
||||||
data: recordSelection
|
data: recordSelection
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -608,40 +610,33 @@ const data = {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getRecordBySQL({ dispatch }, {
|
/**
|
||||||
query,
|
* @param {string} parentUuid
|
||||||
field
|
* @param {string} containerUuid
|
||||||
|
* @param {string} query
|
||||||
|
*/
|
||||||
|
getValueBySQL({ commit }, {
|
||||||
|
parentUuid,
|
||||||
|
containerUuid,
|
||||||
|
query
|
||||||
}) {
|
}) {
|
||||||
// TODO: Change to promise all
|
// TODO: Change to promise all
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise(resolve => {
|
||||||
|
if (query.includes('@')) {
|
||||||
|
query = parseContext({
|
||||||
|
parentUuid,
|
||||||
|
containerUuid,
|
||||||
|
isSQL: true,
|
||||||
|
value: query
|
||||||
|
}).query
|
||||||
|
}
|
||||||
|
|
||||||
getDefaultValueFromServer(query)
|
getDefaultValueFromServer(query)
|
||||||
.then(defaultValueResponse => {
|
.then(defaultValueResponse => {
|
||||||
const valueToReturn = {}
|
resolve(defaultValueResponse)
|
||||||
valueToReturn.key = defaultValueResponse
|
|
||||||
// add display Column for table
|
|
||||||
if (field.componentPath === 'FieldSelect') {
|
|
||||||
dispatch('getLookupItemFromServer', {
|
|
||||||
parentUuid: field.parentUuid,
|
|
||||||
containerUuid: field.containerUuid,
|
|
||||||
tableName: field.reference.tableName,
|
|
||||||
directQuery: field.reference.directQuery,
|
|
||||||
value: valueToReturn.key
|
|
||||||
})
|
|
||||||
.then(responseLookup => {
|
|
||||||
if (responseLookup) {
|
|
||||||
valueToReturn.label = responseLookup.label
|
|
||||||
dispatch('addDisplayColumn', {
|
|
||||||
containerUuid: field.containerUuid,
|
|
||||||
columnName: field.columnName,
|
|
||||||
displayColumn: responseLookup.label
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
resolve(valueToReturn)
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
reject(error)
|
console.warn(`Error getting default value from server. Error code ${error.code}: ${error.message}.`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -658,10 +658,33 @@ const panel = {
|
|||||||
} else if (!getters.isNotReadyForSubmit(containerUuid)) {
|
} else if (!getters.isNotReadyForSubmit(containerUuid)) {
|
||||||
// TODO: refactory for it and change for a standard method
|
// TODO: refactory for it and change for a standard method
|
||||||
if (field.panelType === 'browser' && fieldIsDisplayed(field)) {
|
if (field.panelType === 'browser' && fieldIsDisplayed(field)) {
|
||||||
dispatch('getBrowserSearch', {
|
let isReadyForQuery = true
|
||||||
containerUuid,
|
if (field.isSQLValue) {
|
||||||
isClearSelection: true
|
let awaitForValuesToQuery = panel.awaitForValuesToQuery
|
||||||
})
|
awaitForValuesToQuery--
|
||||||
|
dispatch('changeBrowserAttribute', {
|
||||||
|
containerUuid,
|
||||||
|
attributeName: 'awaitForValuesToQuery',
|
||||||
|
attributeValue: awaitForValuesToQuery
|
||||||
|
})
|
||||||
|
if (awaitForValuesToQuery === 0) {
|
||||||
|
if (panel.isShowedCriteria) {
|
||||||
|
dispatch('changeBrowserAttribute', {
|
||||||
|
containerUuid,
|
||||||
|
attributeName: 'isShowedCriteria',
|
||||||
|
attributeValue: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else if (awaitForValuesToQuery > 0) {
|
||||||
|
isReadyForQuery = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isReadyForQuery && !field.dependentFieldsList.length) {
|
||||||
|
dispatch('getBrowserSearch', {
|
||||||
|
containerUuid,
|
||||||
|
isClearSelection: true
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (field.panelType === 'window' && fieldIsDisplayed(field)) {
|
if (field.panelType === 'window' && fieldIsDisplayed(field)) {
|
||||||
const uuid = getters.getUuid(containerUuid)
|
const uuid = getters.getUuid(containerUuid)
|
||||||
@ -749,7 +772,7 @@ const panel = {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Iterate for change logic
|
// Iterate for change logic
|
||||||
dependentsList.forEach(fieldDependent => {
|
dependentsList.map(async fieldDependent => {
|
||||||
// isDisplayed Logic
|
// isDisplayed Logic
|
||||||
let isDisplayedFromLogic, isMandatoryFromLogic, isReadOnlyFromLogic, defaultValue
|
let isDisplayedFromLogic, isMandatoryFromLogic, isReadOnlyFromLogic, defaultValue
|
||||||
if (fieldDependent.displayLogic.trim() !== '') {
|
if (fieldDependent.displayLogic.trim() !== '') {
|
||||||
@ -780,30 +803,41 @@ const panel = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
// Default Value
|
// Default Value
|
||||||
if (fieldDependent.defaultValue.trim() !== '' &&
|
if (!isEmptyValue(fieldDependent.defaultValue) &&
|
||||||
fieldDependent.defaultValue.includes('@') &&
|
fieldDependent.defaultValue.includes('@') &&
|
||||||
String(fieldDependent.defaultValue).trim() !== '-1') {
|
!fieldDependent.defaultValue.includes('@SQL=')) {
|
||||||
defaultValue = parseContext({
|
defaultValue = parseContext({
|
||||||
parentUuid,
|
parentUuid,
|
||||||
containerUuid,
|
containerUuid,
|
||||||
value: fieldDependent.defaultValue
|
value: fieldDependent.defaultValue
|
||||||
}).value
|
}).value
|
||||||
if (isSendToServer && defaultValue !== fieldDependent.defaultValue) {
|
}
|
||||||
dispatch('getRecordBySQL', {
|
if (!isEmptyValue(fieldDependent.defaultValue) &&
|
||||||
field: fieldDependent,
|
fieldDependent.defaultValue.includes('@SQL=')) {
|
||||||
|
defaultValue = parseContext({
|
||||||
|
parentUuid,
|
||||||
|
containerUuid,
|
||||||
|
isSQL: true,
|
||||||
|
value: fieldDependent.defaultValue
|
||||||
|
}).query
|
||||||
|
if (defaultValue !== fieldDependent.parsedDefaultValue) {
|
||||||
|
const newValue = await dispatch('getValueBySQL', {
|
||||||
|
parentUuid,
|
||||||
|
containerUuid,
|
||||||
query: defaultValue
|
query: defaultValue
|
||||||
})
|
})
|
||||||
.then(response => {
|
|
||||||
dispatch('notifyFieldChange', {
|
dispatch('notifyFieldChange', {
|
||||||
parentUuid,
|
parentUuid,
|
||||||
containerUuid,
|
containerUuid,
|
||||||
panelType: fieldDependent.panelType,
|
isSendToServer,
|
||||||
columnName: fieldDependent.columnName,
|
panelType: fieldDependent.panelType,
|
||||||
newValue: response.key
|
columnName: fieldDependent.columnName,
|
||||||
})
|
newValue
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commit('changeFieldLogic', {
|
commit('changeFieldLogic', {
|
||||||
field: fieldDependent,
|
field: fieldDependent,
|
||||||
isDisplayedFromLogic,
|
isDisplayedFromLogic,
|
||||||
@ -1125,6 +1159,12 @@ const panel = {
|
|||||||
value: fieldItem.defaultValue,
|
value: fieldItem.defaultValue,
|
||||||
isSQL
|
isSQL
|
||||||
})
|
})
|
||||||
|
if (typeof valueToReturn === 'object') {
|
||||||
|
valueToReturn = {
|
||||||
|
...valueToReturn,
|
||||||
|
defaultValue: fieldItem.defaultValue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
valueToReturn = parsedValueComponent({
|
valueToReturn = parsedValueComponent({
|
||||||
|
@ -44,7 +44,9 @@ export function getParentFields({ displayLogic, mandatoryLogic, readOnlyLogic, d
|
|||||||
* @param {string} parentUuid: (REQUIRED from Window) UUID Window
|
* @param {string} parentUuid: (REQUIRED from Window) UUID Window
|
||||||
* @param {string} containerUuid: (REQUIRED) UUID Tab, Process, SmartBrowser, Report and Form
|
* @param {string} containerUuid: (REQUIRED) UUID Tab, Process, SmartBrowser, Report and Form
|
||||||
* @param {string} columnName: (Optional if exists in value) Column name to search in context
|
* @param {string} columnName: (Optional if exists in value) Column name to search in context
|
||||||
* @param {boolean} isBooleanToString, convert boolean values to string
|
* @param {boolean} isBooleanToString, convert boolean values to string ('Y' or 'N')
|
||||||
|
* @param {boolean} isSQL
|
||||||
|
* @param {boolean} isSOTrxMenu
|
||||||
*/
|
*/
|
||||||
export function parseContext({
|
export function parseContext({
|
||||||
parentUuid,
|
parentUuid,
|
||||||
@ -79,6 +81,12 @@ export function parseContext({
|
|||||||
let outString = ''
|
let outString = ''
|
||||||
|
|
||||||
let firstIndexTag = inString.indexOf('@')
|
let firstIndexTag = inString.indexOf('@')
|
||||||
|
const convertBooleanToString = (booleanValue) => {
|
||||||
|
if (booleanValue) {
|
||||||
|
return 'Y'
|
||||||
|
}
|
||||||
|
return 'N'
|
||||||
|
}
|
||||||
|
|
||||||
while (firstIndexTag !== -1) {
|
while (firstIndexTag !== -1) {
|
||||||
outString = outString + inString.substring(0, firstIndexTag) // up to @
|
outString = outString + inString.substring(0, firstIndexTag) // up to @
|
||||||
@ -103,12 +111,8 @@ export function parseContext({
|
|||||||
containerUuid,
|
containerUuid,
|
||||||
columnName
|
columnName
|
||||||
}) // get context
|
}) // get context
|
||||||
if (isBooleanToString && typeof contextInfo === 'boolean') {
|
if ((isBooleanToString || isSQL) && typeof contextInfo === 'boolean') {
|
||||||
if (contextInfo) {
|
contextInfo = convertBooleanToString(contextInfo)
|
||||||
contextInfo = 'Y'
|
|
||||||
} else {
|
|
||||||
contextInfo = 'N'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmptyValue(contextInfo) &&
|
if (isEmptyValue(contextInfo) &&
|
||||||
@ -120,6 +124,9 @@ export function parseContext({
|
|||||||
// menu attribute isEmptyValue isSOTrx
|
// menu attribute isEmptyValue isSOTrx
|
||||||
if (!isEmptyValue(isSOTrxMenu) && token === 'IsSOTrx' && isEmptyValue(contextInfo)) {
|
if (!isEmptyValue(isSOTrxMenu) && token === 'IsSOTrx' && isEmptyValue(contextInfo)) {
|
||||||
contextInfo = isSOTrxMenu
|
contextInfo = isSOTrxMenu
|
||||||
|
if (isBooleanToString || isSQL) {
|
||||||
|
contextInfo = convertBooleanToString(contextInfo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (contextInfo === undefined || contextInfo.length === 0) {
|
if (contextInfo === undefined || contextInfo.length === 0) {
|
||||||
console.info(`No Context for: ${token}`)
|
console.info(`No Context for: ${token}`)
|
||||||
@ -141,16 +148,18 @@ export function parseContext({
|
|||||||
}
|
}
|
||||||
if (isSQL) {
|
if (isSQL) {
|
||||||
return {
|
return {
|
||||||
|
errorsList,
|
||||||
|
isError,
|
||||||
|
isSQL,
|
||||||
query: outString,
|
query: outString,
|
||||||
value: contextInfo,
|
value: contextInfo
|
||||||
isSQL
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
value: outString,
|
|
||||||
isError,
|
|
||||||
errorsList,
|
errorsList,
|
||||||
isSQL
|
isError,
|
||||||
|
isSQL,
|
||||||
|
value: outString
|
||||||
}
|
}
|
||||||
} // parseContext
|
} // parseContext
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ export function generateField({
|
|||||||
isSOTrxMenu
|
isSOTrxMenu
|
||||||
}) {
|
}) {
|
||||||
let isShowedFromUser = false
|
let isShowedFromUser = false
|
||||||
|
let isSQLValue = false
|
||||||
// verify if it no overwrite value with ...moreAttributes
|
// verify if it no overwrite value with ...moreAttributes
|
||||||
if (moreAttributes.isShowedFromUser) {
|
if (moreAttributes.isShowedFromUser) {
|
||||||
isShowedFromUser = moreAttributes.isShowedFromUser
|
isShowedFromUser = moreAttributes.isShowedFromUser
|
||||||
@ -74,6 +75,11 @@ export function generateField({
|
|||||||
isMandatory: fieldToGenerate.isMandatory
|
isMandatory: fieldToGenerate.isMandatory
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (String(fieldToGenerate.defaultValue).includes('@SQL=')) {
|
||||||
|
isShowedFromUser = true
|
||||||
|
isSQLValue = true
|
||||||
|
}
|
||||||
|
|
||||||
// VALUE TO
|
// VALUE TO
|
||||||
if (String(parsedDefaultValueTo).includes('@') &&
|
if (String(parsedDefaultValueTo).includes('@') &&
|
||||||
String(parsedDefaultValueTo).trim() !== '-1') {
|
String(parsedDefaultValueTo).trim() !== '-1') {
|
||||||
@ -115,6 +121,7 @@ export function generateField({
|
|||||||
const field = {
|
const field = {
|
||||||
...fieldToGenerate,
|
...fieldToGenerate,
|
||||||
...moreAttributes,
|
...moreAttributes,
|
||||||
|
isSOTrxMenu,
|
||||||
// displayed attributes
|
// displayed attributes
|
||||||
componentPath: componentReference.type,
|
componentPath: componentReference.type,
|
||||||
isSupport: componentReference.support,
|
isSupport: componentReference.support,
|
||||||
@ -138,6 +145,7 @@ export function generateField({
|
|||||||
isShowedFromUser,
|
isShowedFromUser,
|
||||||
isShowedTableFromUser: fieldToGenerate.isDisplayed,
|
isShowedTableFromUser: fieldToGenerate.isDisplayed,
|
||||||
isFixedTableColumn: false,
|
isFixedTableColumn: false,
|
||||||
|
isSQLValue,
|
||||||
// Advanced query
|
// Advanced query
|
||||||
operator, // current operator
|
operator, // current operator
|
||||||
oldOperator: undefined, // old operator
|
oldOperator: undefined, // old operator
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { convertValueFromGRPC } from '@/api/ADempiere/data'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if value is empty. Deep-checks arrays and objects
|
* Checks if value is empty. Deep-checks arrays and objects
|
||||||
* Note: isEmpty([]) == true, isEmpty({}) == true,
|
* Note: isEmpty([]) == true, isEmpty({}) == true,
|
||||||
@ -10,7 +8,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 || String(value).trim() === '-1') {
|
} else if (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)
|
||||||
@ -137,41 +135,6 @@ export function convertArrayPairsToObject({
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertValuesMapToObject(map) {
|
|
||||||
var objectConverted = {}
|
|
||||||
map.forEach((value, key) => {
|
|
||||||
var valueResult = map.get(key)
|
|
||||||
var tempValue
|
|
||||||
if (valueResult) {
|
|
||||||
tempValue = convertValueFromGRPC(value)
|
|
||||||
}
|
|
||||||
objectConverted[key] = tempValue
|
|
||||||
})
|
|
||||||
return objectConverted
|
|
||||||
}
|
|
||||||
|
|
||||||
export function convertMapToArrayPairs({
|
|
||||||
toConvert,
|
|
||||||
nameKey = 'columnName',
|
|
||||||
nameValue = 'value',
|
|
||||||
isGRPC = true
|
|
||||||
}) {
|
|
||||||
const result = []
|
|
||||||
if (toConvert) {
|
|
||||||
toConvert.forEach((value, key) => {
|
|
||||||
const element = {}
|
|
||||||
element[nameKey] = key
|
|
||||||
element[nameValue] = value
|
|
||||||
if (isGRPC) {
|
|
||||||
element[nameValue] = convertValueFromGRPC(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
result.push(element)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
export function convertHasMapToObject(hasMapToConvert) {
|
export function convertHasMapToObject(hasMapToConvert) {
|
||||||
const result = {}
|
const result = {}
|
||||||
hasMapToConvert.forEach((value, key) => {
|
hasMapToConvert.forEach((value, key) => {
|
||||||
|
@ -112,7 +112,7 @@ export default {
|
|||||||
return this.$store.getters.getDataRecordsList(this.browserUuid)
|
return this.$store.getters.getDataRecordsList(this.browserUuid)
|
||||||
},
|
},
|
||||||
getContainerIsReadyForSubmit() {
|
getContainerIsReadyForSubmit() {
|
||||||
return !this.$store.getters.isNotReadyForSubmit(this.browserUuid)
|
return !this.$store.getters.isNotReadyForSubmit(this.browserUuid) && !this.browserMetadata.awaitForValuesToQuery
|
||||||
},
|
},
|
||||||
isMobile() {
|
isMobile() {
|
||||||
return this.$store.state.app.device === 'mobile'
|
return this.$store.state.app.device === 'mobile'
|
||||||
@ -128,6 +128,21 @@ export default {
|
|||||||
return 'content-help-mobile'
|
return 'content-help-mobile'
|
||||||
}
|
}
|
||||||
return 'content-help'
|
return 'content-help'
|
||||||
|
},
|
||||||
|
isShowedCriteria() {
|
||||||
|
if (this.getterBrowser) {
|
||||||
|
return this.getterBrowser.isShowedCriteria
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isShowedCriteria(value) {
|
||||||
|
const activeSearch = []
|
||||||
|
if (value) {
|
||||||
|
activeSearch.push('opened-criteria')
|
||||||
|
}
|
||||||
|
this.activeSearch = activeSearch
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user