Does not sort the field list of the child tabs on every render. (#363)
parent
4c399a6694
commit
7ed14ac44e
|
@ -165,7 +165,7 @@
|
||||||
fixed
|
fixed
|
||||||
min-width="50"
|
min-width="50"
|
||||||
/>
|
/>
|
||||||
<template v-for="(fieldAttributes, key) in fieldList">
|
<template v-for="(fieldAttributes, key) in fieldsList">
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-if="isDisplayed(fieldAttributes)"
|
v-if="isDisplayed(fieldAttributes)"
|
||||||
:key="key"
|
:key="key"
|
||||||
|
@ -445,12 +445,20 @@ export default {
|
||||||
}
|
}
|
||||||
return this.getterHeight - 300 - totalRow
|
return this.getterHeight - 300 - totalRow
|
||||||
},
|
},
|
||||||
fieldList() {
|
fieldsList() {
|
||||||
if (this.getterPanel && this.getterPanel.fieldList) {
|
if (this.getterPanel && this.getterPanel.fieldList) {
|
||||||
return this.sortFields(
|
if ((this.panelType === 'window' && this.isParent) || this.panelType === 'browser') {
|
||||||
this.getterPanel.fieldList,
|
let orderBy = 'seqNoGrid'
|
||||||
this.panelType !== 'browser' ? 'seqNoGrid' : 'sequence'
|
if (this.panelType === 'browser') {
|
||||||
)
|
orderBy = 'sequence'
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.sortFields({
|
||||||
|
fieldsList: this.getterPanel.fieldList,
|
||||||
|
orderBy
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return this.getterPanel.fieldList
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
|
@ -727,7 +735,7 @@ export default {
|
||||||
this.$store.dispatch('addNewRow', {
|
this.$store.dispatch('addNewRow', {
|
||||||
parentUuid: this.parentUuid,
|
parentUuid: this.parentUuid,
|
||||||
containerUuid: this.containerUuid,
|
containerUuid: this.containerUuid,
|
||||||
fieldList: this.fieldList,
|
fieldList: this.fieldsList,
|
||||||
isEdit: true,
|
isEdit: true,
|
||||||
isSendServer: false
|
isSendServer: false
|
||||||
})
|
})
|
||||||
|
@ -744,7 +752,7 @@ export default {
|
||||||
},
|
},
|
||||||
async setFocus() {
|
async setFocus() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const fieldFocus = this.fieldList.find(itemField => {
|
const fieldFocus = this.fieldsList.find(itemField => {
|
||||||
if (this.$refs.hasOwnProperty(itemField.columnName)) {
|
if (this.$refs.hasOwnProperty(itemField.columnName)) {
|
||||||
if (fieldIsDisplayed(itemField) && !itemField.isReadOnly && itemField.isUpdateable) {
|
if (fieldIsDisplayed(itemField) && !itemField.isReadOnly && itemField.isUpdateable) {
|
||||||
return true
|
return true
|
||||||
|
@ -939,7 +947,7 @@ export default {
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
this.isLoadPanelFromServer = true
|
this.isLoadPanelFromServer = true
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.warn(`FieldList Load Error ${error.code}: ${error.message}.`)
|
console.warn(`Fields List Load Error ${error.code}: ${error.message}.`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -959,7 +967,7 @@ export default {
|
||||||
sums[index] = 'Σ'
|
sums[index] = 'Σ'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const field = this.fieldList.find(field => field.columnName === columnItem.property)
|
const field = this.fieldsList.find(field => field.columnName === columnItem.property)
|
||||||
if (!FIELDS_QUANTITY.includes(field.referenceType)) {
|
if (!FIELDS_QUANTITY.includes(field.referenceType)) {
|
||||||
sums[index] = ''
|
sums[index] = ''
|
||||||
return
|
return
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { supportedTypes, exportFileFromJson, exportFileZip } from '@/utils/ADemp
|
||||||
import { showNotification } from '@/utils/ADempiere/notification'
|
import { showNotification } from '@/utils/ADempiere/notification'
|
||||||
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
|
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
|
||||||
import { FIELDS_QUANTITY } from '@/components/ADempiere/Field/references'
|
import { FIELDS_QUANTITY } from '@/components/ADempiere/Field/references'
|
||||||
import { sortFields } from '@/utils/ADempiere/dictionaryUtils'
|
|
||||||
|
|
||||||
export const menuTableMixin = {
|
export const menuTableMixin = {
|
||||||
props: {
|
props: {
|
||||||
|
@ -79,18 +78,9 @@ export const menuTableMixin = {
|
||||||
getDataAllRecord() {
|
getDataAllRecord() {
|
||||||
return this.getterDataRecordsAndSelection.record
|
return this.getterDataRecordsAndSelection.record
|
||||||
},
|
},
|
||||||
fieldList() {
|
fieldsList() {
|
||||||
if (this.panelMetadata && this.panelMetadata.fieldList) {
|
if (this.panelMetadata && this.panelMetadata.fieldList) {
|
||||||
let sortAttribute = 'sequence'
|
return this.panelMetadata.fieldList
|
||||||
if (this.panelType === 'browser') {
|
|
||||||
sortAttribute = 'seqNoGrid'
|
|
||||||
}
|
|
||||||
// TODO: Change to destructuring and add isParent attribure to change
|
|
||||||
// orderBy sequence value to seqNoGrid value if isParent is false
|
|
||||||
return this.sortFields(
|
|
||||||
this.panelMetadata.fieldList,
|
|
||||||
sortAttribute
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
|
@ -167,7 +157,6 @@ export const menuTableMixin = {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showNotification,
|
showNotification,
|
||||||
sortFields,
|
|
||||||
closeMenu() {
|
closeMenu() {
|
||||||
// TODO: Validate to dispatch one action
|
// TODO: Validate to dispatch one action
|
||||||
this.$store.dispatch('showMenuTable', {
|
this.$store.dispatch('showMenuTable', {
|
||||||
|
@ -253,7 +242,7 @@ export const menuTableMixin = {
|
||||||
this.$store.dispatch('addNewRow', {
|
this.$store.dispatch('addNewRow', {
|
||||||
parentUuid: this.parentUuid,
|
parentUuid: this.parentUuid,
|
||||||
containerUuid: this.containerUuid,
|
containerUuid: this.containerUuid,
|
||||||
fieldList: this.fieldList,
|
fieldList: this.fieldsList,
|
||||||
isEdit: true,
|
isEdit: true,
|
||||||
isSendServer: false
|
isSendServer: false
|
||||||
})
|
})
|
||||||
|
|
|
@ -95,7 +95,15 @@ const panel = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
params.fieldList = assignedGroup(params.fieldList)
|
|
||||||
|
let orderBy = 'sequence'
|
||||||
|
if ((params.panelType === 'window' && !params.isParent) || params.panelType === 'browser') {
|
||||||
|
orderBy = 'seqNoGrid'
|
||||||
|
}
|
||||||
|
params.fieldList = assignedGroup({
|
||||||
|
fieldsList: params.fieldList,
|
||||||
|
orderBy
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
params.keyColumn = keyColumn
|
params.keyColumn = keyColumn
|
||||||
|
|
|
@ -467,18 +467,21 @@ export function getFieldTemplate(attributesOverwrite) {
|
||||||
* @param {array} fieldList Field of List with
|
* @param {array} fieldList Field of List with
|
||||||
* @return {array} fieldList
|
* @return {array} fieldList
|
||||||
*/
|
*/
|
||||||
export function assignedGroup(fieldList, assignedGroup) {
|
export function assignedGroup({ fieldsList, groupToAssigned, orderBy }) {
|
||||||
if (fieldList === undefined || fieldList.length <= 0) {
|
if (fieldsList === undefined || fieldsList.length <= 0) {
|
||||||
return fieldList
|
return fieldsList
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldList = sortFields(fieldList, 'sequence', 'asc', fieldList[0].panelType)
|
fieldsList = sortFields({
|
||||||
|
fieldsList,
|
||||||
|
orderBy
|
||||||
|
})
|
||||||
|
|
||||||
let firstChangeGroup = false
|
let firstChangeGroup = false
|
||||||
let currentGroup = ''
|
let currentGroup = ''
|
||||||
let typeGroup = ''
|
let typeGroup = ''
|
||||||
|
|
||||||
fieldList.forEach(fieldElement => {
|
fieldsList.forEach(fieldElement => {
|
||||||
if (fieldElement.panelType !== 'window') {
|
if (fieldElement.panelType !== 'window') {
|
||||||
fieldElement.groupAssigned = ''
|
fieldElement.groupAssigned = ''
|
||||||
fieldElement.typeGroupAssigned = ''
|
fieldElement.typeGroupAssigned = ''
|
||||||
|
@ -507,12 +510,12 @@ export function assignedGroup(fieldList, assignedGroup) {
|
||||||
fieldElement.groupAssigned = currentGroup
|
fieldElement.groupAssigned = currentGroup
|
||||||
fieldElement.typeGroupAssigned = typeGroup
|
fieldElement.typeGroupAssigned = typeGroup
|
||||||
|
|
||||||
if (assignedGroup !== undefined) {
|
if (groupToAssigned !== undefined) {
|
||||||
fieldElement.groupAssigned = assignedGroup
|
fieldElement.groupAssigned = groupToAssigned
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return fieldList
|
return fieldsList
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -524,18 +527,26 @@ export function assignedGroup(fieldList, assignedGroup) {
|
||||||
* @param {string} panelType
|
* @param {string} panelType
|
||||||
* @returns {array}
|
* @returns {array}
|
||||||
*/
|
*/
|
||||||
export function sortFields(arr, orderBy = 'sequence', type = 'asc', panelType = 'window') {
|
export function sortFields({
|
||||||
if (panelType === 'browser') {
|
fieldsList,
|
||||||
orderBy = 'seqNoGrid'
|
orderBy = 'sequence',
|
||||||
|
type = 'asc'
|
||||||
|
}) {
|
||||||
|
if (type.toLowerCase() === 'asc') {
|
||||||
|
fieldsList.sort((itemA, itemB) => {
|
||||||
|
return itemA[orderBy] - itemB[orderBy]
|
||||||
|
// return itemA[orderBy] > itemB[orderBy]
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
fieldsList.sort((itemA, itemB) => {
|
||||||
|
return itemA[orderBy] + itemB[orderBy]
|
||||||
|
// return itemA[orderBy] > itemB[orderBy]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
arr.sort((itemA, itemB) => {
|
// if (type.toLowerCase() === 'desc') {
|
||||||
return itemA[orderBy] - itemB[orderBy]
|
// return fieldsList.reverse()
|
||||||
// return itemA[orderBy] > itemB[orderBy]
|
// }
|
||||||
})
|
return fieldsList
|
||||||
if (type.toLowerCase() === 'desc') {
|
|
||||||
return arr.reverse()
|
|
||||||
}
|
|
||||||
return arr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue