mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 23:20:12 +08:00
fix: Test View error when change value into field. (#446)
* fix: Test View error when change value into field. * remove console.log * add support to references fields for manual forms * fix logic's Test View. * change definition lookup factory. * Some changes * Add support to factory from ADempiere Co-authored-by: Yamel Senih <ysenih@erpya.com>
This commit is contained in:
parent
9646f69708
commit
7fd5c8f334
@ -251,7 +251,7 @@ import IconElement from '@/components/ADempiere/IconElement'
|
|||||||
import { formatDate } from '@/filters/ADempiere'
|
import { formatDate } from '@/filters/ADempiere'
|
||||||
import MainPanel from '@/components/ADempiere/Panel'
|
import MainPanel from '@/components/ADempiere/Panel'
|
||||||
import { sortFields } from '@/utils/ADempiere/dictionaryUtils'
|
import { sortFields } from '@/utils/ADempiere/dictionaryUtils'
|
||||||
import { FIELDS_DECIMALS, FIELDS_QUANTITY, FIELD_READ_ONLY_FORM } from '@/utils/ADempiere/references'
|
import { FIELDS_DECIMALS, FIELDS_QUANTITY, FIELDS_READ_ONLY_FORM } from '@/utils/ADempiere/references'
|
||||||
import { fieldIsDisplayed } from '@/utils/ADempiere'
|
import { fieldIsDisplayed } from '@/utils/ADempiere'
|
||||||
import evaluator from '@/utils/ADempiere/evaluator'
|
import evaluator from '@/utils/ADempiere/evaluator'
|
||||||
|
|
||||||
@ -667,7 +667,7 @@ export default {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (fieldIsDisplayed(field)) {
|
if (fieldIsDisplayed(field)) {
|
||||||
// const fieldReadOnlyAllForm = FIELD_READ_ONLY_FORM.filter(item => {
|
// const fieldReadOnlyAllForm = FIELDS_READ_ONLY_FORM.filter(item => {
|
||||||
// return row.hasOwnProperty(item.columnName) && item.isChangedAllForm
|
// return row.hasOwnProperty(item.columnName) && item.isChangedAllForm
|
||||||
// })
|
// })
|
||||||
// // columnName: Processed, Processing
|
// // columnName: Processed, Processing
|
||||||
@ -677,7 +677,7 @@ export default {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// columnName: IsActive
|
// columnName: IsActive
|
||||||
const fieldReadOnlyForm = FIELD_READ_ONLY_FORM.find(item => {
|
const fieldReadOnlyForm = FIELDS_READ_ONLY_FORM.find(item => {
|
||||||
return row.hasOwnProperty(item.columnName) && !item.isChangedAllForm
|
return row.hasOwnProperty(item.columnName) && !item.isChangedAllForm
|
||||||
})
|
})
|
||||||
if (fieldReadOnlyForm) {
|
if (fieldReadOnlyForm) {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fieldIsDisplayed } from '@/utils/ADempiere'
|
import { fieldIsDisplayed } from '@/utils/ADempiere'
|
||||||
import { FIELD_READ_ONLY_FORM } from '@/utils/ADempiere/references'
|
import { FIELDS_READ_ONLY_FORM } from '@/utils/ADempiere/references'
|
||||||
import { fieldMixin } from '@/components/ADempiere/Field/FieldMixin'
|
import { fieldMixin } from '@/components/ADempiere/Field/FieldMixin'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -62,7 +62,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
isReadOnlyForm(value) {
|
isReadOnlyForm(value) {
|
||||||
const fieldReadOnlyForm = FIELD_READ_ONLY_FORM.find(item => item.columnName === this.metadata.columnName)
|
const fieldReadOnlyForm = FIELDS_READ_ONLY_FORM.find(item => item.columnName === this.metadata.columnName)
|
||||||
// columnName: IsActive, Processed, Processing
|
// columnName: IsActive, Processed, Processing
|
||||||
if (fieldReadOnlyForm && fieldIsDisplayed(this.metadata)) {
|
if (fieldReadOnlyForm && fieldIsDisplayed(this.metadata)) {
|
||||||
const fieldsExcludes = []
|
const fieldsExcludes = []
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
export const FIELD_DISPLAY_SIZES = [
|
export const FIELD_BINARY = {
|
||||||
{
|
|
||||||
type: 'FieldBinary',
|
type: 'FieldBinary',
|
||||||
size: {
|
size: {
|
||||||
xs: 6,
|
xs: 6,
|
||||||
@ -9,8 +8,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 6,
|
lg: 6,
|
||||||
xl: 6
|
xl: 6
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_BUTTON = {
|
||||||
type: 'FieldButton',
|
type: 'FieldButton',
|
||||||
size: {
|
size: {
|
||||||
xs: 0,
|
xs: 0,
|
||||||
@ -19,8 +19,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 0,
|
lg: 0,
|
||||||
xl: 0
|
xl: 0
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_COLOR = {
|
||||||
type: 'FieldColor',
|
type: 'FieldColor',
|
||||||
size: {
|
size: {
|
||||||
xs: 6,
|
xs: 6,
|
||||||
@ -29,8 +30,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 6,
|
lg: 6,
|
||||||
xl: 6
|
xl: 6
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_DATE = {
|
||||||
type: 'FieldDate',
|
type: 'FieldDate',
|
||||||
size: {
|
size: {
|
||||||
xs: 24,
|
xs: 24,
|
||||||
@ -39,8 +41,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 6,
|
lg: 6,
|
||||||
xl: 6
|
xl: 6
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_IMAGE = {
|
||||||
type: 'FieldImage',
|
type: 'FieldImage',
|
||||||
size: {
|
size: {
|
||||||
xs: 6,
|
xs: 6,
|
||||||
@ -49,8 +52,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 6,
|
lg: 6,
|
||||||
xl: 6
|
xl: 6
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_NUMBER = {
|
||||||
type: 'FieldNumber',
|
type: 'FieldNumber',
|
||||||
size: {
|
size: {
|
||||||
xs: 24,
|
xs: 24,
|
||||||
@ -59,8 +63,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 6,
|
lg: 6,
|
||||||
xl: 6
|
xl: 6
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_SELECT = {
|
||||||
type: 'FieldSelect',
|
type: 'FieldSelect',
|
||||||
size: {
|
size: {
|
||||||
xs: 24,
|
xs: 24,
|
||||||
@ -69,8 +74,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 6,
|
lg: 6,
|
||||||
xl: 6
|
xl: 6
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_TEXT = {
|
||||||
type: 'FieldText',
|
type: 'FieldText',
|
||||||
size: {
|
size: {
|
||||||
xs: 24,
|
xs: 24,
|
||||||
@ -79,8 +85,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 6,
|
lg: 6,
|
||||||
xl: 6
|
xl: 6
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_TEXT_LONG = {
|
||||||
type: 'FieldTextLong',
|
type: 'FieldTextLong',
|
||||||
size: {
|
size: {
|
||||||
xs: 24,
|
xs: 24,
|
||||||
@ -89,8 +96,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 24,
|
lg: 24,
|
||||||
xl: 24
|
xl: 24
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_TIME = {
|
||||||
type: 'FieldTime',
|
type: 'FieldTime',
|
||||||
size: {
|
size: {
|
||||||
xs: 24,
|
xs: 24,
|
||||||
@ -99,8 +107,9 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 6,
|
lg: 6,
|
||||||
xl: 6
|
xl: 6
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const FIELD_YES_NO = {
|
||||||
type: 'FieldYesNo',
|
type: 'FieldYesNo',
|
||||||
size: {
|
size: {
|
||||||
xs: 14,
|
xs: 14,
|
||||||
@ -109,11 +118,24 @@ export const FIELD_DISPLAY_SIZES = [
|
|||||||
lg: 3,
|
lg: 3,
|
||||||
xl: 6
|
xl: 6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FIELDS_DISPLAY_SIZES = [
|
||||||
|
FIELD_BINARY,
|
||||||
|
FIELD_BUTTON,
|
||||||
|
FIELD_COLOR,
|
||||||
|
FIELD_DATE,
|
||||||
|
FIELD_IMAGE,
|
||||||
|
FIELD_NUMBER,
|
||||||
|
FIELD_SELECT,
|
||||||
|
FIELD_TEXT,
|
||||||
|
FIELD_TEXT_LONG,
|
||||||
|
FIELD_YES_NO
|
||||||
]
|
]
|
||||||
|
export default FIELDS_DISPLAY_SIZES
|
||||||
|
|
||||||
export const DEFAULT_SIZE = {
|
export const DEFAULT_SIZE = {
|
||||||
type: 'FieldYesNo',
|
type: 'FieldDefault',
|
||||||
size: {
|
size: {
|
||||||
xs: 6,
|
xs: 6,
|
||||||
sm: 8,
|
sm: 8,
|
||||||
|
@ -74,7 +74,7 @@ import documentStatus from '@/components/ADempiere/Field/popover/documentStatus'
|
|||||||
import operatorComparison from '@/components/ADempiere/Field/popover/operatorComparison'
|
import operatorComparison from '@/components/ADempiere/Field/popover/operatorComparison'
|
||||||
import translated from '@/components/ADempiere/Field/popover/translated'
|
import translated from '@/components/ADempiere/Field/popover/translated'
|
||||||
import calculator from '@/components/ADempiere/Field/popover/calculator'
|
import calculator from '@/components/ADempiere/Field/popover/calculator'
|
||||||
import { DEFAULT_SIZE, FIELD_DISPLAY_SIZES } from '@/components/ADempiere/Field/fieldSize'
|
import FIELDS_DISPLAY_SIZES, { DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
|
||||||
import { evalutateTypeField, fieldIsDisplayed } from '@/utils/ADempiere/dictionaryUtils'
|
import { evalutateTypeField, fieldIsDisplayed } from '@/utils/ADempiere/dictionaryUtils'
|
||||||
import { showMessage } from '@/utils/ADempiere/notification'
|
import { showMessage } from '@/utils/ADempiere/notification'
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ export default {
|
|||||||
},
|
},
|
||||||
sizeFieldResponsive() {
|
sizeFieldResponsive() {
|
||||||
if (!this.isDisplayed) {
|
if (!this.isDisplayed) {
|
||||||
return DEFAULT_SIZE
|
return DEFAULT_SIZE.size
|
||||||
}
|
}
|
||||||
|
|
||||||
let sizeField = {}
|
let sizeField = {}
|
||||||
@ -228,13 +228,13 @@ export default {
|
|||||||
}
|
}
|
||||||
if (this.isEmptyValue(sizeField)) {
|
if (this.isEmptyValue(sizeField)) {
|
||||||
// Sizes from panel and groups
|
// Sizes from panel and groups
|
||||||
sizeField = FIELD_DISPLAY_SIZES.find(item => {
|
sizeField = FIELDS_DISPLAY_SIZES.find(item => {
|
||||||
return item.type === this.field.componentPath
|
return item.type === this.field.componentPath
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (this.isEmptyValue(sizeField)) {
|
if (this.isEmptyValue(sizeField)) {
|
||||||
// set default size
|
// set default size
|
||||||
sizeField = DEFAULT_SIZE
|
sizeField = DEFAULT_SIZE.size
|
||||||
}
|
}
|
||||||
|
|
||||||
const newSizes = {}
|
const newSizes = {}
|
||||||
@ -318,7 +318,7 @@ export default {
|
|||||||
// assined field with prop
|
// assined field with prop
|
||||||
this.field = this.metadataField
|
this.field = this.metadataField
|
||||||
if (this.field.isCustomField && !this.field.componentPath) {
|
if (this.field.isCustomField && !this.field.componentPath) {
|
||||||
let componentReference = evalutateTypeField(this.field.displayType, true)
|
let componentReference = evalutateTypeField(this.field.displayType)
|
||||||
if (this.isEmptyValue(componentReference)) {
|
if (this.isEmptyValue(componentReference)) {
|
||||||
componentReference = {
|
componentReference = {
|
||||||
type: 'FieldText',
|
type: 'FieldText',
|
||||||
|
@ -101,21 +101,6 @@ const browser = {
|
|||||||
})
|
})
|
||||||
fieldsList = fieldsList.concat(fieldsRangeList)
|
fieldsList = fieldsList.concat(fieldsRangeList)
|
||||||
|
|
||||||
// Get dependent fields
|
|
||||||
fieldsList
|
|
||||||
.forEach((field, index, list) => {
|
|
||||||
if (field.isActive && field.parentFieldsList.length) {
|
|
||||||
field.parentFieldsList.forEach(parentColumnName => {
|
|
||||||
const parentField = list.find(parentField => {
|
|
||||||
return parentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
|
||||||
})
|
|
||||||
if (parentField) {
|
|
||||||
parentField.dependentFieldsList.push(field.columnName)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Panel for save on store
|
// Panel for save on store
|
||||||
const newBrowser = {
|
const newBrowser = {
|
||||||
...browserResponse,
|
...browserResponse,
|
||||||
|
97
src/store/modules/ADempiere/field.js
Normal file
97
src/store/modules/ADempiere/field.js
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
import { getField as getFieldFromDictionary } from '@/api/ADempiere/dictionary'
|
||||||
|
|
||||||
|
const initStateLookup = {
|
||||||
|
referenceList: [],
|
||||||
|
fieldList: [],
|
||||||
|
validationRuleList: []
|
||||||
|
}
|
||||||
|
|
||||||
|
const field = {
|
||||||
|
state: initStateLookup,
|
||||||
|
mutations: {
|
||||||
|
addField(state, payload) {
|
||||||
|
state.fieldList.push(payload)
|
||||||
|
},
|
||||||
|
addReference(state, payload) {
|
||||||
|
state.referenceList.push(payload)
|
||||||
|
},
|
||||||
|
addValidationRule(state, payload) {
|
||||||
|
state.validationRuleList.push(payload)
|
||||||
|
},
|
||||||
|
resetStateLookup(state) {
|
||||||
|
state = initStateLookup
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
// Get Reference from Server based on criteria
|
||||||
|
getFieldFromServer({ commit, rootGetters }, {
|
||||||
|
fieldUuid,
|
||||||
|
columnUuid,
|
||||||
|
elementUuid,
|
||||||
|
tableName,
|
||||||
|
columnName,
|
||||||
|
elementColumnName
|
||||||
|
}) {
|
||||||
|
return getFieldFromDictionary({
|
||||||
|
fieldUuid,
|
||||||
|
columnUuid,
|
||||||
|
elementUuid,
|
||||||
|
// TableName + ColumnName
|
||||||
|
tableName,
|
||||||
|
columnName,
|
||||||
|
elementColumnName
|
||||||
|
})
|
||||||
|
.then(fieldResponse => {
|
||||||
|
if (columnUuid) {
|
||||||
|
fieldResponse.columnUuid = columnUuid
|
||||||
|
} else if (elementUuid) {
|
||||||
|
fieldResponse.elementUuid = elementUuid
|
||||||
|
} else if (elementColumnName) {
|
||||||
|
fieldResponse.elementColumnName = elementColumnName
|
||||||
|
} else if (tableName && columnName) {
|
||||||
|
fieldResponse.tableName = tableName
|
||||||
|
fieldResponse.columnName = columnName
|
||||||
|
}
|
||||||
|
commit('addField', {
|
||||||
|
fieldResponse
|
||||||
|
})
|
||||||
|
return fieldResponse
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(`Get Field, Select Base - Error ${error.code}: ${error.message}.`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
getFieldFromUuid: (state) => (uuid) => {
|
||||||
|
return state.fieldList.find(fieldItem => {
|
||||||
|
return fieldItem.uuid === uuid
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getFieldFromColumnUuid: (state) => (columnUuid) => {
|
||||||
|
return state.fieldList.find(fieldItem => {
|
||||||
|
return fieldItem.columnUuid === columnUuid
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getFieldFromElementUuid: (state) => (elementUuid) => {
|
||||||
|
return state.fieldList.find(fieldItem => {
|
||||||
|
return fieldItem.elementUuid === elementUuid
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getFieldFromElementColumnName: (state) => (elementColumnName) => {
|
||||||
|
return state.fieldList.find(fieldItem => {
|
||||||
|
return fieldItem.elementColumnName === elementColumnName
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getFieldFromTableNameAndColumnName: (state) => ({
|
||||||
|
tableName,
|
||||||
|
columnName
|
||||||
|
}) => {
|
||||||
|
return state.fieldList.find(fieldItem => {
|
||||||
|
return fieldItem.tableName === tableName && fieldItem.columnName === columnName
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default field
|
@ -56,13 +56,14 @@ const panel = {
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
addPanel({ commit, dispatch, getters }, params) {
|
addPanel({ commit, dispatch, getters }, params) {
|
||||||
|
const { panelType } = params
|
||||||
let keyColumn = ''
|
let keyColumn = ''
|
||||||
let selectionColumn = []
|
let selectionColumn = []
|
||||||
let identifierColumns = []
|
let identifierColumns = []
|
||||||
let count = 0
|
let count = 0
|
||||||
|
|
||||||
if (params.fieldList) {
|
if (params.fieldList) {
|
||||||
params.fieldList.forEach(itemField => {
|
params.fieldList.forEach((itemField, index, listFields) => {
|
||||||
if (itemField.isKey) {
|
if (itemField.isKey) {
|
||||||
keyColumn = itemField.columnName
|
keyColumn = itemField.columnName
|
||||||
}
|
}
|
||||||
@ -77,15 +78,15 @@ const panel = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.panelType === 'table' || params.isAdvancedQuery) {
|
if (panelType === 'table' || params.isAdvancedQuery) {
|
||||||
itemField.isShowedFromUser = false
|
itemField.isShowedFromUser = false
|
||||||
if (count < 2 && itemField.isSelectionColumn && itemField.sequence >= 10) {
|
if (count < 2 && itemField.isSelectionColumn && itemField.sequence >= 10) {
|
||||||
itemField.isShowedFromUser = true
|
itemField.isShowedFromUser = true
|
||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (['browser', 'process', 'report'].includes(params.panelType) ||
|
if (['browser', 'process', 'report', 'custom'].includes(panelType) ||
|
||||||
params.panelType === 'window' && params.isParentTab) {
|
panelType === 'window' && params.isParentTab) {
|
||||||
dispatch('setContext', {
|
dispatch('setContext', {
|
||||||
parentUuid: params.parentUuid,
|
parentUuid: params.parentUuid,
|
||||||
containerUuid: params.uuid,
|
containerUuid: params.uuid,
|
||||||
@ -93,11 +94,24 @@ const panel = {
|
|||||||
value: itemField.value
|
value: itemField.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get dependent fields
|
||||||
|
if (!isEmptyValue(itemField.parentFieldsList) && itemField.isActive) {
|
||||||
|
itemField.parentFieldsList.forEach(parentColumnName => {
|
||||||
|
const parentField = listFields.find(parentFieldItem => {
|
||||||
|
return parentFieldItem.columnName === parentColumnName &&
|
||||||
|
parentColumnName !== itemField.columnName
|
||||||
|
})
|
||||||
|
if (parentField) {
|
||||||
|
parentField.dependentFieldsList.push(itemField.columnName)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let orderBy = 'sequence'
|
let orderBy = 'sequence'
|
||||||
if ((params.panelType === 'window' && !params.isParentTab) || params.panelType === 'browser') {
|
if ((panelType === 'window' && !params.isParentTab) || panelType === 'browser') {
|
||||||
orderBy = 'seqNoGrid'
|
orderBy = 'seqNoGrid'
|
||||||
}
|
}
|
||||||
params.fieldList = assignedGroup({
|
params.fieldList = assignedGroup({
|
||||||
@ -125,6 +139,7 @@ const panel = {
|
|||||||
params.isShowedTableOptionalColumns = false
|
params.isShowedTableOptionalColumns = false
|
||||||
|
|
||||||
commit('addPanel', params)
|
commit('addPanel', params)
|
||||||
|
return params
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Used by components/fields/filterFields
|
* Used by components/fields/filterFields
|
||||||
|
@ -6,7 +6,8 @@ import { showMessage } from '@/utils/ADempiere/notification'
|
|||||||
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
||||||
import language from '@/lang'
|
import language from '@/lang'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { generateField, getFieldTemplate } from '@/utils/ADempiere/dictionaryUtils'
|
import { generateField } from '@/utils/ADempiere/dictionaryUtils'
|
||||||
|
import { getFieldTemplate } from '@/utils/ADempiere/lookupFactory'
|
||||||
|
|
||||||
const initStateWindow = {
|
const initStateWindow = {
|
||||||
window: [],
|
window: [],
|
||||||
@ -286,21 +287,6 @@ const window = {
|
|||||||
|
|
||||||
let isTabsChildren = false
|
let isTabsChildren = false
|
||||||
if (!isAdvancedQuery) {
|
if (!isAdvancedQuery) {
|
||||||
// Get dependent fields
|
|
||||||
fieldsList
|
|
||||||
.forEach((field, index, list) => {
|
|
||||||
if (field.parentFieldsList.length && field.isActive) {
|
|
||||||
field.parentFieldsList.forEach(parentColumnName => {
|
|
||||||
const parentField = list.find(parentField => {
|
|
||||||
return parentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
|
||||||
})
|
|
||||||
if (parentField) {
|
|
||||||
parentField.dependentFieldsList.push(field.columnName)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const window = getters.getWindow(parentUuid)
|
const window = getters.getWindow(parentUuid)
|
||||||
isTabsChildren = Boolean(window.tabsListChildren.length)
|
isTabsChildren = Boolean(window.tabsListChildren.length)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import evaluator from '@/utils/ADempiere/evaluator'
|
import evaluator from '@/utils/ADempiere/evaluator'
|
||||||
import { isEmptyValue, parsedValueComponent } from '@/utils/ADempiere/valueUtils'
|
import { isEmptyValue, parsedValueComponent } from '@/utils/ADempiere/valueUtils'
|
||||||
import { getContext, getParentFields, getPreference, parseContext } from '@/utils/ADempiere/contextUtils'
|
import { getContext, getParentFields, getPreference, parseContext } from '@/utils/ADempiere/contextUtils'
|
||||||
import REFERENCES, { FIELD_NOT_SHOWED } from '@/utils/ADempiere/references'
|
import REFERENCES, { FIELDS_HIDDEN } from '@/utils/ADempiere/references'
|
||||||
import { FIELD_DISPLAY_SIZES, DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
|
import FIELDS_DISPLAY_SIZES, { DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
|
||||||
import language from '@/lang'
|
import language from '@/lang'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +24,7 @@ export function generateField({
|
|||||||
isShowedFromUser = moreAttributes.isShowedFromUser
|
isShowedFromUser = moreAttributes.isShowedFromUser
|
||||||
}
|
}
|
||||||
|
|
||||||
const componentReference = evalutateTypeField(fieldToGenerate.displayType, true)
|
const componentReference = evalutateTypeField(fieldToGenerate.displayType)
|
||||||
const referenceType = componentReference.alias[0]
|
const referenceType = componentReference.alias[0]
|
||||||
let isDisplayedFromLogic = fieldToGenerate.isDisplayed
|
let isDisplayedFromLogic = fieldToGenerate.isDisplayed
|
||||||
let isMandatoryFromLogic = false
|
let isMandatoryFromLogic = false
|
||||||
@ -194,14 +194,14 @@ export function generateField({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sizes from panel and groups
|
// Sizes from panel and groups
|
||||||
field.sizeFieldFromType = FIELD_DISPLAY_SIZES.find(item => {
|
field.sizeFieldFromType = FIELDS_DISPLAY_SIZES.find(item => {
|
||||||
return item.type === field.componentPath
|
return item.type === field.componentPath
|
||||||
})
|
})
|
||||||
if (field.sizeFieldFromType === undefined) {
|
if (field.sizeFieldFromType === undefined) {
|
||||||
console.warn(`Field size no found: ${field.name} type: ${field.componentPath}.`)
|
console.warn(`Field size no found: ${field.name} type: ${field.componentPath}.`)
|
||||||
field.sizeFieldFromType = {
|
field.sizeFieldFromType = {
|
||||||
type: field.componentPath,
|
type: field.componentPath,
|
||||||
size: DEFAULT_SIZE
|
size: DEFAULT_SIZE.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ export function generateField({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hidden field type button
|
// hidden field type button
|
||||||
const notShowedField = FIELD_NOT_SHOWED.find(itemField => {
|
const notShowedField = FIELDS_HIDDEN.find(itemField => {
|
||||||
return field.displayType === itemField.id
|
return field.displayType === itemField.id
|
||||||
})
|
})
|
||||||
if (notShowedField) {
|
if (notShowedField) {
|
||||||
@ -279,21 +279,6 @@ export function generateProcess({ processToGenerate, containerUuidAssociated = u
|
|||||||
return field
|
return field
|
||||||
})
|
})
|
||||||
fieldDefinitionList = fieldDefinitionList.concat(fieldsRangeList)
|
fieldDefinitionList = fieldDefinitionList.concat(fieldsRangeList)
|
||||||
|
|
||||||
// Get dependent fields
|
|
||||||
fieldDefinitionList
|
|
||||||
.forEach((field, index, list) => {
|
|
||||||
if (field.isActive && field.parentFieldsList.length) {
|
|
||||||
field.parentFieldsList.forEach(parentColumnName => {
|
|
||||||
const parentField = list.find(itemParentField => {
|
|
||||||
return itemParentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
|
||||||
})
|
|
||||||
if (parentField) {
|
|
||||||
parentField.dependentFieldsList.push(field.columnName)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default Action
|
// Default Action
|
||||||
@ -405,7 +390,7 @@ export function generateProcess({ processToGenerate, containerUuidAssociated = u
|
|||||||
* @param {boolean} isAllInfo
|
* @param {boolean} isAllInfo
|
||||||
* @return string type, assigned value to folder after evaluating the parameter
|
* @return string type, assigned value to folder after evaluating the parameter
|
||||||
*/
|
*/
|
||||||
export function evalutateTypeField(displayTypeId, isAllInfo = false) {
|
export function evalutateTypeField(displayTypeId, isAllInfo = true) {
|
||||||
const component = REFERENCES.find(reference => displayTypeId === reference.id)
|
const component = REFERENCES.find(reference => displayTypeId === reference.id)
|
||||||
if (isAllInfo) {
|
if (isAllInfo) {
|
||||||
return component
|
return component
|
||||||
@ -413,79 +398,6 @@ export function evalutateTypeField(displayTypeId, isAllInfo = false) {
|
|||||||
return component.type
|
return component.type
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default template for injected fields
|
|
||||||
export function getFieldTemplate(attributesOverwrite) {
|
|
||||||
return {
|
|
||||||
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: {
|
|
||||||
tableName: '',
|
|
||||||
keyColumnName: '',
|
|
||||||
displayColumnName: '',
|
|
||||||
query: '',
|
|
||||||
parsedQuery: '',
|
|
||||||
directQuery: '',
|
|
||||||
parsedDirectQuery: '',
|
|
||||||
validationCode: '',
|
|
||||||
windowsList: []
|
|
||||||
},
|
|
||||||
contextInfo: undefined,
|
|
||||||
isShowedFromUser: false,
|
|
||||||
isFixedTableColumn: false,
|
|
||||||
sizeFieldFromType: {
|
|
||||||
type: 'Button',
|
|
||||||
size: DEFAULT_SIZE
|
|
||||||
},
|
|
||||||
...attributesOverwrite
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [assignedGroup]
|
* [assignedGroup]
|
||||||
* @param {array} fieldList Field of List with
|
* @param {array} fieldList Field of List with
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
// - tableName:
|
// - tableName:
|
||||||
// Date and Time:
|
// Date and Time:
|
||||||
// - isRange
|
// - isRange
|
||||||
|
// - vFormat
|
||||||
// - valueTo
|
// - valueTo
|
||||||
// - valueMax
|
// - valueMax
|
||||||
// - valueMin
|
// - valueMin
|
||||||
@ -40,41 +41,308 @@
|
|||||||
// - fieldLength
|
// - fieldLength
|
||||||
// Select:
|
// Select:
|
||||||
// - isSelectCreated (created from ui for multi-selection)
|
// - isSelectCreated (created from ui for multi-selection)
|
||||||
// - reference.query
|
// - query
|
||||||
// - reference.directQuery
|
// - directQuery
|
||||||
// - reference.tableName
|
// - tableName
|
||||||
// - displayColumn
|
// - displayColumn
|
||||||
// - defaultValue
|
// - defaultValue
|
||||||
|
|
||||||
import REFERENCES, { TEXT } from '@/utils/ADempiere/references'
|
import { TEXT, TABLE_DIRECT } from '@/utils/ADempiere/references'
|
||||||
|
import { evalutateTypeField } from '@/utils/ADempiere/dictionaryUtils'
|
||||||
|
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
|
||||||
|
import evaluator, { getContext, getParentFields } from '@/utils/ADempiere/contextUtils'
|
||||||
|
import FIELDS_DISPLAY_SIZES, { DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
|
||||||
|
import store from '@/store'
|
||||||
|
|
||||||
export function createField({
|
// Create a Field from UUID based on server meta-data
|
||||||
|
export function createFieldDictionary({
|
||||||
containerUuid,
|
containerUuid,
|
||||||
displayType = TEXT.id,
|
fieldUuid,
|
||||||
columnName,
|
columnUuid,
|
||||||
name,
|
elementUuid,
|
||||||
isMandatory = false,
|
elementColumnName,
|
||||||
isReadOnly = false
|
tableName,
|
||||||
|
columnName
|
||||||
}) {
|
}) {
|
||||||
const metadata = {
|
let field
|
||||||
isCustomField: true,
|
if (fieldUuid) {
|
||||||
containerUuid: containerUuid,
|
field = store.getters.getFieldFromUuid(fieldUuid)
|
||||||
columnName: columnName,
|
} else if (columnUuid) {
|
||||||
name: name,
|
field = store.getters.getFieldFromColumnUuid(columnUuid)
|
||||||
displayType: displayType,
|
} else if (elementUuid) {
|
||||||
isActive: true,
|
field = store.getters.getFieldFromElementUuid(elementUuid)
|
||||||
isMandatory: isMandatory,
|
} if (elementColumnName) {
|
||||||
isReadOnly: isReadOnly,
|
field = store.getters.getFieldFromElementColumnName(elementColumnName)
|
||||||
isDisplayed: true,
|
} else if (tableName && columnName) {
|
||||||
isDisplayedFromLogic: true,
|
field = store.getters.getFieldFromElementColumnName({
|
||||||
isShowedFromUser: true,
|
tableName,
|
||||||
componentPath: REFERENCES.find(reference => reference.id === displayType).type
|
columnName
|
||||||
|
})
|
||||||
}
|
}
|
||||||
// Special cases
|
if (!isEmptyValue(field)) {
|
||||||
// Please if you need use a special case remember that already exists many implementations
|
return getFactoryFromField({ containerUuid, field })
|
||||||
|
}
|
||||||
|
return new Promise(resolve => {
|
||||||
|
store.dispatch('getFieldFromServer', {
|
||||||
|
fieldUuid,
|
||||||
|
columnUuid,
|
||||||
|
elementUuid,
|
||||||
|
elementColumnName,
|
||||||
|
tableName,
|
||||||
|
columnName
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
resolve(getFactoryFromField({
|
||||||
|
containerUuid: containerUuid,
|
||||||
|
field: response
|
||||||
|
}))
|
||||||
|
}).catch(error => {
|
||||||
|
console.warn(`LookupFactory: Get Field From Server (State) - Error ${error.code}: ${error.message}.`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert field getted from server to factory
|
||||||
|
function getFactoryFromField({
|
||||||
|
containerUuid,
|
||||||
|
field
|
||||||
|
}) {
|
||||||
|
return createField({
|
||||||
|
containerUuid: containerUuid,
|
||||||
|
columnName: field.columnName,
|
||||||
|
definition: {
|
||||||
|
displayType: field.displayType,
|
||||||
|
tableName: field.reference.tableName,
|
||||||
|
directQuery: field.directQuery,
|
||||||
|
query: field.reference.query,
|
||||||
|
keyColumnName: field.reference.keyColumnName,
|
||||||
|
validationCode: field.reference.validationCode,
|
||||||
|
windowsList: field.reference.windowsList,
|
||||||
|
id: field.id,
|
||||||
|
uuid: field.uuid,
|
||||||
|
name: field.name,
|
||||||
|
description: field.description,
|
||||||
|
help: field.help,
|
||||||
|
fieldGroup: field.fieldGroup,
|
||||||
|
isFieldOnly: field.isFieldOnly,
|
||||||
|
isRange: field.isRange,
|
||||||
|
isSameLine: field.isSameLine,
|
||||||
|
sequence: field.sequence,
|
||||||
|
seqNoGrid: field.seqNoGrid,
|
||||||
|
isIdentifier: field.isIdentifier,
|
||||||
|
isKey: field.isKey,
|
||||||
|
isSelectionColumn: field.isSelectionColumn,
|
||||||
|
isUpdateable: field.isUpdateable,
|
||||||
|
formatPattern: field.formatPattern,
|
||||||
|
vFormat: field.vFormat,
|
||||||
|
defaultValue: field.defaultValue,
|
||||||
|
defaultValueTo: field.defaultValueTo,
|
||||||
|
valueMin: field.valueMin,
|
||||||
|
valueMax: field.valueMax,
|
||||||
|
isActive: field.isActive,
|
||||||
|
isMandatory: field.isMandatory,
|
||||||
|
isReadOnly: field.isReadOnly,
|
||||||
|
isDisplayedFromLogic: field.isDisplayedFromLogic,
|
||||||
|
isReadOnlyFromLogic: field.isReadOnlyFromLogic,
|
||||||
|
isMandatoryFromLogic: field.isMandatoryFromLogic,
|
||||||
|
callout: field.callout,
|
||||||
|
isQueryCriteria: field.isQueryCriteria,
|
||||||
|
displayLogic: field.displayLogic,
|
||||||
|
mandatoryLogic: field.mandatoryLogic,
|
||||||
|
readOnlyLogic: field.readOnlyLogic,
|
||||||
|
parentFieldsList: field.parentFieldsList,
|
||||||
|
dependentFieldsList: field.dependentFieldsList,
|
||||||
|
contextInfo: field.contextInfo
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a field, it assumed that you define all behavior from source code
|
||||||
|
export function createField({
|
||||||
|
parentUuid,
|
||||||
|
containerUuid,
|
||||||
|
columnName,
|
||||||
|
definition = {}
|
||||||
|
}) {
|
||||||
|
if (!isEmptyValue(definition)) {
|
||||||
|
if (isEmptyValue(definition.displayType)) {
|
||||||
|
definition.displayType = TEXT.id
|
||||||
|
} else if (definition.displayType === TABLE_DIRECT.id &&
|
||||||
|
isEmptyValue(definition.tableName) &&
|
||||||
|
columnName.indexOf('_ID') > 0) {
|
||||||
|
definition.tableName = columnName.replace('_ID', '')
|
||||||
|
}
|
||||||
|
if (isEmptyValue(definition.isActive)) {
|
||||||
|
definition.isActive = true
|
||||||
|
}
|
||||||
|
if (isEmptyValue(definition.isDisplayed)) {
|
||||||
|
definition.isDisplayed = true
|
||||||
|
}
|
||||||
|
if (isEmptyValue(definition.isDisplayedFromLogic)) {
|
||||||
|
definition.isDisplayedFromLogic = true
|
||||||
|
}
|
||||||
|
if (isEmptyValue(definition.isReadOnly)) {
|
||||||
|
definition.isReadOnly = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEmptyValue(definition.isMandatory)) {
|
||||||
|
definition.isMandatory = false
|
||||||
|
}
|
||||||
|
if (isEmptyValue(definition.sequence)) {
|
||||||
|
definition.sequence = 0
|
||||||
|
if (definition.isDisplayed) {
|
||||||
|
definition.sequence = 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let reference = {}
|
||||||
|
if (!isEmptyValue(definition.directQuery) || !isEmptyValue(definition.query)) {
|
||||||
|
reference = {
|
||||||
|
directQuery: definition.directQuery,
|
||||||
|
query: definition.query,
|
||||||
|
tableName: definition.tableName || undefined,
|
||||||
|
keyColumnName: definition.keyColumnName || undefined,
|
||||||
|
validationCode: definition.validationCode || undefined,
|
||||||
|
windowsList: definition.windowsList || []
|
||||||
|
}
|
||||||
|
delete definition.directQuery
|
||||||
|
delete definition.query
|
||||||
|
delete definition.tableName
|
||||||
|
delete definition.validationCode
|
||||||
|
delete definition.windowsList
|
||||||
|
}
|
||||||
|
definition.reference = reference
|
||||||
|
}
|
||||||
|
// if(isLookup()) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// // Special cases
|
||||||
|
// // Please if you need use a special case remember that already exists many implementations
|
||||||
// switch (displayType) {
|
// switch (displayType) {
|
||||||
// case TEXT.id:
|
// case TEXT.id:
|
||||||
// break
|
// break
|
||||||
// }
|
// }
|
||||||
return metadata
|
return getFieldTemplate({
|
||||||
|
...definition,
|
||||||
|
isShowedFromUser: true,
|
||||||
|
isCustomField: true,
|
||||||
|
parentUuid,
|
||||||
|
containerUuid,
|
||||||
|
columnName
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default template for injected fields
|
||||||
|
export function getFieldTemplate(attributesOverwrite) {
|
||||||
|
let displayType = 10
|
||||||
|
if (!isEmptyValue(attributesOverwrite.displayType)) {
|
||||||
|
displayType = attributesOverwrite.displayType
|
||||||
|
}
|
||||||
|
|
||||||
|
const componentReference = evalutateTypeField(displayType)
|
||||||
|
const referenceType = componentReference.alias[0]
|
||||||
|
|
||||||
|
let sizeFieldFromType = FIELDS_DISPLAY_SIZES.find(item => {
|
||||||
|
return item.type === componentReference.type
|
||||||
|
})
|
||||||
|
if (isEmptyValue(sizeFieldFromType)) {
|
||||||
|
sizeFieldFromType = {
|
||||||
|
type: referenceType,
|
||||||
|
size: DEFAULT_SIZE.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const fieldTemplateMetadata = {
|
||||||
|
id: 0,
|
||||||
|
uuid: '',
|
||||||
|
name: '',
|
||||||
|
description: '',
|
||||||
|
help: '',
|
||||||
|
columnName: '',
|
||||||
|
fieldGroup: {
|
||||||
|
name: '',
|
||||||
|
fieldGroupType: ''
|
||||||
|
},
|
||||||
|
displayType,
|
||||||
|
componentPath: componentReference.type,
|
||||||
|
referenceType,
|
||||||
|
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: undefined,
|
||||||
|
isReadOnlyFromLogic: undefined,
|
||||||
|
isMandatoryFromLogic: undefined,
|
||||||
|
// browser attributes
|
||||||
|
callout: undefined,
|
||||||
|
isQueryCriteria: false,
|
||||||
|
displayLogic: undefined,
|
||||||
|
mandatoryLogic: undefined,
|
||||||
|
readOnlyLogic: undefined,
|
||||||
|
parentFieldsList: undefined,
|
||||||
|
dependentFieldsList: [],
|
||||||
|
reference: {
|
||||||
|
tableName: '',
|
||||||
|
keyColumnName: '',
|
||||||
|
query: '',
|
||||||
|
directQuery: '',
|
||||||
|
validationCode: '',
|
||||||
|
windowsList: []
|
||||||
|
},
|
||||||
|
contextInfo: undefined,
|
||||||
|
isShowedFromUser: false,
|
||||||
|
isFixedTableColumn: false,
|
||||||
|
sizeFieldFromType,
|
||||||
|
...attributesOverwrite
|
||||||
|
}
|
||||||
|
|
||||||
|
// get parsed parent fields list
|
||||||
|
fieldTemplateMetadata.parentFieldsList = getParentFields(fieldTemplateMetadata)
|
||||||
|
|
||||||
|
// evaluate logics
|
||||||
|
const setEvaluateLogics = {
|
||||||
|
parentUuid: fieldTemplateMetadata.parentUuid,
|
||||||
|
containerUuid: fieldTemplateMetadata.containerUuid,
|
||||||
|
context: getContext
|
||||||
|
}
|
||||||
|
if (!isEmptyValue(fieldTemplateMetadata.displayLogic)) {
|
||||||
|
fieldTemplateMetadata.isDisplayedFromLogic = evaluator.evaluateLogic({
|
||||||
|
...setEvaluateLogics,
|
||||||
|
logic: fieldTemplateMetadata.displayLogic
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!isEmptyValue(fieldTemplateMetadata.mandatoryLogic)) {
|
||||||
|
fieldTemplateMetadata.isMandatoryFromLogic = evaluator.evaluateLogic({
|
||||||
|
...setEvaluateLogics,
|
||||||
|
logic: fieldTemplateMetadata.mandatoryLogic
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!isEmptyValue(fieldTemplateMetadata.readOnlyLogic)) {
|
||||||
|
fieldTemplateMetadata.isReadOnlyFromLogic = evaluator.evaluateLogic({
|
||||||
|
...setEvaluateLogics,
|
||||||
|
logic: fieldTemplateMetadata.readOnlyLogic
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return fieldTemplateMetadata
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@ export const COLOR = {
|
|||||||
alias: ['Color']
|
alias: ['Color']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cost or Prices
|
||||||
export const COSTS_PLUS_PRICES = {
|
export const COSTS_PLUS_PRICES = {
|
||||||
id: 37,
|
id: 37,
|
||||||
type: 'FieldNumber',
|
type: 'FieldNumber',
|
||||||
@ -272,7 +273,7 @@ export const TABLE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Table Dir
|
// Table Dir
|
||||||
export const TABLE_DIR = {
|
export const TABLE_DIRECT = {
|
||||||
id: 19,
|
id: 19,
|
||||||
type: 'FieldSelect',
|
type: 'FieldSelect',
|
||||||
support: true,
|
support: true,
|
||||||
@ -331,6 +332,19 @@ export const YES_NO = {
|
|||||||
alias: ['YesNo', 'Yes No', 'Yes-No']
|
alias: ['YesNo', 'Yes No', 'Yes-No']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some helper methods
|
||||||
|
export function isLookup(displayType) {
|
||||||
|
return displayType === LIST.id ||
|
||||||
|
displayType === TABLE.id ||
|
||||||
|
displayType === TABLE_DIRECT.id ||
|
||||||
|
displayType === SEARCH.id ||
|
||||||
|
displayType === ACCOUNT_ELEMENT.id ||
|
||||||
|
displayType === LOCATION_ADDRESS.id ||
|
||||||
|
displayType === LOCATOR_WAREHOUSE.id ||
|
||||||
|
displayType === PRODUCT_ATTRIBUTE.id ||
|
||||||
|
displayType === RESOURCE_ASSIGNMENT.id
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All references
|
* All references
|
||||||
* {number} id: Identifiert to field reference
|
* {number} id: Identifiert to field reference
|
||||||
@ -365,80 +379,36 @@ const REFERENCES = [
|
|||||||
SEARCH,
|
SEARCH,
|
||||||
CHAR,
|
CHAR,
|
||||||
TABLE,
|
TABLE,
|
||||||
TABLE_DIR,
|
TABLE_DIRECT,
|
||||||
TEXT,
|
TEXT,
|
||||||
TEXT_LONG,
|
TEXT_LONG,
|
||||||
TIME,
|
TIME,
|
||||||
URL,
|
URL,
|
||||||
YES_NO
|
YES_NO
|
||||||
]
|
]
|
||||||
|
|
||||||
export default REFERENCES
|
export default REFERENCES
|
||||||
|
|
||||||
export const FIELD_RANGE = [
|
export const FIELDS_RANGE = [
|
||||||
{
|
NUMBER,
|
||||||
id: 12,
|
COSTS_PLUS_PRICES,
|
||||||
type: 'Amount',
|
DATE,
|
||||||
description: 'Number with 4 decimals',
|
DATE_PLUS_TIME,
|
||||||
alias: ['Amount']
|
INTEGER,
|
||||||
},
|
FLOAT,
|
||||||
{
|
QUANTITY,
|
||||||
id: 37,
|
TIME
|
||||||
type: 'Costs+Prices',
|
|
||||||
description: 'Costs + Prices (minimum currency precision but if exists more)',
|
|
||||||
alias: ['Costs+Prices', 'CostsPrices', 'Cost Prices']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 15,
|
|
||||||
type: 'Date',
|
|
||||||
description: 'Date mm/dd/yyyy',
|
|
||||||
alias: ['Date']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 16,
|
|
||||||
type: 'DateTime',
|
|
||||||
description: 'Date with time',
|
|
||||||
alias: ['DateTime', 'Date Time', 'Date+Time']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 11,
|
|
||||||
type: 'Integer',
|
|
||||||
description: '10 Digit numeric',
|
|
||||||
alias: ['Integer']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 22,
|
|
||||||
type: 'Number',
|
|
||||||
description: 'Float Number',
|
|
||||||
alias: ['Number']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 29,
|
|
||||||
type: 'Quantity',
|
|
||||||
description: 'Quantity data type',
|
|
||||||
alias: ['Quantity']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 24,
|
|
||||||
type: 'Time',
|
|
||||||
description: 'Time',
|
|
||||||
alias: ['Time']
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
|
/**
|
||||||
export const FIELD_NOT_SHOWED = [
|
* Fields not showed in panel's
|
||||||
{
|
*/
|
||||||
id: 28,
|
export const FIELDS_HIDDEN = [
|
||||||
type: 'Button',
|
BUTTON
|
||||||
description: 'Command Button - starts a process',
|
|
||||||
alias: ['Button']
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields with this column name, changed all fields is read only
|
* Fields with this column name, changed all fields is read only
|
||||||
*/
|
*/
|
||||||
export const FIELD_READ_ONLY_FORM = [
|
export const FIELDS_READ_ONLY_FORM = [
|
||||||
{
|
{
|
||||||
columnName: 'IsActive', // column name of field
|
columnName: 'IsActive', // column name of field
|
||||||
defaultValue: true, // default value when loading
|
defaultValue: true, // default value when loading
|
||||||
|
@ -1,20 +1,35 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form>
|
<div class="wrapper">
|
||||||
<el-row
|
<el-form
|
||||||
|
v-if="isLoaded"
|
||||||
|
key="form-loaded"
|
||||||
|
label-position="top"
|
||||||
|
label-width="200px"
|
||||||
|
>
|
||||||
|
<el-row>
|
||||||
|
<field
|
||||||
v-for="(metadata) in metadataList"
|
v-for="(metadata) in metadataList"
|
||||||
:key="metadata.columnName"
|
:key="metadata.columnName"
|
||||||
>
|
|
||||||
<field
|
|
||||||
:metadata-field="metadata"
|
:metadata-field="metadata"
|
||||||
/>
|
/>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
key="form-loading"
|
||||||
|
v-loading="!isLoaded"
|
||||||
|
:element-loading-text="$t('notifications.loading')"
|
||||||
|
element-loading-spinner="el-icon-loading"
|
||||||
|
element-loading-background="rgba(255, 255, 255, 0.8)"
|
||||||
|
class="loading-panel"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Field from '@/components/ADempiere/Field'
|
import Field from '@/components/ADempiere/Field'
|
||||||
import { createField } from '@/utils/ADempiere/lookupFactory'
|
import { createField, createFieldDictionary } from '@/utils/ADempiere/lookupFactory'
|
||||||
import { URL, TEXT, NUMBER, INTEGER, TEXT_LONG } from '@/utils/ADempiere/references'
|
import { URL, TEXT, NUMBER, INTEGER, TEXT_LONG, TABLE_DIRECT } from '@/utils/ADempiere/references'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TestView',
|
name: 'TestView',
|
||||||
@ -23,47 +38,173 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
metadataList: []
|
metadataList: [],
|
||||||
|
panelMetadata: {},
|
||||||
|
isLoaded: false,
|
||||||
|
panelUuid: 'Test-View',
|
||||||
|
panelType: 'custom'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
getterPanel() {
|
||||||
|
return this.$store.getters.getPanel(this.panelUuid)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.getPanel()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getPanel() {
|
||||||
|
const panel = this.getterPanel
|
||||||
|
if (panel) {
|
||||||
|
this.metadataList = panel.fieldList
|
||||||
|
this.isLoaded = true
|
||||||
|
} else {
|
||||||
|
this.setFieldsList()
|
||||||
|
this.$store.dispatch('addPanel', {
|
||||||
|
name: 'Test View',
|
||||||
|
uuid: this.panelUuid,
|
||||||
|
panelType: this.panelType,
|
||||||
|
fieldList: this.metadataList
|
||||||
|
})
|
||||||
|
.then(responsePanel => {
|
||||||
|
this.metadataList = responsePanel.fieldList
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.isLoaded = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setFieldsList() {
|
||||||
|
const fieldsList = []
|
||||||
|
|
||||||
|
let sequence = 10
|
||||||
// URL
|
// URL
|
||||||
this.metadataList.push(createField({
|
fieldsList.push(createField({
|
||||||
|
containerUuid: this.panelUuid,
|
||||||
columnName: 'URL',
|
columnName: 'URL',
|
||||||
|
definition: {
|
||||||
name: 'Web',
|
name: 'Web',
|
||||||
displayType: URL.id
|
displayType: URL.id,
|
||||||
}))
|
panelType: this.panelType,
|
||||||
// Text
|
sequence
|
||||||
this.metadataList.push(createField({
|
}
|
||||||
columnName: 'Name',
|
|
||||||
name: 'Only Name',
|
|
||||||
displayType: TEXT.id
|
|
||||||
}))
|
|
||||||
// Amount
|
|
||||||
this.metadataList.push(createField({
|
|
||||||
columnName: 'Amount',
|
|
||||||
name: 'Amount for it',
|
|
||||||
displayType: NUMBER.id
|
|
||||||
}))
|
|
||||||
// Integer
|
|
||||||
this.metadataList.push(createField({
|
|
||||||
columnName: 'SeqNo',
|
|
||||||
name: 'Sequence for record',
|
|
||||||
displayType: INTEGER.id
|
|
||||||
}))
|
|
||||||
// Text Long
|
|
||||||
this.metadataList.push(createField({
|
|
||||||
columnName: 'Description',
|
|
||||||
name: 'Only Description',
|
|
||||||
displayType: TEXT_LONG.id
|
|
||||||
}))
|
}))
|
||||||
|
// From Field UUID
|
||||||
|
createFieldDictionary({
|
||||||
|
containerUuid: this.panelUuid,
|
||||||
|
fieldUuid: '8ceabe8a-fb40-11e8-a479-7a0060f0aa01'
|
||||||
|
})
|
||||||
|
.then(metadata => {
|
||||||
|
fieldsList.push(metadata)
|
||||||
|
}).catch(error => {
|
||||||
|
console.warn(`LookupFactory: Get Field From Server (State) - Error ${error.code}: ${error.message}.`)
|
||||||
|
})
|
||||||
|
// From Column UUID
|
||||||
|
createFieldDictionary({
|
||||||
|
containerUuid: this.panelUuid,
|
||||||
|
columnUuid: '8b4bbb7e-fb40-11e8-a479-7a0060f0aa01'
|
||||||
|
})
|
||||||
|
.then(metadata => {
|
||||||
|
fieldsList.push(metadata)
|
||||||
|
}).catch(error => {
|
||||||
|
console.warn(`LookupFactory: Get Field From Server (State) - Error ${error.code}: ${error.message}.`)
|
||||||
|
})
|
||||||
|
// From Element Column Name
|
||||||
|
createFieldDictionary({
|
||||||
|
containerUuid: this.panelUuid,
|
||||||
|
elementColumnName: 'M_RMA_ID'
|
||||||
|
})
|
||||||
|
.then(metadata => {
|
||||||
|
fieldsList.push(metadata)
|
||||||
|
}).catch(error => {
|
||||||
|
console.warn(`LookupFactory: Get Field From Server (State) - Error ${error.code}: ${error.message}.`)
|
||||||
|
})
|
||||||
|
// From Table and Column Name
|
||||||
|
createFieldDictionary({
|
||||||
|
containerUuid: this.panelUuid,
|
||||||
|
tableName: 'C_BPartner',
|
||||||
|
columnName: 'PaymentRule'
|
||||||
|
})
|
||||||
|
.then(metadata => {
|
||||||
|
fieldsList.push(metadata)
|
||||||
|
}).catch(error => {
|
||||||
|
console.warn(`LookupFactory: Get Field From Server (State) - Error ${error.code}: ${error.message}.`)
|
||||||
|
})
|
||||||
// Table direct
|
// Table direct
|
||||||
// To be define
|
// To be define
|
||||||
// this.metadataList.push(createField({
|
sequence = sequence + 10
|
||||||
// columnName: 'C_Country',
|
fieldsList.push(createField({
|
||||||
// name: 'Country',
|
containerUuid: this.panelUuid,
|
||||||
// displayType: TABLE_DIR.id
|
columnName: 'C_Currency_ID',
|
||||||
// }))
|
definition: {
|
||||||
|
name: 'Currency',
|
||||||
|
displayType: TABLE_DIRECT.id,
|
||||||
|
panelType: this.panelType,
|
||||||
|
keyColumn: 'C_Currency.C_Currency_ID',
|
||||||
|
directQuery: 'SELECT C_Currency.C_Currency_ID,NULL,C_Currency.ISO_Code,C_Currency.IsActive FROM C_Currency WHERE C_Currency.C_Currency_ID=?',
|
||||||
|
query: 'SELECT C_Currency.C_Currency_ID,NULL,C_Currency.ISO_Code,C_Currency.IsActive FROM C_Currency ORDER BY 3',
|
||||||
|
sequence
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
sequence = sequence + 10
|
||||||
|
// Text
|
||||||
|
fieldsList.push(createField({
|
||||||
|
containerUuid: this.panelUuid,
|
||||||
|
columnName: 'Name',
|
||||||
|
definition: {
|
||||||
|
name: 'Only Name',
|
||||||
|
displayType: TEXT.id,
|
||||||
|
panelType: this.panelType,
|
||||||
|
displayLogic: '@URL@!""',
|
||||||
|
sequence
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
sequence = sequence + 10
|
||||||
|
// Amount
|
||||||
|
fieldsList.push(createField({
|
||||||
|
containerUuid: this.panelUuid,
|
||||||
|
columnName: 'Amount',
|
||||||
|
definition: {
|
||||||
|
name: 'Amount for it',
|
||||||
|
displayType: NUMBER.id,
|
||||||
|
panelType: this.panelType,
|
||||||
|
readOnlyLogic: '@C_Currency_ID@<>""',
|
||||||
|
sequence
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
sequence = sequence + 10
|
||||||
|
// Integer
|
||||||
|
fieldsList.push(createField({
|
||||||
|
containerUuid: this.panelUuid,
|
||||||
|
columnName: 'SeqNo',
|
||||||
|
definition: {
|
||||||
|
name: 'Sequence for record',
|
||||||
|
displayType: INTEGER.id,
|
||||||
|
panelType: this.panelType,
|
||||||
|
mandatoryLogic: '@URL@!""',
|
||||||
|
sequence
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
sequence = sequence + 10
|
||||||
|
// Text Long
|
||||||
|
fieldsList.push(createField({
|
||||||
|
containerUuid: this.panelUuid,
|
||||||
|
columnName: 'Description',
|
||||||
|
definition: {
|
||||||
|
name: 'Only Description',
|
||||||
|
displayType: TEXT_LONG.id,
|
||||||
|
panelType: this.panelType,
|
||||||
|
sequence
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
this.metadataList = fieldsList
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user