mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-09-25 15:00:00 +08:00
redefine API to provide dictionary metadata. (#197)
* Migrate Smart Browser, Process, and Field. * Migrate Window and Tabs.
This commit is contained in:
parent
7372a21308
commit
992908ad72
@ -13,19 +13,36 @@ function Instance() {
|
||||
}
|
||||
|
||||
export function getWindow(uuid, childrenTabs = true) {
|
||||
return Instance.call(this).requestWindow(uuid, childrenTabs)
|
||||
return Instance.call(this).requestWindow({
|
||||
uuid: uuid,
|
||||
isWithTabs: childrenTabs,
|
||||
isConvertedMetadata: true
|
||||
})
|
||||
}
|
||||
|
||||
export function getProcess(uuid) {
|
||||
return Instance.call(this).requestProcess(uuid)
|
||||
export function getProcess(uuid, isConvert = true) {
|
||||
return Instance.call(this).requestProcess({
|
||||
uuid: uuid,
|
||||
isConvertedMetadata: isConvert,
|
||||
isConvertedFields: true
|
||||
})
|
||||
}
|
||||
|
||||
export function getBrowser(uuid) {
|
||||
return Instance.call(this).requestBrowser(uuid)
|
||||
export function getBrowser(uuid, isConvert = true) {
|
||||
return Instance.call(this).requestBrowser({
|
||||
uuid: uuid,
|
||||
isConvertedMetadata: isConvert,
|
||||
isConvertedFields: true
|
||||
})
|
||||
}
|
||||
|
||||
export function getTab(uuid, childrenFields = true) {
|
||||
return Instance.call(this).requestTab(uuid, childrenFields)
|
||||
export function getTab(uuid, childrenFields = true, isConvert = true) {
|
||||
return Instance.call(this).requestTab({
|
||||
uuid: uuid,
|
||||
isWithFields: childrenFields,
|
||||
isConvertedMetadata: isConvert,
|
||||
isConvertedFields: true
|
||||
})
|
||||
}
|
||||
|
||||
export function getField(uuid) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { showNotification } from '@/utils/ADempiere/notification'
|
||||
import Item from './items'
|
||||
import { convertFieldListToShareLink } from '@/utils/ADempiere/valueUtil'
|
||||
import { convertFieldListToShareLink } from '@/utils/ADempiere/valueUtils'
|
||||
import { supportedTypes, exportFileFromJson } from '@/utils/ADempiere/exportUtil'
|
||||
import ROUTES from '@/utils/ADempiere/zoomWindow'
|
||||
|
||||
|
@ -1079,8 +1079,8 @@ export default {
|
||||
},
|
||||
getFieldDefinition(fieldDefinition, row) {
|
||||
var styleSheet = ''
|
||||
if (fieldDefinition && (fieldDefinition.id !== null || fieldDefinition.conditions.length)) {
|
||||
fieldDefinition.conditions.forEach(condition => {
|
||||
if (fieldDefinition && (fieldDefinition.id !== null || fieldDefinition.conditionsList.length)) {
|
||||
fieldDefinition.conditionsList.forEach(condition => {
|
||||
var columns = evaluator.parseDepends(condition.condition)
|
||||
var conditionLogic = condition.condition
|
||||
columns.forEach(column => {
|
||||
|
@ -7,6 +7,7 @@
|
||||
<el-col
|
||||
v-if="!inTable"
|
||||
v-show="isDisplayed()"
|
||||
key="panel-template"
|
||||
:xs="sizeFieldResponsive.xs"
|
||||
:sm="sizeFieldResponsive.sm"
|
||||
:md="sizeFieldResponsive.md"
|
||||
@ -57,6 +58,7 @@
|
||||
<component
|
||||
:is="componentRender"
|
||||
v-else
|
||||
key="table-template"
|
||||
:class="classField"
|
||||
:metadata="{
|
||||
...field,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { parseContext } from '@/utils/ADempiere'
|
||||
import { parseContext } from '@/utils/ADempiere/contextUtils'
|
||||
|
||||
export const tabMixin = {
|
||||
props: {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { getBrowser as getBrowserMetadata } from '@/api/ADempiere/dictionary'
|
||||
import { convertField, isEmptyValue, showMessage } from '@/utils/ADempiere'
|
||||
import { isEmptyValue, showMessage } from '@/utils/ADempiere'
|
||||
import { generateField } from '@/utils/ADempiere/dictionaryUtils'
|
||||
import router from '@/router'
|
||||
import language from '@/lang'
|
||||
const browser = {
|
||||
@ -18,33 +19,36 @@ const browser = {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
getBrowserFromServer({ commit, dispatch }, parameters) {
|
||||
getBrowserFromServer({ commit, dispatch }, {
|
||||
containerUuid,
|
||||
routeToDelete
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var browserUuid = parameters.containerUuid
|
||||
getBrowserMetadata(browserUuid)
|
||||
.then(response => {
|
||||
getBrowserMetadata(containerUuid)
|
||||
.then(browserResponse => {
|
||||
const panelType = 'browser'
|
||||
const query = response.getQuery()
|
||||
const whereClause = response.getWhereclause()
|
||||
const additionalAttributes = {
|
||||
browserUuid: response.getUuid(),
|
||||
browserId: response.getId(),
|
||||
containerUuid: response.getUuid(),
|
||||
containerUuid: browserResponse.uuid,
|
||||
panelType: panelType
|
||||
}
|
||||
const {
|
||||
query,
|
||||
whereClause,
|
||||
process
|
||||
} = browserResponse
|
||||
|
||||
// Convert from gRPC
|
||||
const fieldsRangeList = []
|
||||
var isMandatoryParams = false
|
||||
var fieldsList = response.getFieldsList().map((fieldItem, index) => {
|
||||
let isMandatoryParams = false
|
||||
let fieldsList = browserResponse.fieldsList.map((fieldItem, index) => {
|
||||
const someAttributes = {
|
||||
...additionalAttributes,
|
||||
fieldListIndex: index
|
||||
}
|
||||
const field = convertField(fieldItem, someAttributes)
|
||||
const field = generateField(fieldItem, someAttributes)
|
||||
// Add new field if is range number
|
||||
if (field.isRange && field.componentPath === 'FieldNumber') {
|
||||
const fieldRange = convertField(fieldItem, someAttributes, true)
|
||||
const fieldRange = generateField(fieldItem, someAttributes, true)
|
||||
if (!isEmptyValue(fieldRange.value)) {
|
||||
fieldRange.isShowedFromUser = true
|
||||
}
|
||||
@ -88,26 +92,8 @@ const browser = {
|
||||
|
||||
// Panel for save on store
|
||||
const newBrowser = {
|
||||
id: response.getId(),
|
||||
uuid: response.getUuid(),
|
||||
containerUuid: response.getUuid(),
|
||||
value: response.getValue(),
|
||||
name: response.getName(),
|
||||
description: response.getDescription(),
|
||||
help: response.getHelp(),
|
||||
// sql query
|
||||
query: query,
|
||||
whereClause: whereClause,
|
||||
orderByClause: response.getOrderbyclause(),
|
||||
//
|
||||
isUpdateable: response.getIsupdateable(),
|
||||
isDeleteable: response.getIsdeleteable(),
|
||||
isSelectedByDefault: response.getIsselectedbydefault(),
|
||||
isCollapsibleByDefault: response.getIscollapsiblebydefault(),
|
||||
isExecutedQueryByDefault: response.getIsexecutedquerybydefault(),
|
||||
isShowTotal: response.getIsshowtotal(),
|
||||
isActive: response.getIsactive(),
|
||||
viewUuid: response.getViewuuid(),
|
||||
...browserResponse,
|
||||
containerUuid: browserResponse.uuid,
|
||||
fieldList: fieldsList,
|
||||
panelType: panelType,
|
||||
// app attributes
|
||||
@ -116,27 +102,21 @@ const browser = {
|
||||
isShowedTotals: true
|
||||
}
|
||||
// Convert from gRPC process list
|
||||
const process = response.getProcess()
|
||||
var actions = []
|
||||
const actions = []
|
||||
if (process) {
|
||||
actions.push({
|
||||
name: process.getName(),
|
||||
type: 'process',
|
||||
uuid: process.getUuid(),
|
||||
description: process.getDescription(),
|
||||
help: process.getHelp(),
|
||||
isReport: process.getIsreport(),
|
||||
accessLevel: process.getAccesslevel(),
|
||||
showHelp: process.getShowhelp(),
|
||||
isDirectPrint: process.getIsdirectprint()
|
||||
uuid: process.uuid,
|
||||
name: process.name,
|
||||
description: process.description,
|
||||
isReport: process.isReport,
|
||||
isDirectPrint: process.isDirectPrint
|
||||
})
|
||||
// add process associated in vuex store
|
||||
dispatch('addProcessAssociated', {
|
||||
processToGenerate: process,
|
||||
containerUuidAssociated: newBrowser.uuid
|
||||
})
|
||||
|
||||
// TODO: convert gRPC attributes from response.getProcess() to object
|
||||
// Add process asociate in store
|
||||
// var processStore = rootGetters.getProcess(process.getUuid())
|
||||
// if (processStore === undefined) {
|
||||
// dispatch('getProcessFromServer', process.getUuid())
|
||||
// }
|
||||
}
|
||||
|
||||
dispatch('addPanel', newBrowser)
|
||||
@ -144,7 +124,7 @@ const browser = {
|
||||
|
||||
// Add process menu
|
||||
dispatch('setContextMenu', {
|
||||
containerUuid: response.getUuid(),
|
||||
containerUuid: browserResponse.uuid,
|
||||
relations: [],
|
||||
actions: actions,
|
||||
references: []
|
||||
@ -153,17 +133,20 @@ const browser = {
|
||||
})
|
||||
.catch(error => {
|
||||
router.push({ path: '/dashboard' })
|
||||
dispatch('tagsView/delView', parameters.routeToDelete)
|
||||
dispatch('tagsView/delView', routeToDelete)
|
||||
showMessage({
|
||||
message: language.t('login.unexpectedError'),
|
||||
type: 'error'
|
||||
})
|
||||
console.warn('Dictionary Browser - Error ' + error.code + ': ' + error.message)
|
||||
console.warn(`Dictionary Browser - Error ${error.code}: ${error.message}`)
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
changeShowedCriteriaBrowser({ commit, getters }, { containerUuid, isShowedCriteria }) {
|
||||
changeShowedCriteriaBrowser({ commit, getters }, {
|
||||
containerUuid,
|
||||
isShowedCriteria
|
||||
}) {
|
||||
commit('changeShowedCriteriaBrowser', {
|
||||
browser: getters.getBrowser(containerUuid),
|
||||
isShowedCriteria: isShowedCriteria
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
// Delete when get global context and account context
|
||||
import { isEmptyValue } from '@/utils/ADempiere/valueUtil.js'
|
||||
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
|
||||
|
||||
const context = {
|
||||
state: {
|
||||
|
@ -13,7 +13,9 @@ import {
|
||||
getPendingDocumentsFromServer,
|
||||
requestPrintFormats
|
||||
} from '@/api/ADempiere'
|
||||
import { convertValuesMapToObject, isEmptyValue, showMessage, convertAction } from '@/utils/ADempiere'
|
||||
import { convertValuesMapToObject, isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
||||
import { showMessage } from '@/utils/ADempiere/notification'
|
||||
import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
|
||||
import language from '@/lang'
|
||||
|
||||
const data = {
|
||||
@ -611,9 +613,10 @@ const data = {
|
||||
getRecentItems()
|
||||
.then(response => {
|
||||
const recentItems = response.getRecentitemsList().map(item => {
|
||||
const actionConverted = convertAction(item.getAction())
|
||||
return {
|
||||
action: convertAction(item.getAction()).name,
|
||||
icon: convertAction(item.getAction()).icon,
|
||||
action: actionConverted.name,
|
||||
icon: actionConverted.icon,
|
||||
displayName: item.getDisplayname(),
|
||||
menuUuid: item.getMenuuuid(),
|
||||
menuName: item.getMenuname(),
|
||||
@ -640,13 +643,14 @@ const data = {
|
||||
getFavoritesFromServer(userUuid)
|
||||
.then(response => {
|
||||
const favorites = response.getFavoritesList().map(favorite => {
|
||||
const actionConverted = convertAction(favorite.getAction())
|
||||
return {
|
||||
uuid: favorite.getMenuuuid(),
|
||||
name: favorite.getMenuname(),
|
||||
description: favorite.getMenudescription(),
|
||||
referenceUuid: favorite.getReferenceuuid(),
|
||||
action: convertAction(favorite.getAction()).name,
|
||||
icon: convertAction(favorite.getAction()).icon
|
||||
action: actionConverted.name,
|
||||
icon: actionConverted.icon
|
||||
}
|
||||
})
|
||||
commit('setFavorites', favorites)
|
||||
|
@ -5,7 +5,10 @@
|
||||
// - Window: Just need storage tab and fields
|
||||
// - Process & Report: Always save a panel and parameters
|
||||
// - Smart Browser: Can have a search panel, table panel and process panel
|
||||
import evaluator, { assignedGroup, fieldIsDisplayed, isEmptyValue, parseContext, parsedValueComponent, showMessage } from '@/utils/ADempiere'
|
||||
import { isEmptyValue, parsedValueComponent } from '@/utils/ADempiere/valueUtils'
|
||||
import evaluator, { parseContext } from '@/utils/ADempiere/contextUtils'
|
||||
import { showMessage } from '@/utils/ADempiere/notification'
|
||||
import { assignedGroup, fieldIsDisplayed } from '@/utils/ADempiere/dictionaryUtils'
|
||||
import router from '@/router'
|
||||
import language from '@/lang'
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { getProcess as getProcessMetadata } from '@/api/ADempiere'
|
||||
import { convertField, isEmptyValue, showMessage } from '@/utils/ADempiere'
|
||||
import { showMessage } from '@/utils/ADempiere'
|
||||
import { generateProcess } from '@/utils/ADempiere/dictionaryUtils'
|
||||
import language from '@/lang'
|
||||
import router from '@/router'
|
||||
|
||||
@ -16,160 +17,27 @@ const process = {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
getProcessFromServer: ({ commit, dispatch }, parameters) => {
|
||||
/**
|
||||
*
|
||||
* @param {string} containerUuid
|
||||
* @param {object} routeToDelete, route to close in tagView when fail
|
||||
*/
|
||||
getProcessFromServer({ commit, dispatch }, {
|
||||
containerUuid,
|
||||
routeToDelete
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var processUuid = parameters.containerUuid
|
||||
getProcessMetadata(processUuid)
|
||||
.then(response => {
|
||||
let panelType = 'process'
|
||||
if (response.getIsreport()) {
|
||||
panelType = 'report'
|
||||
}
|
||||
|
||||
const additionalAttributes = {
|
||||
processUuid: response.getUuid(),
|
||||
processId: response.getId(),
|
||||
containerUuid: response.getUuid(),
|
||||
panelType: panelType
|
||||
}
|
||||
|
||||
// Convert from gRPC
|
||||
const fieldsRangeList = []
|
||||
var fieldDefinitionList = response.getParametersList().map((fieldItem, index) => {
|
||||
const someAttributes = {
|
||||
...additionalAttributes,
|
||||
fieldListIndex: index
|
||||
}
|
||||
const field = convertField(fieldItem, someAttributes)
|
||||
// Add new field if is range number
|
||||
if (field.isRange && field.componentPath === 'FieldNumber') {
|
||||
const fieldRange = convertField(fieldItem, someAttributes, true)
|
||||
if (!isEmptyValue(fieldRange.value)) {
|
||||
fieldRange.isShowedFromUser = true
|
||||
}
|
||||
fieldsRangeList.push(fieldRange)
|
||||
}
|
||||
|
||||
// if field with value displayed in main panel
|
||||
if (!isEmptyValue(field.value)) {
|
||||
field.isShowedFromUser = true
|
||||
}
|
||||
|
||||
return field
|
||||
getProcessMetadata(containerUuid)
|
||||
.then(responseProcess => {
|
||||
const { processDefinition, actions } = generateProcess({
|
||||
processToGenerate: responseProcess
|
||||
})
|
||||
fieldDefinitionList = fieldDefinitionList.concat(fieldsRangeList)
|
||||
|
||||
// Get dependent fields
|
||||
fieldDefinitionList
|
||||
.filter(field => field.parentFieldsList && field.isActive)
|
||||
.forEach((field, index, list) => {
|
||||
field.parentFieldsList.forEach(parentColumnName => {
|
||||
var parentField = list.find(parentField => {
|
||||
return parentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
||||
})
|
||||
if (parentField) {
|
||||
parentField.dependentFieldsList.push(field.columnName)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// Get export list
|
||||
var reportExportTypeList = response.getReportexporttypesList().map(reportType => {
|
||||
return {
|
||||
name: reportType.getName(),
|
||||
description: reportType.getDescription(),
|
||||
reportExportType: reportType.getType()
|
||||
}
|
||||
})
|
||||
// Default Action
|
||||
var actions = []
|
||||
actions.push({
|
||||
name: language.t('components.RunProcess'),
|
||||
processName: response.getName(),
|
||||
type: 'action',
|
||||
action: 'startProcess',
|
||||
uuid: response.getUuid(),
|
||||
id: response.getId(),
|
||||
description: response.getDescription(),
|
||||
help: response.getHelp(),
|
||||
isReport: response.getIsreport(),
|
||||
accessLevel: response.getAccesslevel(),
|
||||
showHelp: response.getShowhelp(),
|
||||
isDirectPrint: response.getIsdirectprint(),
|
||||
reportExportType: undefined
|
||||
}, {
|
||||
name: language.t('components.ChangeParameters'),
|
||||
processName: response.getName(),
|
||||
type: 'process',
|
||||
action: 'changeParameters',
|
||||
uuid: response.getUuid(),
|
||||
id: response.getId(),
|
||||
description: response.description,
|
||||
help: response.getHelp(),
|
||||
isReport: response.getIsreport(),
|
||||
accessLevel: response.getAccesslevel(),
|
||||
showHelp: response.getShowhelp(),
|
||||
isDirectPrint: response.getIsdirectprint()
|
||||
})
|
||||
|
||||
var summaryAction = {
|
||||
name: language.t('components.RunProcessAs'),
|
||||
processName: response.getName(),
|
||||
type: 'summary',
|
||||
action: '',
|
||||
childs: [],
|
||||
uuid: response.getUuid(),
|
||||
id: response.getId(),
|
||||
description: response.getDescription(),
|
||||
help: response.getHelp(),
|
||||
isReport: response.getIsreport(),
|
||||
accessLevel: response.getAccesslevel(),
|
||||
showHelp: response.getShowhelp(),
|
||||
isDirectPrint: response.getIsdirectprint()
|
||||
}
|
||||
reportExportTypeList.forEach(actionValue => {
|
||||
// Push values
|
||||
summaryAction.childs.push({
|
||||
name: language.t('components.ExportTo') + ' (' + actionValue.name + ')',
|
||||
processName: response.getName(),
|
||||
type: 'action',
|
||||
action: 'startProcess',
|
||||
uuid: response.getUuid(),
|
||||
id: response.getId(),
|
||||
description: actionValue.description,
|
||||
help: response.getHelp(),
|
||||
isReport: response.getIsreport(),
|
||||
accessLevel: response.getAccesslevel(),
|
||||
showHelp: response.getShowhelp(),
|
||||
isDirectPrint: response.getIsdirectprint(),
|
||||
reportExportType: actionValue.reportExportType
|
||||
})
|
||||
})
|
||||
// Add summary Actions
|
||||
actions.push(summaryAction)
|
||||
|
||||
var processDefinition = {
|
||||
id: response.getId(),
|
||||
uuid: response.getUuid(),
|
||||
name: response.getName(),
|
||||
description: response.getDescription(),
|
||||
help: response.getHelp(),
|
||||
isReport: response.getIsreport(),
|
||||
accessLevel: response.getAccesslevel(),
|
||||
showHelp: response.getShowhelp(),
|
||||
isDirectPrint: response.getIsdirectprint(),
|
||||
reportExportTypeList: reportExportTypeList,
|
||||
value: response.getValue(),
|
||||
panelType: panelType,
|
||||
fieldList: fieldDefinitionList
|
||||
}
|
||||
|
||||
dispatch('addPanel', processDefinition)
|
||||
commit('addProcess', processDefinition)
|
||||
|
||||
// Add process menu
|
||||
dispatch('setContextMenu', {
|
||||
containerUuid: response.getUuid(),
|
||||
containerUuid: processDefinition.uuid,
|
||||
relations: [],
|
||||
actions: actions,
|
||||
references: []
|
||||
@ -178,15 +46,41 @@ const process = {
|
||||
})
|
||||
.catch(error => {
|
||||
router.push({ path: '/dashboard' })
|
||||
dispatch('tagsView/delView', parameters.routeToDelete)
|
||||
dispatch('tagsView/delView', routeToDelete)
|
||||
showMessage({
|
||||
message: language.t('login.unexpectedError'),
|
||||
type: 'error'
|
||||
})
|
||||
console.warn('Dictionary Process (State) - Error ' + error)
|
||||
console.warn(`Dictionary Process (State) - Error ${error.message}`)
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* Add process associated in window or smart browser
|
||||
* @param {object} processToGenerate
|
||||
*/
|
||||
addProcessAssociated({ commit, dispatch }, {
|
||||
processToGenerate
|
||||
}) {
|
||||
return new Promise(resolve => {
|
||||
const { processDefinition, actions } = generateProcess({
|
||||
processToGenerate: processToGenerate
|
||||
})
|
||||
|
||||
dispatch('addPanel', processDefinition)
|
||||
commit('addProcess', processDefinition)
|
||||
|
||||
// Add process menu
|
||||
dispatch('setContextMenu', {
|
||||
containerUuid: processDefinition.uuid,
|
||||
relations: [],
|
||||
actions: actions,
|
||||
references: []
|
||||
})
|
||||
|
||||
resolve(processDefinition)
|
||||
})
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
|
@ -2,9 +2,10 @@ import {
|
||||
getWindow as getWindowMetadata,
|
||||
getTab as getTabMetadata
|
||||
} from '@/api/ADempiere/dictionary'
|
||||
import { convertContextInfoFromGRPC, convertField, getFieldTemplate, showMessage } from '@/utils/ADempiere'
|
||||
import { showMessage } from '@/utils/ADempiere'
|
||||
import language from '@/lang'
|
||||
import router from '@/router'
|
||||
import { generateField, getFieldTemplate } from '@/utils/ADempiere/dictionaryUtils'
|
||||
|
||||
const window = {
|
||||
state: {
|
||||
@ -34,89 +35,44 @@ const window = {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
getWindowFromServer({ commit, state, dispatch }, params) {
|
||||
return getWindowMetadata(params.windowUuid)
|
||||
.then(response => {
|
||||
var newWindow = {
|
||||
id: response.getId(),
|
||||
uuid: params.windowUuid,
|
||||
name: response.getName(),
|
||||
contextInfo: convertContextInfoFromGRPC(response.getContextinfo()),
|
||||
windowType: response.getWindowtype(),
|
||||
isShowedRecordNavigation: undefined,
|
||||
firstTabUuid: response.getTabsList()[0].getUuid()
|
||||
}
|
||||
var tabs = response.getTabsList()
|
||||
const firstTab = tabs[0].getTablename()
|
||||
var childrenTabs = []
|
||||
var parentTabs = []
|
||||
getWindowFromServer({ commit, state, dispatch }, {
|
||||
windowUuid,
|
||||
routeToDelete
|
||||
}) {
|
||||
return getWindowMetadata(windowUuid)
|
||||
.then(responseWindow => {
|
||||
const firstTab = responseWindow.tabsList[0].tableName
|
||||
const firstTabUuid = responseWindow.tabsList[0].uuid
|
||||
const childrenTabs = []
|
||||
const parentTabs = []
|
||||
|
||||
tabs = tabs.map((tabItem, index) => {
|
||||
var group = {
|
||||
groupName: '',
|
||||
groupType: ''
|
||||
}
|
||||
if (tabItem.getFieldgroup()) {
|
||||
group.groupName = tabItem.getFieldgroup().getName()
|
||||
group.groupType = tabItem.getFieldgroup().getFieldgrouptype()
|
||||
}
|
||||
|
||||
var tab = {
|
||||
id: tabItem.getId(),
|
||||
uuid: tabItem.getUuid(),
|
||||
containerUuid: tabItem.getUuid(),
|
||||
parentUuid: params.windowUuid,
|
||||
windowUuid: params.windowUuid,
|
||||
name: tabItem.getName(),
|
||||
tabGroup: group,
|
||||
firstTabUuid: newWindow.firstTabUuid,
|
||||
//
|
||||
displayLogic: tabItem.getDisplaylogic(),
|
||||
isView: tabItem.getIsview(),
|
||||
isDocument: tabItem.getIsdocument(),
|
||||
isInsertRecord: tabItem.getIsinsertrecord(),
|
||||
isSortTab: tabItem.getIssorttab(), // Tab type Order Tab
|
||||
const tabs = responseWindow.tabsList.map((tabItem, index) => {
|
||||
// let tab = tabItem
|
||||
const tab = {
|
||||
...tabItem,
|
||||
containerUuid: tabItem.uuid,
|
||||
parentUuid: windowUuid,
|
||||
windowUuid: windowUuid,
|
||||
tabGroup: tabItem.fieldGroup,
|
||||
firstTabUuid: firstTabUuid,
|
||||
// relations
|
||||
isParentTab: Boolean(firstTab === tabItem.getTablename()),
|
||||
sequence: tabItem.getSequence(),
|
||||
tabLevel: tabItem.getTablevel(),
|
||||
parentTabUuid: tabItem.getParenttabuuid(),
|
||||
linkColumnName: tabItem.getLinkcolumnname(),
|
||||
parentColumnName: tabItem.getParentcolumnname(),
|
||||
//
|
||||
contextInfo: convertContextInfoFromGRPC(tabItem.getContextinfo()),
|
||||
isAdvancedTab: tabItem.getIsadvancedtab(),
|
||||
isHasTree: tabItem.getIshastree(),
|
||||
isInfoTab: tabItem.getIsinfotab(),
|
||||
isTranslationTab: tabItem.getIstranslationtab(),
|
||||
isReadOnly: tabItem.getIsreadonly(),
|
||||
isDeleteable: tabItem.getIsdeleteable(),
|
||||
accessLevel: tabItem.getAccesslevel(),
|
||||
isSingleRow: tabItem.getIssinglerow(),
|
||||
// conditionals
|
||||
commitWarning: tabItem.getCommitwarning(),
|
||||
// query db
|
||||
tableName: tabItem.getTablename(),
|
||||
query: tabItem.getQuery(),
|
||||
whereClause: tabItem.getWhereclause(),
|
||||
orderByClause: tabItem.getOrderbyclause(),
|
||||
isChangeLog: tabItem.getIschangelog(),
|
||||
isParentTab: Boolean(firstTab === tabItem.tableName),
|
||||
// app properties
|
||||
isShowedRecordNavigation: !(tabItem.getIssinglerow()),
|
||||
isShowedRecordNavigation: !(tabItem.isSingleRow),
|
||||
isLoadFieldList: false,
|
||||
index: index
|
||||
}
|
||||
delete tab.processesList
|
||||
|
||||
// Convert from gRPC process list
|
||||
// action is dispatch used in vuex
|
||||
var actions = []
|
||||
let actions = []
|
||||
actions.push({
|
||||
// action to set default values and enable fields not isUpdateable
|
||||
name: language.t('window.newRecord'),
|
||||
processName: language.t('window.newRecord'),
|
||||
type: 'dataAction',
|
||||
action: 'resetPanelToNew',
|
||||
uuidParent: newWindow.uuid,
|
||||
uuidParent: responseWindow,
|
||||
disabled: !tab.isInsertRecord || tab.isReadOnly
|
||||
}, {
|
||||
// action to delete record selected
|
||||
@ -124,7 +80,7 @@ const window = {
|
||||
processName: language.t('window.deleteRecord'),
|
||||
type: 'dataAction',
|
||||
action: 'deleteEntity',
|
||||
uuidParent: newWindow.uuid,
|
||||
uuidParent: responseWindow,
|
||||
disabled: tab.isReadOnly
|
||||
}, {
|
||||
// action to undo create, update, delete record
|
||||
@ -132,10 +88,9 @@ const window = {
|
||||
processName: language.t('data.undo'),
|
||||
type: 'dataAction',
|
||||
action: 'undoModifyData',
|
||||
uuidParent: newWindow.uuid,
|
||||
uuidParent: responseWindow,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
}, {
|
||||
name: language.t('data.lockRecord'),
|
||||
processName: language.t('data.lockRecord'),
|
||||
type: 'dataAction',
|
||||
@ -144,8 +99,7 @@ const window = {
|
||||
hidden: true,
|
||||
tableName: '',
|
||||
recordId: null
|
||||
},
|
||||
{
|
||||
}, {
|
||||
name: language.t('data.unlockRecord'),
|
||||
processName: language.t('data.unlockRecord'),
|
||||
type: 'dataAction',
|
||||
@ -155,21 +109,27 @@ const window = {
|
||||
tableName: '',
|
||||
recordId: null
|
||||
})
|
||||
const processList = tabItem.getProcessesList().map(processItem => {
|
||||
return {
|
||||
name: processItem.getName(),
|
||||
type: 'process',
|
||||
uuid: processItem.getUuid(),
|
||||
description: processItem.getDescription(),
|
||||
help: processItem.getHelp(),
|
||||
isReport: processItem.getIsreport(),
|
||||
accessLevel: processItem.getAccesslevel(),
|
||||
showHelp: processItem.getShowhelp(),
|
||||
isDirectPrint: processItem.getIsdirectprint()
|
||||
}
|
||||
})
|
||||
actions = actions.concat(processList)
|
||||
|
||||
// get processess associated in tab
|
||||
if (tabItem.processesList && tabItem.processesList.length) {
|
||||
const processList = tabItem.processesList.map(processItem => {
|
||||
dispatch('addProcessAssociated', {
|
||||
processToGenerate: processItem,
|
||||
containerUuidAssociated: tabItem.uuid
|
||||
})
|
||||
return {
|
||||
id: processItem.id,
|
||||
uuid: processItem.uuid,
|
||||
name: processItem.name,
|
||||
type: 'process',
|
||||
description: processItem.description,
|
||||
help: processItem.help,
|
||||
isReport: processItem.isReport,
|
||||
isDirectPrint: processItem.isDirectPrint
|
||||
}
|
||||
})
|
||||
actions = actions.concat(processList)
|
||||
}
|
||||
// Add process menu
|
||||
dispatch('setContextMenu', {
|
||||
containerUuid: tab.uuid,
|
||||
@ -191,7 +151,7 @@ const window = {
|
||||
return !(itemTab.isSortTab || itemTab.isTranslationTab)
|
||||
})
|
||||
|
||||
var tabProperties = {
|
||||
const tabProperties = {
|
||||
tabsList: tabs,
|
||||
currentTab: parentTabs[0],
|
||||
tabsListParent: parentTabs,
|
||||
@ -201,9 +161,11 @@ const window = {
|
||||
currentTabUuid: parentTabs[0].uuid
|
||||
}
|
||||
|
||||
newWindow = {
|
||||
...newWindow,
|
||||
const newWindow = {
|
||||
...responseWindow,
|
||||
...tabProperties,
|
||||
isShowedRecordNavigation: undefined,
|
||||
firstTabUuid: firstTabUuid,
|
||||
windowIndex: state.windowIndex + 1
|
||||
}
|
||||
commit('addWindow', newWindow)
|
||||
@ -211,12 +173,12 @@ const window = {
|
||||
})
|
||||
.catch(error => {
|
||||
router.push({ path: '/dashboard' })
|
||||
dispatch('tagsView/delView', params.routeToDelete)
|
||||
dispatch('tagsView/delView', routeToDelete)
|
||||
showMessage({
|
||||
message: language.t('login.unexpectedError'),
|
||||
type: 'error'
|
||||
})
|
||||
console.warn('Dictionary Window (State Window) - Error ' + error.code + ': ' + error.message)
|
||||
console.warn(`Dictionary Window (State Window) - Error ${error.code}: ${error.message}`)
|
||||
})
|
||||
},
|
||||
getTabAndFieldFromServer({ dispatch, getters }, {
|
||||
@ -226,36 +188,35 @@ const window = {
|
||||
isAdvancedQuery = false
|
||||
}) {
|
||||
return getTabMetadata(containerUuid)
|
||||
.then(response => {
|
||||
var fieldsList = response.getFieldsList()
|
||||
.then(tabResponse => {
|
||||
const additionalAttributes = {
|
||||
parentUuid: parentUuid,
|
||||
containerUuid: containerUuid,
|
||||
isShowedFromUser: true,
|
||||
panelType: panelType,
|
||||
tableName: response.getTablename(),
|
||||
tableName: tabResponse.tableName,
|
||||
//
|
||||
isReadOnlyFromForm: false,
|
||||
isAdvancedQuery: isAdvancedQuery
|
||||
}
|
||||
|
||||
var fieldUuidsequence = 0
|
||||
var fieldLinkColumnName
|
||||
let fieldUuidsequence = 0
|
||||
let fieldLinkColumnName
|
||||
// Convert from gRPC
|
||||
fieldsList = fieldsList.map((item, index) => {
|
||||
item = convertField(item, {
|
||||
const fieldsList = tabResponse.fieldsList.map((fieldItem, index) => {
|
||||
fieldItem = generateField(fieldItem, {
|
||||
...additionalAttributes,
|
||||
fieldListIndex: index
|
||||
})
|
||||
if (item.sequence > fieldUuidsequence) {
|
||||
fieldUuidsequence = item.sequence
|
||||
if (fieldItem.sequence > fieldUuidsequence) {
|
||||
fieldUuidsequence = fieldItem.sequence
|
||||
}
|
||||
|
||||
if (item.isParent) {
|
||||
fieldLinkColumnName = item.columnName
|
||||
if (fieldItem.isParent) {
|
||||
fieldLinkColumnName = fieldItem.columnName
|
||||
}
|
||||
|
||||
return item
|
||||
return fieldItem
|
||||
})
|
||||
|
||||
// Get dependent fields
|
||||
@ -273,7 +234,7 @@ const window = {
|
||||
})
|
||||
|
||||
if (!fieldsList.find(field => field.columnName === 'UUID')) {
|
||||
var attributesOverwrite = {
|
||||
const attributesOverwrite = {
|
||||
panelType: panelType,
|
||||
sequence: (fieldUuidsequence + 10),
|
||||
name: 'UUID',
|
||||
@ -281,7 +242,7 @@ const window = {
|
||||
isAdvancedQuery: isAdvancedQuery,
|
||||
componentPath: 'FieldText'
|
||||
}
|
||||
var field = getFieldTemplate(attributesOverwrite)
|
||||
const field = getFieldTemplate(attributesOverwrite)
|
||||
fieldsList.push(field)
|
||||
}
|
||||
|
||||
@ -308,11 +269,11 @@ const window = {
|
||||
message: language.t('login.unexpectedError'),
|
||||
type: 'error'
|
||||
})
|
||||
console.warn('Dictionary Tab (State Window) - Error ' + error.code + ': ' + error.message)
|
||||
console.warn(`Dictionary Tab (State Window) - Error ${error.code}: ${error.message}`)
|
||||
})
|
||||
},
|
||||
changeShowedDetailWindow: ({ commit, state }, params) => {
|
||||
var window = state.window.find(itemWindow => {
|
||||
const window = state.window.find(itemWindow => {
|
||||
return itemWindow.uuid === params.containerUuid
|
||||
})
|
||||
commit('changeShowedDetailWindow', {
|
||||
@ -321,7 +282,7 @@ const window = {
|
||||
})
|
||||
},
|
||||
changeShowedRecordWindow: ({ commit, state }, params) => {
|
||||
var window = state.window.find(itemWindow => {
|
||||
const window = state.window.find(itemWindow => {
|
||||
return itemWindow.uuid === params.parentUuid
|
||||
})
|
||||
commit('changeShowedRecordWindow', {
|
||||
|
124
src/utils/ADempiere/contextUtils.js
Normal file
124
src/utils/ADempiere/contextUtils.js
Normal file
@ -0,0 +1,124 @@
|
||||
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
||||
import evaluator from '@/utils/ADempiere/evaluator'
|
||||
|
||||
export default evaluator
|
||||
|
||||
/**
|
||||
* Extracts the associated fields from the logics or default values
|
||||
* @param {string} displayLogic
|
||||
* @param {string} mandatoryLogic
|
||||
* @param {string} readOnlyLogic
|
||||
* @param {string} defaultValue
|
||||
*/
|
||||
export function getParentFields({ displayLogic, mandatoryLogic, readOnlyLogic, defaultValue }) {
|
||||
let parentFields = []
|
||||
// For Display logic
|
||||
if (displayLogic) {
|
||||
parentFields = Array.from(new Set([
|
||||
...parentFields,
|
||||
...evaluator.parseDepends(displayLogic)
|
||||
]))
|
||||
}
|
||||
// For Mandatory Logic
|
||||
if (mandatoryLogic) {
|
||||
parentFields = Array.from(new Set([
|
||||
...parentFields,
|
||||
...evaluator.parseDepends(mandatoryLogic)
|
||||
]))
|
||||
}
|
||||
// For Read Only Logic
|
||||
if (readOnlyLogic) {
|
||||
parentFields = Array.from(new Set([
|
||||
...parentFields,
|
||||
...evaluator.parseDepends(readOnlyLogic)
|
||||
]))
|
||||
}
|
||||
// For Default Value
|
||||
if (defaultValue) {
|
||||
parentFields = Array.from(new Set([
|
||||
...parentFields,
|
||||
...evaluator.parseDepends(defaultValue)
|
||||
]))
|
||||
}
|
||||
return parentFields
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Context String
|
||||
* @param {object} context
|
||||
* - value: (REQUIRED) String to parsing
|
||||
* - parentUuid: (REQUIRED from Window) UUID Window
|
||||
* - containerUuid: (REQUIRED) UUID Tab, Process, SmartBrowser, Report and Form
|
||||
* - columnName: (Optional if exists in value) Column name to search in context
|
||||
* @param {boolean} isBoolToString, convert boolean values to string
|
||||
*/
|
||||
export function parseContext(context, isBoolToString = false) {
|
||||
const store = require('@/store')
|
||||
var value = String(context.value)
|
||||
var valueSQL = {}
|
||||
if (isEmptyValue(value)) {
|
||||
return ''
|
||||
}
|
||||
if (value.includes('@SQL=')) {
|
||||
value = value.replace('@SQL=', '')
|
||||
}
|
||||
// var instances = value.length - value.replace('@', '').length
|
||||
// if ((instances > 0) && (instances % 2) !== 0) { // could be an email address
|
||||
// return value
|
||||
// }
|
||||
|
||||
var token
|
||||
var inStr = value
|
||||
var outStr = ''
|
||||
|
||||
var i = inStr.indexOf('@')
|
||||
|
||||
while (i !== -1) {
|
||||
outStr = outStr + inStr.substring(0, i) // up to @
|
||||
inStr = inStr.substring(i + 1, inStr.length) // from first @
|
||||
var j = inStr.indexOf('@') // next @
|
||||
if (j < 0) {
|
||||
console.log('No second tag: ' + inStr)
|
||||
return '' // no second tag
|
||||
}
|
||||
|
||||
token = inStr.substring(0, j)
|
||||
context.columnName = token
|
||||
|
||||
var ctxInfo = store.default.getters.getContext(context) // get context
|
||||
if (isBoolToString && typeof ctxInfo === 'boolean') {
|
||||
if (ctxInfo) {
|
||||
ctxInfo = 'Y'
|
||||
} else {
|
||||
ctxInfo = 'N'
|
||||
}
|
||||
}
|
||||
|
||||
if ((ctxInfo === undefined || ctxInfo.length === 0) && (token.startsWith('#') || token.startsWith('$'))) {
|
||||
context.parentUuid = undefined
|
||||
context.containerUuid = undefined
|
||||
ctxInfo = store.default.getters.getContext(context) // get global context
|
||||
}
|
||||
if (ctxInfo === undefined || ctxInfo.length === 0) {
|
||||
console.info('No Context for: ' + token)
|
||||
} else {
|
||||
if (typeof ctxInfo === 'object') {
|
||||
outStr = ctxInfo
|
||||
} else {
|
||||
outStr = outStr + ctxInfo // replace context with Context
|
||||
}
|
||||
}
|
||||
|
||||
inStr = inStr.substring(j + 1, inStr.length) // from second @
|
||||
i = inStr.indexOf('@')
|
||||
}
|
||||
if (typeof ctxInfo !== 'object') {
|
||||
outStr = outStr + inStr // add the rest of the string
|
||||
}
|
||||
if (context.isSQL) {
|
||||
valueSQL['query'] = outStr
|
||||
valueSQL['value'] = ctxInfo
|
||||
return valueSQL
|
||||
}
|
||||
return outStr
|
||||
} // parseContext
|
494
src/utils/ADempiere/dictionaryUtils.js
Normal file
494
src/utils/ADempiere/dictionaryUtils.js
Normal file
@ -0,0 +1,494 @@
|
||||
import evaluator from '@/utils/ADempiere/evaluator'
|
||||
import { isEmptyValue, parsedValueComponent } from '@/utils/ADempiere/valueUtils'
|
||||
import { getParentFields, parseContext } from '@/utils/ADempiere/contextUtils'
|
||||
import REFERENCES, { FIELD_NOT_SHOWED } from '@/components/ADempiere/Field/references'
|
||||
import { FIELD_DISPLAY_SIZES, DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
|
||||
import language from '@/lang'
|
||||
|
||||
/**
|
||||
* Generate field to app
|
||||
* @param {object} fieldToGenerate
|
||||
* @param {object} moreAttributes, additional attributes
|
||||
* @param {boolean} typeRange, indicate if this field is a range used as _To
|
||||
*/
|
||||
export function generateField(fieldToGenerate, moreAttributes, typeRange = false) {
|
||||
let isShowedFromUser = false
|
||||
// verify if it no overwrite value with ...moreAttributes
|
||||
if (moreAttributes.isShowedFromUser) {
|
||||
isShowedFromUser = moreAttributes.isShowedFromUser
|
||||
}
|
||||
|
||||
const componentReference = evalutateTypeField(fieldToGenerate.displayType, true)
|
||||
|
||||
let parsedDefaultValue = fieldToGenerate.defaultValue
|
||||
if (String(parsedDefaultValue).includes('@')) {
|
||||
if (String(parsedDefaultValue).includes('@SQL=')) {
|
||||
parsedDefaultValue.replace('@SQL=', '')
|
||||
}
|
||||
parsedDefaultValue = parseContext({
|
||||
...moreAttributes,
|
||||
columnName: fieldToGenerate.columnName,
|
||||
value: parsedDefaultValue
|
||||
})
|
||||
}
|
||||
parsedDefaultValue = parsedValueComponent({
|
||||
fieldType: componentReference.type,
|
||||
value: parsedDefaultValue,
|
||||
referenceType: componentReference.alias[0],
|
||||
isMandatory: fieldToGenerate.isMandatory
|
||||
})
|
||||
|
||||
let parsedDefaultValueTo = fieldToGenerate.defaultValueTo
|
||||
if (String(parsedDefaultValueTo).includes('@')) {
|
||||
parsedDefaultValueTo = parseContext({
|
||||
...moreAttributes,
|
||||
columnName: fieldToGenerate.columnName,
|
||||
value: fieldToGenerate.defaultValueTo
|
||||
})
|
||||
}
|
||||
parsedDefaultValueTo = parsedValueComponent({
|
||||
fieldType: componentReference.type,
|
||||
value: parsedDefaultValueTo,
|
||||
referenceType: componentReference.alias[0],
|
||||
isMandatory: fieldToGenerate.isMandatory
|
||||
})
|
||||
fieldToGenerate.reference.zoomWindowList = fieldToGenerate.reference.windowsList
|
||||
const field = {
|
||||
...fieldToGenerate,
|
||||
...moreAttributes,
|
||||
// displayed attributes
|
||||
componentPath: componentReference.type,
|
||||
isSupport: componentReference.support,
|
||||
referenceType: componentReference.alias[0],
|
||||
displayColumn: undefined, // link to value from selects and table
|
||||
// value attributes
|
||||
value: String(parsedDefaultValue).trim() === '' ? undefined : parsedDefaultValue,
|
||||
oldValue: parsedDefaultValue,
|
||||
valueTo: parsedDefaultValueTo,
|
||||
parsedDefaultValue: parsedDefaultValue,
|
||||
parsedDefaultValueTo: parsedDefaultValueTo,
|
||||
// logics to app
|
||||
isDisplayedFromLogic: fieldToGenerate.isDisplayed,
|
||||
isReadOnlyFromLogic: undefined,
|
||||
isMandatoryFromLogic: undefined,
|
||||
//
|
||||
parentFieldsList: getParentFields(fieldToGenerate),
|
||||
dependentFieldsList: [],
|
||||
// TODO: Add support on server
|
||||
// app attributes
|
||||
isShowedFromUser: isShowedFromUser,
|
||||
isShowedTableFromUser: fieldToGenerate.isDisplayed,
|
||||
isFixedTableColumn: false
|
||||
}
|
||||
|
||||
// evaluate simple logics without context
|
||||
if (field.displayLogic.trim() !== '' && !field.displayLogic.includes('@')) {
|
||||
field.isDisplayedFromLogic = evaluator.evaluateLogic({
|
||||
type: 'displayed',
|
||||
logic: field.displayLogic
|
||||
})
|
||||
}
|
||||
if (field.mandatoryLogic.trim() !== '' && !field.mandatoryLogic.includes('@')) {
|
||||
field.isMandatoryFromLogic = evaluator.evaluateLogic({
|
||||
logic: field.mandatoryLogic
|
||||
})
|
||||
}
|
||||
if (field.readOnlyLogic.trim() !== '' && !field.readOnlyLogic.includes('@')) {
|
||||
field.isReadOnlyFromLogic = evaluator.evaluateLogic({
|
||||
logic: field.readOnlyLogic
|
||||
})
|
||||
}
|
||||
|
||||
// Sizes from panel and groups
|
||||
field.sizeFieldFromType = FIELD_DISPLAY_SIZES.find(item => {
|
||||
return item.type === field.componentPath
|
||||
})
|
||||
if (field.sizeFieldFromType === undefined) {
|
||||
console.warn(`Field size no found: ${field.name} type: ${field.componentPath}`)
|
||||
field.sizeFieldFromType = {
|
||||
type: field.componentPath,
|
||||
size: DEFAULT_SIZE
|
||||
}
|
||||
}
|
||||
|
||||
// Overwrite some values
|
||||
if (typeRange) {
|
||||
field.uuid = `${field.uuid}_To`
|
||||
field.columnName = `${field.columnName}_To`
|
||||
field.name = `${field.name} To`
|
||||
field.value = parsedDefaultValueTo
|
||||
field.defaultValue = field.defaultValueTo
|
||||
field.parsedDefaultValue = field.parsedDefaultValueTo
|
||||
}
|
||||
|
||||
// hidden field type button
|
||||
const notShowedField = FIELD_NOT_SHOWED.find(itemField => {
|
||||
if (field.displayType === itemField.id) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (notShowedField) {
|
||||
field.isDisplayedFromLogic = false
|
||||
field.isDisplayed = false
|
||||
}
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the actions and the associated process to store in the vuex store,
|
||||
* avoiding additional requests
|
||||
* @param {object} processToGenerate
|
||||
* @returns {object}
|
||||
*/
|
||||
export function generateProcess({ processToGenerate, containerUuidAssociated = undefined }) {
|
||||
const panelType = processToGenerate.isReport ? 'report' : 'process'
|
||||
const additionalAttributes = {
|
||||
processUuid: processToGenerate.uuid,
|
||||
processId: processToGenerate.id,
|
||||
processName: processToGenerate.name,
|
||||
containerUuid: processToGenerate.uuid,
|
||||
panelType: panelType
|
||||
}
|
||||
|
||||
// Convert from gRPC
|
||||
const fieldsRangeList = []
|
||||
let fieldDefinitionList = processToGenerate.parametersList
|
||||
.map(fieldItem => {
|
||||
const field = generateField(fieldItem, additionalAttributes)
|
||||
// Add new field if is range number
|
||||
if (field.isRange && field.componentPath === 'FieldNumber') {
|
||||
const fieldRange = generateField(fieldItem, additionalAttributes, true)
|
||||
if (!isEmptyValue(fieldRange.value)) {
|
||||
fieldRange.isShowedFromUser = true
|
||||
}
|
||||
fieldsRangeList.push(fieldRange)
|
||||
}
|
||||
|
||||
// if field with value displayed in main panel
|
||||
if (!isEmptyValue(field.value)) {
|
||||
field.isShowedFromUser = true
|
||||
}
|
||||
|
||||
return field
|
||||
})
|
||||
fieldDefinitionList = fieldDefinitionList.concat(fieldsRangeList)
|
||||
|
||||
// Get dependent fields
|
||||
fieldDefinitionList
|
||||
.filter(field => field.parentFieldsList && field.isActive)
|
||||
.forEach((field, index, list) => {
|
||||
field.parentFieldsList.forEach(parentColumnName => {
|
||||
var parentField = list.find(parentField => {
|
||||
return parentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
||||
})
|
||||
if (parentField) {
|
||||
parentField.dependentFieldsList.push(field.columnName)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// Default Action
|
||||
const actions = []
|
||||
actions.push({
|
||||
name: language.t('components.RunProcess'),
|
||||
processName: processToGenerate.name,
|
||||
type: 'action',
|
||||
action: 'startProcess',
|
||||
uuid: processToGenerate.uuid,
|
||||
id: processToGenerate.id,
|
||||
description: processToGenerate.description,
|
||||
isReport: processToGenerate.isReport,
|
||||
isDirectPrint: processToGenerate.isDirectPrint,
|
||||
reportExportType: undefined
|
||||
}, {
|
||||
name: language.t('components.ChangeParameters'),
|
||||
processName: processToGenerate.name,
|
||||
type: 'process',
|
||||
action: 'changeParameters',
|
||||
uuid: processToGenerate.uuid,
|
||||
id: processToGenerate.id,
|
||||
description: processToGenerate.description,
|
||||
isReport: processToGenerate.isReport,
|
||||
isDirectPrint: processToGenerate.isDirectPrint
|
||||
})
|
||||
|
||||
const summaryAction = {
|
||||
name: language.t('components.RunProcessAs'),
|
||||
processName: processToGenerate.name,
|
||||
type: 'summary',
|
||||
action: '',
|
||||
childs: [],
|
||||
uuid: processToGenerate.uuid,
|
||||
id: processToGenerate.id,
|
||||
description: processToGenerate.description,
|
||||
isReport: processToGenerate.isReport,
|
||||
isDirectPrint: processToGenerate.isDirectPrint
|
||||
}
|
||||
processToGenerate.reportExportTypeList.forEach(actionValue => {
|
||||
// Push values
|
||||
summaryAction.childs.push({
|
||||
name: `${language.t('components.ExportTo')} (${actionValue.name})`,
|
||||
processName: processToGenerate.name,
|
||||
type: 'action',
|
||||
action: 'startProcess',
|
||||
uuid: processToGenerate.uuid,
|
||||
id: processToGenerate.id,
|
||||
description: actionValue.description,
|
||||
isReport: processToGenerate.isReport,
|
||||
isDirectPrint: processToGenerate.isDirectPrint,
|
||||
reportExportType: actionValue.reportExportType
|
||||
})
|
||||
})
|
||||
// Add summary Actions
|
||||
actions.push(summaryAction)
|
||||
|
||||
const processDefinition = {
|
||||
...processToGenerate,
|
||||
panelType: panelType,
|
||||
isAssociated: Boolean(containerUuidAssociated),
|
||||
containerUuidAssociated: containerUuidAssociated,
|
||||
fieldList: fieldDefinitionList
|
||||
}
|
||||
|
||||
return {
|
||||
processDefinition: processDefinition,
|
||||
actions: actions
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate by the ID and name of the reference to call the component type
|
||||
* @param {integer} displayTypeId, received from data
|
||||
* @param {boolean} isAllInfo
|
||||
* @return string type, assigned value to folder after evaluating the parameter
|
||||
*/
|
||||
export function evalutateTypeField(displayTypeId, isAllInfo = false) {
|
||||
var component = REFERENCES.find(reference => displayTypeId === reference.id)
|
||||
if (isAllInfo) {
|
||||
return component
|
||||
}
|
||||
return component.type
|
||||
}
|
||||
|
||||
// Default template for injected fields
|
||||
export function getFieldTemplate(attributesOverwrite) {
|
||||
const referenceValue = {
|
||||
tableName: '',
|
||||
keyColumnName: '',
|
||||
displayColumnName: '',
|
||||
query: '',
|
||||
parsedQuery: '',
|
||||
directQuery: '',
|
||||
parsedDirectQuery: '',
|
||||
validationCode: '',
|
||||
windowsList: [],
|
||||
zoomWindowList: []
|
||||
}
|
||||
const newField = {
|
||||
id: 0,
|
||||
uuid: '',
|
||||
name: '',
|
||||
description: '',
|
||||
help: '',
|
||||
columnName: '',
|
||||
fieldGroup: {
|
||||
name: '',
|
||||
fieldGroupType: ''
|
||||
},
|
||||
displayType: 10,
|
||||
componentPath: 'FieldButton',
|
||||
referenceType: 'Button',
|
||||
isFieldOnly: false,
|
||||
isRange: false,
|
||||
isSameLine: false,
|
||||
sequence: 0,
|
||||
seqNoGrid: 0,
|
||||
isIdentifier: 0,
|
||||
isKey: false,
|
||||
isSelectionColumn: false,
|
||||
isUpdateable: true,
|
||||
formatPattern: undefined,
|
||||
VFormat: undefined,
|
||||
value: undefined,
|
||||
valueTo: undefined,
|
||||
defaultValue: undefined,
|
||||
parsedDefaultValue: undefined,
|
||||
defaultValueTo: undefined,
|
||||
parsedDefaultValueTo: undefined,
|
||||
valueMin: undefined,
|
||||
valueMax: undefined,
|
||||
//
|
||||
isDisplayed: false,
|
||||
isActive: true,
|
||||
isMandatory: false,
|
||||
isReadOnly: false,
|
||||
isDisplayedFromLogic: false,
|
||||
isReadOnlyFromLogic: false,
|
||||
isMandatoryFromLogic: false,
|
||||
// browser attributes
|
||||
callout: undefined,
|
||||
isQueryCriteria: false,
|
||||
displayLogic: undefined,
|
||||
mandatoryLogic: undefined,
|
||||
readOnlyLogic: undefined,
|
||||
parentFieldsList: undefined,
|
||||
dependentFieldsList: [],
|
||||
reference: referenceValue,
|
||||
contextInfo: undefined,
|
||||
isShowedFromUser: false,
|
||||
isFixedTableColumn: false,
|
||||
sizeFieldFromType: {
|
||||
type: 'Button',
|
||||
size: DEFAULT_SIZE
|
||||
}
|
||||
}
|
||||
return Object.assign(newField, attributesOverwrite)
|
||||
}
|
||||
|
||||
/**
|
||||
* [assignedGroup]
|
||||
* @param {array} fieldList Field of List with
|
||||
* @return {array} fieldList
|
||||
*/
|
||||
export function assignedGroup(fieldList, assignedGroup) {
|
||||
if (fieldList === undefined || fieldList.length <= 0) {
|
||||
return fieldList
|
||||
}
|
||||
fieldList = sortFields(fieldList, 'sequence', 'asc', fieldList[0].panelType)
|
||||
|
||||
let firstChangeGroup = false
|
||||
let currentGroup = ''
|
||||
let typeGroup = ''
|
||||
|
||||
fieldList.forEach(fieldElement => {
|
||||
if (fieldElement.panelType !== 'window') {
|
||||
fieldElement.groupAssigned = ''
|
||||
fieldElement.typeGroupAssigned = ''
|
||||
return
|
||||
}
|
||||
|
||||
// change the first field group, change the band
|
||||
if (!firstChangeGroup) {
|
||||
if (!isEmptyValue(fieldElement.fieldGroup.name) &&
|
||||
currentGroup !== fieldElement.fieldGroup.name &&
|
||||
fieldElement.isDisplayed) {
|
||||
firstChangeGroup = true
|
||||
}
|
||||
}
|
||||
// if you change the field group for the first time and it is different
|
||||
// from 0, updates the field group, since it is another field group and
|
||||
// assigns the following field items to the current field group whose
|
||||
// field group is '' or null
|
||||
if (firstChangeGroup) {
|
||||
if (!isEmptyValue(fieldElement.fieldGroup.name)) {
|
||||
currentGroup = fieldElement.fieldGroup.name
|
||||
typeGroup = fieldElement.fieldGroup.fieldGroupType
|
||||
}
|
||||
}
|
||||
|
||||
fieldElement.groupAssigned = currentGroup
|
||||
fieldElement.typeGroupAssigned = typeGroup
|
||||
|
||||
if (assignedGroup !== undefined) {
|
||||
fieldElement.groupAssigned = assignedGroup
|
||||
}
|
||||
})
|
||||
|
||||
return fieldList
|
||||
}
|
||||
|
||||
/**
|
||||
* Order the fields, then assign the groups to each field, and finally group
|
||||
* in an array according to each field group to show in panel (or table).
|
||||
* @param {array} arr
|
||||
* @param {string} orderBy
|
||||
* @param {string} type
|
||||
* @param {string} panelType
|
||||
* @returns {array}
|
||||
*/
|
||||
export function sortFields(arr, orderBy = 'sequence', type = 'asc', panelType = 'window') {
|
||||
if (panelType === 'browser') {
|
||||
orderBy = 'seqNoGrid'
|
||||
}
|
||||
arr.sort((itemA, itemB) => {
|
||||
return itemA[orderBy] - itemB[orderBy]
|
||||
// return itemA[orderBy] > itemB[orderBy]
|
||||
})
|
||||
if (type.toLowerCase() === 'desc') {
|
||||
return arr.reverse()
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
/**
|
||||
* Determinate if field is displayed
|
||||
* @param {boolean} field.isActive
|
||||
* @param {boolean} field.isDisplayed
|
||||
* @param {boolean} field.isDisplayedFromLogic
|
||||
* @param {boolean} field.isQueryCriteria
|
||||
* @param {string} field.panelType
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function fieldIsDisplayed(field) {
|
||||
// if is Advanced Query
|
||||
if (field.panelType === 'table') {
|
||||
return field.isDisplayed && field.isDisplayedFromLogic
|
||||
}
|
||||
const isBrowserDisplayed = field.isQueryCriteria // browser query criteria
|
||||
const isWindowDisplayed = field.isDisplayed && field.isDisplayedFromLogic // window, process and report, browser result
|
||||
const isDisplayedView = (field.panelType === 'browser' && isBrowserDisplayed) || (field.panelType !== 'browser' && isWindowDisplayed)
|
||||
|
||||
// Verify for displayed and is active
|
||||
return field.isActive && isDisplayedView
|
||||
}
|
||||
|
||||
export function convertAction(action) {
|
||||
var actionAttributes = {
|
||||
name: '',
|
||||
icon: '',
|
||||
hidden: false,
|
||||
isIndex: false
|
||||
}
|
||||
switch (action) {
|
||||
case 'B':
|
||||
actionAttributes.name = 'Workbench'
|
||||
actionAttributes.icon = 'peoples'
|
||||
break
|
||||
case 'F':
|
||||
actionAttributes.name = 'Workflow'
|
||||
actionAttributes.icon = 'example'
|
||||
break
|
||||
case 'P':
|
||||
actionAttributes.name = 'Process'
|
||||
actionAttributes.icon = 'component'
|
||||
break
|
||||
case 'R':
|
||||
actionAttributes.name = 'Report'
|
||||
actionAttributes.icon = 'skill'
|
||||
break
|
||||
case 'S':
|
||||
actionAttributes.name = 'SmartBrowser'
|
||||
actionAttributes.icon = 'search'
|
||||
break
|
||||
case 'T':
|
||||
actionAttributes.name = 'Task'
|
||||
actionAttributes.icon = 'size'
|
||||
break
|
||||
case 'W':
|
||||
actionAttributes.name = 'Window'
|
||||
actionAttributes.icon = 'tab'
|
||||
break
|
||||
case 'X':
|
||||
actionAttributes.name = 'Form'
|
||||
actionAttributes.icon = 'form'
|
||||
|
||||
break
|
||||
default:
|
||||
actionAttributes.name = 'summary'
|
||||
actionAttributes.icon = 'nested'
|
||||
actionAttributes.isIndex = true
|
||||
break
|
||||
}
|
||||
return actionAttributes
|
||||
}
|
@ -1,2 +1,5 @@
|
||||
|
||||
export { isEmptyValue, zeroPad } from '@/utils/ADempiere/valueUtil.js'
|
||||
export {
|
||||
isEmptyValue,
|
||||
zeroPad
|
||||
} from '@/utils/ADempiere/valueUtils.js'
|
||||
|
@ -1,491 +1,3 @@
|
||||
import REFERENCES, { FIELD_NOT_SHOWED } from '@/components/ADempiere/Field/references'
|
||||
import { FIELD_DISPLAY_SIZES, DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
|
||||
import evaluator from '@/utils/ADempiere/evaluator.js'
|
||||
import * as valueUtil from '@/utils/ADempiere/valueUtil.js'
|
||||
|
||||
/**
|
||||
* Determinate if field is displayed
|
||||
* @param {boolean} field.isActive
|
||||
* @param {boolean} field.isDisplayed
|
||||
* @param {boolean} field.isDisplayedFromLogic
|
||||
* @param {boolean} field.isQueryCriteria
|
||||
* @param {string} field.panelType
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function fieldIsDisplayed(field) {
|
||||
// if is Advanced Query
|
||||
if (field.panelType === 'table') {
|
||||
return field.isDisplayed && field.isDisplayedFromLogic
|
||||
}
|
||||
const isBrowserDisplayed = field.isQueryCriteria // browser query criteria
|
||||
const isWindowDisplayed = field.isDisplayed && field.isDisplayedFromLogic // window, process and report, browser result
|
||||
const isDisplayedView = (field.panelType === 'browser' && isBrowserDisplayed) || (field.panelType !== 'browser' && isWindowDisplayed)
|
||||
|
||||
// Verify for displayed and is active
|
||||
return field.isActive && isDisplayedView
|
||||
}
|
||||
|
||||
/**
|
||||
* Converted gRPC attributes to object
|
||||
* @param {object} fieldGRPC
|
||||
* @param {object} moreAttributes, additional attributes
|
||||
* @param {boolean} typeRange, indicate if this field is a range used as _To
|
||||
*/
|
||||
export function convertField(fieldGRPC, moreAttributes = {}, typeRange = false) {
|
||||
var group = {}
|
||||
var isShowedFromUser = false
|
||||
// verify if it no overwrite value with ...moreAttributes
|
||||
if (moreAttributes.isShowedFromUser) {
|
||||
isShowedFromUser = moreAttributes.isShowedFromUser
|
||||
}
|
||||
|
||||
try {
|
||||
group = {
|
||||
name: fieldGRPC.getFieldgroup().getName(),
|
||||
fieldGroupType: fieldGRPC.getFieldgroup().getFieldgrouptype()
|
||||
}
|
||||
} catch (e) {
|
||||
group = {
|
||||
name: '',
|
||||
fieldGroupType: ''
|
||||
}
|
||||
}
|
||||
|
||||
var reference = fieldGRPC.getReference()
|
||||
var zoomWindowList = []
|
||||
var referenceValue = {
|
||||
tableName: '',
|
||||
keyColumnName: '',
|
||||
displayColumnName: '',
|
||||
query: '',
|
||||
parsedQuery: '',
|
||||
directQuery: '',
|
||||
parsedDirectQuery: '',
|
||||
validationCode: '',
|
||||
zoomWindowList: zoomWindowList
|
||||
}
|
||||
if (reference) {
|
||||
if (reference.getWindowsList()) {
|
||||
zoomWindowList = reference.getWindowsList().map(zoomWindow => {
|
||||
return {
|
||||
id: zoomWindow.getId(),
|
||||
uuid: zoomWindow.getUuid(),
|
||||
name: zoomWindow.getName(),
|
||||
description: zoomWindow.getDescription(),
|
||||
isSOTrx: zoomWindow.getIssotrx(),
|
||||
isActive: zoomWindow.getIsactive()
|
||||
}
|
||||
})
|
||||
}
|
||||
referenceValue = {
|
||||
tableName: reference.getTablename(),
|
||||
keyColumnName: reference.getKeycolumnname(),
|
||||
displayColumnName: reference.getDisplaycolumnname(),
|
||||
query: reference.getQuery(),
|
||||
parsedQuery: reference.getQuery(),
|
||||
directQuery: reference.getDirectquery(),
|
||||
parsedDirectQuery: reference.getDirectquery(),
|
||||
validationCode: reference.getValidationcode(),
|
||||
zoomWindowList: zoomWindowList
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
if (String(parsedDefaultValue).includes('@')) {
|
||||
if (String(parsedDefaultValue).includes('@SQL=')) {
|
||||
parsedDefaultValue.replace('@SQL=', '')
|
||||
}
|
||||
parsedDefaultValue = parseContext({
|
||||
...moreAttributes,
|
||||
columnName: fieldGRPC.getColumnname(),
|
||||
value: parsedDefaultValue
|
||||
})
|
||||
}
|
||||
parsedDefaultValue = parsedValueComponent({
|
||||
fieldType: componentReference.type,
|
||||
value: parsedDefaultValue,
|
||||
referenceType: componentReference.alias[0],
|
||||
isMandatory: fieldGRPC.getIsmandatory()
|
||||
})
|
||||
|
||||
var parsedDefaultValueTo = fieldGRPC.getDefaultvalueto()
|
||||
if (String(parsedDefaultValueTo).includes('@')) {
|
||||
parsedDefaultValueTo = parseContext({
|
||||
...moreAttributes,
|
||||
columnName: fieldGRPC.getColumnname(),
|
||||
value: fieldGRPC.getDefaultvalueto()
|
||||
})
|
||||
}
|
||||
parsedDefaultValueTo = parsedValueComponent({
|
||||
fieldType: componentReference.type,
|
||||
value: parsedDefaultValueTo,
|
||||
referenceType: componentReference.alias[0],
|
||||
isMandatory: fieldGRPC.getIsmandatory()
|
||||
})
|
||||
|
||||
var field = {
|
||||
...moreAttributes,
|
||||
// base attributes
|
||||
id: fieldGRPC.getId(),
|
||||
uuid: fieldGRPC.getUuid(),
|
||||
name: fieldGRPC.getName(),
|
||||
description: fieldGRPC.getDescription(),
|
||||
help: fieldGRPC.getHelp(),
|
||||
columnName: fieldGRPC.getColumnname(),
|
||||
isActive: fieldGRPC.getIsactive(),
|
||||
// displayed attributes
|
||||
fieldGroup: group,
|
||||
fieldDefinition: fieldDefinitionValue,
|
||||
displayType: fieldGRPC.getDisplaytype(),
|
||||
componentPath: componentReference.type,
|
||||
isSupport: componentReference.support,
|
||||
referenceType: componentReference.alias[0],
|
||||
isFieldOnly: fieldGRPC.getIsfieldonly(),
|
||||
isRange: fieldGRPC.getIsrange(),
|
||||
isSameLine: fieldGRPC.getIssameline(),
|
||||
isEncrypted: fieldGRPC.getIsencrypted(), // passswords fields
|
||||
sequence: fieldGRPC.getSequence(),
|
||||
seqNoGrid: fieldGRPC.getSeqnogrid(),
|
||||
displayColumn: undefined, // link to value from selects and table
|
||||
// value attributes
|
||||
formatPattern: fieldGRPC.getFormatpattern(),
|
||||
VFormat: fieldGRPC.getVformat(),
|
||||
value: String(parsedDefaultValue).trim() === '' ? undefined : parsedDefaultValue,
|
||||
defaultValue: fieldGRPC.getDefaultvalue(),
|
||||
oldValue: parsedDefaultValue,
|
||||
valueTo: parsedDefaultValueTo,
|
||||
parsedDefaultValue: parsedDefaultValue,
|
||||
defaultValueTo: fieldGRPC.getDefaultvalueto(),
|
||||
parsedDefaultValueTo: parsedDefaultValueTo,
|
||||
fieldLength: fieldGRPC.getFieldlength(),
|
||||
valueMin: fieldGRPC.getValuemin(),
|
||||
valueMax: fieldGRPC.getValuemax(),
|
||||
//
|
||||
isIdentifier: fieldGRPC.getIsidentifier(),
|
||||
isParent: fieldGRPC.getIsparent(),
|
||||
isKey: fieldGRPC.getIskey(),
|
||||
isSelectionColumn: fieldGRPC.getIsselectioncolumn(),
|
||||
isUpdateable: fieldGRPC.getIsupdateable(),
|
||||
isAlwaysUpdateable: fieldGRPC.getIsalwaysupdateable(),
|
||||
//
|
||||
isDisplayed: fieldGRPC.getIsdisplayed(),
|
||||
isMandatory: fieldGRPC.getIsmandatory(),
|
||||
isReadOnly: fieldGRPC.getIsreadonly(),
|
||||
isDisplayedFromLogic: fieldGRPC.getIsdisplayed(),
|
||||
isReadOnlyFromLogic: undefined,
|
||||
isMandatoryFromLogic: undefined,
|
||||
// browser attributes
|
||||
isQueryCriteria: fieldGRPC.getIsquerycriteria(),
|
||||
isInfoOnly: fieldGRPC.getIsinfoonly(),
|
||||
//
|
||||
callout: fieldGRPC.getCallout(),
|
||||
displayLogic: fieldGRPC.getDisplaylogic(),
|
||||
mandatoryLogic: fieldGRPC.getMandatorylogic(),
|
||||
readOnlyLogic: fieldGRPC.getReadonlylogic(),
|
||||
parentFieldsList: getParentFields(fieldGRPC),
|
||||
dependentFieldsList: [],
|
||||
reference: referenceValue,
|
||||
contextInfo: convertContextInfoFromGRPC(
|
||||
fieldGRPC.getContextinfo()
|
||||
),
|
||||
// TODO: Add support on server
|
||||
// app attributes
|
||||
isShowedFromUser: isShowedFromUser,
|
||||
isFixedTableColumn: false
|
||||
}
|
||||
field.isShowedTableFromUser = field.isDisplayed && field.isDisplayedFromLogic
|
||||
|
||||
// evaluate simple logics without context
|
||||
if (field.displayLogic.trim() !== '' && !field.displayLogic.includes('@')) {
|
||||
field.isDisplayedFromLogic = evaluator.evaluateLogic({
|
||||
type: 'displayed',
|
||||
logic: field.displayLogic
|
||||
})
|
||||
}
|
||||
if (field.mandatoryLogic.trim() !== '' && !field.mandatoryLogic.includes('@')) {
|
||||
field.isMandatoryFromLogic = evaluator.evaluateLogic({
|
||||
logic: field.mandatoryLogic
|
||||
})
|
||||
}
|
||||
if (field.readOnlyLogic.trim() !== '' && !field.readOnlyLogic.includes('@')) {
|
||||
field.isReadOnlyFromLogic = evaluator.evaluateLogic({
|
||||
logic: field.readOnlyLogic
|
||||
})
|
||||
}
|
||||
|
||||
// Sizes from panel and groups
|
||||
field.sizeFieldFromType = FIELD_DISPLAY_SIZES.find(item => {
|
||||
return item.type === field.componentPath
|
||||
})
|
||||
if (field.sizeFieldFromType === undefined) {
|
||||
console.warn('Field size no found:', field.name, 'type:', field.componentPath)
|
||||
field.sizeFieldFromType = {
|
||||
type: field.componentPath,
|
||||
size: DEFAULT_SIZE
|
||||
}
|
||||
}
|
||||
|
||||
// Overwrite some values
|
||||
if (typeRange) {
|
||||
field.uuid = field.uuid + '_To'
|
||||
field.columnName = field.columnName + '_To'
|
||||
field.name = field.name + ' To'
|
||||
field.value = parsedDefaultValueTo
|
||||
field.defaultValue = field.defaultValueTo
|
||||
field.parsedDefaultValue = field.parsedDefaultValueTo
|
||||
}
|
||||
|
||||
// hidden field type button
|
||||
const notShowedField = FIELD_NOT_SHOWED.find(itemField => {
|
||||
if (field.displayType === itemField.id) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (notShowedField) {
|
||||
field.isDisplayedFromLogic = false
|
||||
field.isDisplayed = false
|
||||
}
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// Default template for injected fields
|
||||
export function getFieldTemplate(attributesOverwrite) {
|
||||
var group = {
|
||||
name: '',
|
||||
fieldGroupType: ''
|
||||
}
|
||||
var zoomWindowList = []
|
||||
var referenceValue = {
|
||||
tableName: '',
|
||||
keyColumnName: '',
|
||||
displayColumnName: '',
|
||||
query: '',
|
||||
parsedQuery: '',
|
||||
directQuery: '',
|
||||
parsedDirectQuery: '',
|
||||
validationCode: '',
|
||||
zoomWindowList: zoomWindowList
|
||||
}
|
||||
var newField = {
|
||||
id: 0,
|
||||
uuid: '',
|
||||
name: '',
|
||||
description: '',
|
||||
help: '',
|
||||
columnName: '',
|
||||
fieldGroup: group,
|
||||
displayType: 10,
|
||||
componentPath: 'FieldButton',
|
||||
referenceType: 'Button',
|
||||
isFieldOnly: false,
|
||||
isRange: false,
|
||||
isSameLine: false,
|
||||
sequence: 0,
|
||||
seqNoGrid: 0,
|
||||
isIdentifier: 0,
|
||||
isKey: false,
|
||||
isSelectionColumn: false,
|
||||
isUpdateable: true,
|
||||
formatPattern: undefined,
|
||||
VFormat: undefined,
|
||||
value: undefined,
|
||||
valueTo: undefined,
|
||||
defaultValue: undefined,
|
||||
parsedDefaultValue: undefined,
|
||||
defaultValueTo: undefined,
|
||||
parsedDefaultValueTo: undefined,
|
||||
valueMin: undefined,
|
||||
valueMax: undefined,
|
||||
//
|
||||
isDisplayed: false,
|
||||
isActive: true,
|
||||
isMandatory: false,
|
||||
isReadOnly: false,
|
||||
isDisplayedFromLogic: false,
|
||||
isReadOnlyFromLogic: false,
|
||||
isMandatoryFromLogic: false,
|
||||
// browser attributes
|
||||
callout: undefined,
|
||||
isQueryCriteria: false,
|
||||
displayLogic: undefined,
|
||||
mandatoryLogic: undefined,
|
||||
readOnlyLogic: undefined,
|
||||
parentFieldsList: undefined,
|
||||
dependentFieldsList: [],
|
||||
reference: referenceValue,
|
||||
contextInfo: undefined,
|
||||
isShowedFromUser: false,
|
||||
isFixedTableColumn: false,
|
||||
sizeFieldFromType: {
|
||||
type: 'Button',
|
||||
size: DEFAULT_SIZE
|
||||
}
|
||||
}
|
||||
return Object.assign(newField, attributesOverwrite)
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate by the ID and name of the reference to call the component type
|
||||
* @param {integer} displayTypeId, received from data
|
||||
* @param {boolean} isAllInfo
|
||||
* @return string type, assigned value to folder after evaluating the parameter
|
||||
*/
|
||||
export function evalutateTypeField(displayTypeId, isAllInfo = false) {
|
||||
var component = REFERENCES.find(reference => displayTypeId === reference.id)
|
||||
if (isAllInfo) {
|
||||
return component
|
||||
}
|
||||
return component.type
|
||||
}
|
||||
|
||||
export function getParentFields(fieldGRPC) {
|
||||
var parentFields = []
|
||||
// For Display logic
|
||||
if (fieldGRPC.getDisplaylogic()) {
|
||||
parentFields = Array.from(new Set([
|
||||
...parentFields,
|
||||
...evaluator.parseDepends(fieldGRPC.getDisplaylogic())
|
||||
]))
|
||||
}
|
||||
// For Mandatory Logic
|
||||
if (fieldGRPC.getMandatorylogic()) {
|
||||
parentFields = Array.from(new Set([
|
||||
...parentFields,
|
||||
...evaluator.parseDepends(fieldGRPC.getMandatorylogic())
|
||||
]))
|
||||
}
|
||||
// For Read Only Logic
|
||||
if (fieldGRPC.getReadonlylogic()) {
|
||||
parentFields = Array.from(new Set([
|
||||
...parentFields,
|
||||
...evaluator.parseDepends(fieldGRPC.getReadonlylogic())
|
||||
]))
|
||||
}
|
||||
// For Default Value
|
||||
if (fieldGRPC.getDefaultvalue()) {
|
||||
parentFields = Array.from(new Set([
|
||||
...parentFields,
|
||||
...evaluator.parseDepends(fieldGRPC.getDefaultvalue())
|
||||
]))
|
||||
}
|
||||
return parentFields
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Context String
|
||||
* @param {object} context
|
||||
* - value: (REQUIRED) String to parsing
|
||||
* - parentUuid: (REQUIRED from Window) UUID Window
|
||||
* - containerUuid: (REQUIRED) UUID Tab, Process, SmartBrowser, Report and Form
|
||||
* - columnName: (Optional if exists in value) Column name to search in context
|
||||
* @param {boolean} isBoolToString, convert boolean values to string
|
||||
*/
|
||||
export function parseContext(context, isBoolToString = false) {
|
||||
const store = require('@/store')
|
||||
var value = String(context.value)
|
||||
var valueSQL = {}
|
||||
if (valueUtil.isEmptyValue(value)) { return '' }
|
||||
if (value.includes('@SQL=')) {
|
||||
value = value.replace('@SQL=', '')
|
||||
}
|
||||
// var instances = value.length - value.replace('@', '').length
|
||||
// if ((instances > 0) && (instances % 2) !== 0) { // could be an email address
|
||||
// return value
|
||||
// }
|
||||
|
||||
var token
|
||||
var inStr = value
|
||||
var outStr = ''
|
||||
|
||||
var i = inStr.indexOf('@')
|
||||
|
||||
while (i !== -1) {
|
||||
outStr = outStr + inStr.substring(0, i) // up to @
|
||||
inStr = inStr.substring(i + 1, inStr.length) // from first @
|
||||
var j = inStr.indexOf('@') // next @
|
||||
if (j < 0) {
|
||||
console.log('No second tag: ' + inStr)
|
||||
return '' // no second tag
|
||||
}
|
||||
|
||||
token = inStr.substring(0, j)
|
||||
context.columnName = token
|
||||
|
||||
var ctxInfo = store.default.getters.getContext(context) // get context
|
||||
if (isBoolToString && typeof ctxInfo === 'boolean') {
|
||||
if (ctxInfo) {
|
||||
ctxInfo = 'Y'
|
||||
} else {
|
||||
ctxInfo = 'N'
|
||||
}
|
||||
}
|
||||
|
||||
if ((ctxInfo === undefined || ctxInfo.length === 0) && (token.startsWith('#') || token.startsWith('$'))) {
|
||||
context.parentUuid = undefined
|
||||
context.containerUuid = undefined
|
||||
ctxInfo = store.default.getters.getContext(context) // get global context
|
||||
}
|
||||
if (ctxInfo === undefined || ctxInfo.length === 0) {
|
||||
console.info('No Context for: ' + token)
|
||||
} else {
|
||||
if (typeof ctxInfo === 'object') {
|
||||
outStr = ctxInfo
|
||||
} else {
|
||||
outStr = outStr + ctxInfo // replace context with Context
|
||||
}
|
||||
}
|
||||
|
||||
inStr = inStr.substring(j + 1, inStr.length) // from second @
|
||||
i = inStr.indexOf('@')
|
||||
}
|
||||
if (typeof ctxInfo !== 'object') {
|
||||
outStr = outStr + inStr // add the rest of the string
|
||||
}
|
||||
if (context.isSQL) {
|
||||
valueSQL['query'] = outStr
|
||||
valueSQL['value'] = ctxInfo
|
||||
return valueSQL
|
||||
}
|
||||
return outStr
|
||||
} // parseContext
|
||||
|
||||
export function convertRoleFromGRPC(roleGRPC) {
|
||||
return {
|
||||
id: roleGRPC.getId(),
|
||||
@ -498,291 +10,9 @@ export function convertRoleFromGRPC(roleGRPC) {
|
||||
}
|
||||
}
|
||||
|
||||
export function convertContextInfoFromGRPC(contextInfoGRPC) {
|
||||
var contextInfo = {
|
||||
id: '',
|
||||
uuid: '',
|
||||
name: '',
|
||||
description: '',
|
||||
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
|
||||
}
|
||||
|
||||
export function convertMessageTextFromGRPC(messageTextGRPC) {
|
||||
var messageText = {
|
||||
id: '',
|
||||
uuid: '',
|
||||
value: '',
|
||||
msgType: '',
|
||||
msgText: '',
|
||||
msgTip: '',
|
||||
isActive: false
|
||||
}
|
||||
if (messageTextGRPC !== undefined) {
|
||||
messageText = {
|
||||
id: messageTextGRPC.getId(),
|
||||
// uuid: messageText.getUuid(),
|
||||
value: messageTextGRPC.getValue(),
|
||||
msgType: messageTextGRPC.getMsgtype(),
|
||||
msgText: messageTextGRPC.getMsgtext(),
|
||||
msgTip: messageTextGRPC.getMsgtip(),
|
||||
isActive: messageTextGRPC.getIsactive()
|
||||
}
|
||||
}
|
||||
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
|
||||
* @return {array} fieldList
|
||||
*/
|
||||
export function assignedGroup(fieldList, assignedGroup) {
|
||||
if (fieldList === undefined || fieldList.length <= 0) {
|
||||
return fieldList
|
||||
}
|
||||
fieldList = sortFields(fieldList, 'sequence', 'asc', fieldList[0].panelType)
|
||||
|
||||
let firstChangeGroup = false
|
||||
let currentGroup = ''
|
||||
let typeGroup = ''
|
||||
|
||||
fieldList.forEach(fieldElement => {
|
||||
if (fieldElement.panelType !== 'window') {
|
||||
fieldElement.groupAssigned = ''
|
||||
fieldElement.typeGroupAssigned = ''
|
||||
return
|
||||
}
|
||||
|
||||
// change the first field group, change the band
|
||||
if (!firstChangeGroup) {
|
||||
if (!valueUtil.isEmptyValue(fieldElement.fieldGroup.name) &&
|
||||
currentGroup !== fieldElement.fieldGroup.name &&
|
||||
fieldElement.isDisplayed) {
|
||||
firstChangeGroup = true
|
||||
}
|
||||
}
|
||||
// if you change the field group for the first time and it is different
|
||||
// from 0, updates the field group, since it is another field group and
|
||||
// assigns the following field items to the current field group whose
|
||||
// field group is '' or null
|
||||
if (firstChangeGroup) {
|
||||
if (!valueUtil.isEmptyValue(fieldElement.fieldGroup.name)) {
|
||||
currentGroup = fieldElement.fieldGroup.name
|
||||
typeGroup = fieldElement.fieldGroup.fieldGroupType
|
||||
}
|
||||
}
|
||||
|
||||
fieldElement.groupAssigned = currentGroup
|
||||
fieldElement.typeGroupAssigned = typeGroup
|
||||
|
||||
if (assignedGroup !== undefined) {
|
||||
fieldElement.groupAssigned = assignedGroup
|
||||
}
|
||||
})
|
||||
|
||||
return fieldList
|
||||
}
|
||||
|
||||
/**
|
||||
* Order the fields, then assign the groups to each field, and finally group
|
||||
* in an array according to each field group to show in panel (or table).
|
||||
* @param {array} arr
|
||||
* @param {string} orderBy
|
||||
* @param {string} type
|
||||
* @param {string} panelType
|
||||
* @returns {array}
|
||||
*/
|
||||
export function sortFields(arr, orderBy = 'sequence', type = 'asc', panelType = 'window') {
|
||||
if (panelType === 'browser') {
|
||||
orderBy = 'seqNoGrid'
|
||||
}
|
||||
arr.sort((itemA, itemB) => {
|
||||
return itemA[orderBy] - itemB[orderBy]
|
||||
// return itemA[orderBy] > itemB[orderBy]
|
||||
})
|
||||
if (type.toLowerCase() === 'desc') {
|
||||
return arr.reverse()
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
export function parsedValueComponent({ fieldType, value, referenceType, isMandatory = false }) {
|
||||
if (value === undefined || value === null) {
|
||||
return undefined
|
||||
}
|
||||
var returnValue
|
||||
|
||||
switch (fieldType) {
|
||||
// data type Number
|
||||
case 'FieldNumber':
|
||||
if (String(value).trim() === '') {
|
||||
returnValue = undefined
|
||||
if (isMandatory) {
|
||||
returnValue = 0
|
||||
}
|
||||
} else if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
||||
returnValue = value
|
||||
} else {
|
||||
returnValue = Number(value)
|
||||
}
|
||||
break
|
||||
|
||||
// data type Boolean
|
||||
case 'FieldYesNo':
|
||||
if (value === 'false' || value === 'N') {
|
||||
value = false
|
||||
} else if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
||||
returnValue = value
|
||||
}
|
||||
returnValue = Boolean(value)
|
||||
break
|
||||
|
||||
// data type String
|
||||
case 'FieldText':
|
||||
case 'FieldTextArea':
|
||||
if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
||||
returnValue = value
|
||||
}
|
||||
returnValue = String(value)
|
||||
break
|
||||
|
||||
// data type Date
|
||||
case 'FieldDate':
|
||||
case 'FieldTime ':
|
||||
if (String(value).trim() === '') {
|
||||
value = undefined
|
||||
}
|
||||
if (!isNaN(value)) {
|
||||
value = Number(value)
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
value = new Date(value)
|
||||
}
|
||||
if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
||||
returnValue = value
|
||||
}
|
||||
returnValue = value
|
||||
break
|
||||
|
||||
case 'FieldSelect':
|
||||
if (String(value).trim() === '') {
|
||||
value = undefined
|
||||
}
|
||||
if (referenceType === 'TableDirect') {
|
||||
if (value !== '' && value !== null && value !== undefined) {
|
||||
value = Number(value)
|
||||
}
|
||||
} // Search or List
|
||||
returnValue = value
|
||||
break
|
||||
|
||||
default:
|
||||
returnValue = value
|
||||
break
|
||||
}
|
||||
return returnValue
|
||||
}
|
||||
export function convertAction(action) {
|
||||
var actionAttributes = {
|
||||
name: '',
|
||||
icon: '',
|
||||
hidden: false,
|
||||
isIndex: false
|
||||
}
|
||||
switch (action) {
|
||||
case 'B':
|
||||
actionAttributes.name = 'Workbench'
|
||||
actionAttributes.icon = 'peoples'
|
||||
break
|
||||
case 'F':
|
||||
actionAttributes.name = 'Workflow'
|
||||
actionAttributes.icon = 'example'
|
||||
break
|
||||
case 'P':
|
||||
actionAttributes.name = 'Process'
|
||||
actionAttributes.icon = 'component'
|
||||
break
|
||||
case 'R':
|
||||
actionAttributes.name = 'Report'
|
||||
actionAttributes.icon = 'skill'
|
||||
break
|
||||
case 'S':
|
||||
actionAttributes.name = 'SmartBrowser'
|
||||
actionAttributes.icon = 'search'
|
||||
break
|
||||
case 'T':
|
||||
actionAttributes.name = 'Task'
|
||||
actionAttributes.icon = 'size'
|
||||
break
|
||||
case 'W':
|
||||
actionAttributes.name = 'Window'
|
||||
actionAttributes.icon = 'tab'
|
||||
break
|
||||
case 'X':
|
||||
actionAttributes.name = 'Form'
|
||||
actionAttributes.icon = 'form'
|
||||
|
||||
break
|
||||
default:
|
||||
actionAttributes.name = 'summary'
|
||||
actionAttributes.icon = 'nested'
|
||||
actionAttributes.isIndex = true
|
||||
break
|
||||
}
|
||||
return actionAttributes
|
||||
}
|
||||
export default evaluator // from '@/utils/ADempiere/evaluator.js'
|
||||
export { default } from '@/utils/ADempiere/evaluator.js'
|
||||
export * from '@/utils/ADempiere/auth.js'
|
||||
export * from '@/utils/ADempiere/notification.js'
|
||||
export * from '@/utils/ADempiere/valueUtil.js'
|
||||
export * from '@/utils/ADempiere/valueUtils.js'
|
||||
export * from '@/utils/ADempiere/contextUtils.js'
|
||||
export * from '@/utils/ADempiere/dictionaryUtils.js'
|
||||
|
@ -207,3 +207,84 @@ export function convertFieldListToShareLink(fieldList) {
|
||||
|
||||
return attributesListLink.slice(0, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} param0
|
||||
*/
|
||||
export function parsedValueComponent({ fieldType, value, referenceType, isMandatory = false }) {
|
||||
if (value === undefined || value === null) {
|
||||
return undefined
|
||||
}
|
||||
var returnValue
|
||||
|
||||
switch (fieldType) {
|
||||
// data type Number
|
||||
case 'FieldNumber':
|
||||
if (String(value).trim() === '') {
|
||||
returnValue = undefined
|
||||
if (isMandatory) {
|
||||
returnValue = 0
|
||||
}
|
||||
} else if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
||||
returnValue = value
|
||||
} else {
|
||||
returnValue = Number(value)
|
||||
}
|
||||
break
|
||||
|
||||
// data type Boolean
|
||||
case 'FieldYesNo':
|
||||
if (value === 'false' || value === 'N') {
|
||||
value = false
|
||||
} else if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
||||
returnValue = value
|
||||
}
|
||||
returnValue = Boolean(value)
|
||||
break
|
||||
|
||||
// data type String
|
||||
case 'FieldText':
|
||||
case 'FieldTextArea':
|
||||
if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
||||
returnValue = value
|
||||
}
|
||||
returnValue = String(value)
|
||||
break
|
||||
|
||||
// data type Date
|
||||
case 'FieldDate':
|
||||
case 'FieldTime ':
|
||||
if (String(value).trim() === '') {
|
||||
value = undefined
|
||||
}
|
||||
if (!isNaN(value)) {
|
||||
value = Number(value)
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
value = new Date(value)
|
||||
}
|
||||
if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
||||
returnValue = value
|
||||
}
|
||||
returnValue = value
|
||||
break
|
||||
|
||||
case 'FieldSelect':
|
||||
if (String(value).trim() === '') {
|
||||
value = undefined
|
||||
}
|
||||
if (referenceType === 'TableDirect') {
|
||||
if (value !== '' && value !== null && value !== undefined) {
|
||||
value = Number(value)
|
||||
}
|
||||
} // Search or List
|
||||
returnValue = value
|
||||
break
|
||||
|
||||
default:
|
||||
returnValue = value
|
||||
break
|
||||
}
|
||||
return returnValue
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user