Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Change the columns of the panel (#175)
Browse files Browse the repository at this point in the history
* Change the columns of the panel

* Update componentUtils.js

Co-authored-by: Edwin Betancourt <[email protected]>
  • Loading branch information
elsiosanchez and EdwinBetanc0urt authored Jun 15, 2022
1 parent b17ce71 commit 1e53dc3
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
41 changes: 40 additions & 1 deletion src/store/modules/ADempiere/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import Vue from 'vue'
// api request methods
import { requestFieldMetadata } from '@/api/ADempiere/dictionary/window'
// constants
import { DEFAULT_SIZE_COLUMN } from '@/utils/ADempiere/componentUtils'

const initStateLookup = {
referenceList: [],
fieldsList: [],
validationRuleList: []
validationRuleList: [],
defaultSizeField: {}
}

const field = {
Expand All @@ -37,6 +41,21 @@ const field = {
},
resetStateLookup(state) {
state = initStateLookup
},
setSizeField(state, {
parentUuid,
containerUuid,
sizeField = DEFAULT_SIZE_COLUMN
}) {
const defaultSizeField = {
parentUuid,
containerUuid,
sizeField
}
Vue.set(state.defaultSizeField, containerUuid, defaultSizeField)
},
sizeField(state, size) {
state.defaultSizeField = size
}
},
actions: {
Expand Down Expand Up @@ -77,6 +96,23 @@ const field = {
.catch(error => {
console.warn(`Get Field - Error ${error.code}: ${error.message}.`)
})
},
/**
* Change the columns of the panel
* @param {string} parentUuid
* @param {string} containerUuid
* @param {number} sizeField
*/
changeSizeField({ commit }, {
parentUuid,
containerUuid,
sizeField
}) {
commit('setSizeField', {
parentUuid,
containerUuid,
sizeField
})
}
},
getters: {
Expand Down Expand Up @@ -107,6 +143,9 @@ const field = {
return state.fieldsList.find(fieldItem => {
return fieldItem.tableName === tableName && fieldItem.columnName === columnName
})
},
getSizeColumn: (state, getters) => ({ containerUuid }) => {
return state.defaultSizeField[containerUuid].sizeField || DEFAULT_SIZE_COLUMN
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/store/modules/ADempiere/windowManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {

// constants
import { ROW_ATTRIBUTES } from '@/utils/ADempiere/constants/table'
import { DEFAULT_SIZE_COLUMN } from '@/utils/ADempiere/componentUtils'

// utils and helper methods
import { getContextAttributes } from '@/utils/ADempiere/contextUtils.js'
Expand Down Expand Up @@ -165,7 +166,12 @@ const windowManager = {
isLoaded: false,
containerUuid
})

commit('setSizeField', {
parentUuid,
isLoaded: true,
containerUuid,
sizeField: DEFAULT_SIZE_COLUMN
})
getEntities({
windowUuid: parentUuid,
tabUuid: containerUuid,
Expand Down
11 changes: 11 additions & 0 deletions src/utils/ADempiere/componentUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,14 @@ export function notSubmitForm(event) {
event.preventDefault()
return false
}

/**
* Columns number on layout by component ui
* https://element.eleme.io/#/es/component/layout
*/
export const LAYOUT_SIZE_COLUMN = 24

/**
* Default size of column
*/
export const DEFAULT_SIZE_COLUMN = 0

0 comments on commit 1e53dc3

Please sign in to comment.