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