Skip to content

Commit

Permalink
fix: Hidden/Showed Advanced Query Fields. (adempiere#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt committed Jan 3, 2023
1 parent b69b9ac commit 111d7d9
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 95 deletions.
28 changes: 15 additions & 13 deletions src/store/modules/ADempiere/dictionary/window/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
Expand All @@ -20,15 +20,15 @@ import language from '@/lang'
import router from '@/router'
import store from '@/store'

// api request methods
// API Request Methods
import { requestWindowMetadata } from '@/api/ADempiere/dictionary/window.js'

// constants
// Constants
import { CLIENT } from '@/utils/ADempiere/constants/systemColumns'
import { containerManager } from '@/utils/ADempiere/dictionary/window'
import { DISPLAY_COLUMN_PREFIX } from '@/utils/ADempiere/dictionaryUtils'
import { DISPLAY_COLUMN_PREFIX, IS_ADVANCED_QUERY } from '@/utils/ADempiere/dictionaryUtils'

// utils and helper methods
// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import {
generateWindow,
Expand Down Expand Up @@ -83,7 +83,6 @@ export default {
})
.then(async windowResponse => {
const window = generateWindow(windowResponse)
// generateAdvanceQueryPanel(windowResponse, 'addWindow')
dispatch('addWindow', window)

resolve(window)
Expand Down Expand Up @@ -669,18 +668,21 @@ export default {
})
},

setTabAdvanceuery({ commit, rootGetters }, {
setTabAdvancedQuery({ commit, rootGetters }, {
parentUuid,
containerUuid,
isAdvancedQuery
containerUuid
}) {
const tabPanel = rootGetters.getStoredTab(parentUuid, containerUuid)

const tabAdvanceQuery = panelAdvanceQuery({
tabPanel: rootGetters.getStoredTab(parentUuid, containerUuid),
parentUuid,
containerUuid,
isAdvancedQuery,
listTabs: rootGetters.getStoredTabs(parentUuid)
tabPanel
})

commit('setTabAdvancedQuery', {
parentUuid: parentUuid + IS_ADVANCED_QUERY,
tabAdvanceQuery
})
commit('addAdvanceQuery', { parentUuid, tabAdvanceQuery })
}
}
13 changes: 4 additions & 9 deletions src/store/modules/ADempiere/dictionary/window/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,10 @@ export default {

getStoredTab: (state) => (windowUuid, tabUuid) => {
if (!isEmptyValue(state.storedWindows[windowUuid])) {
const tabStore = state.storedWindows[windowUuid].tabsList.find(tab => tab.uuid === tabUuid)
if (tabStore) return tabStore
}
return {}
},
getFindTabAvanceQuery: (state) => (windowUuid, tabUuid) => {
if (!isEmptyValue(state.storedWindows[windowUuid])) {
const tabQuery = state.storedWindows[windowUuid].tabsList.find(tab => tab.uuid === tabUuid && tab.containerUuid.includes('IS_ADVANCE_QUERY'))
if (tabQuery) return tabQuery
const tabStored = state.storedWindows[windowUuid].tabsList.find(tab => tab.uuid === tabUuid)
if (tabStored) {
return tabStored
}
}
return {}
},
Expand Down
50 changes: 32 additions & 18 deletions src/store/modules/ADempiere/dictionary/window/mutations.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A.
// Contributor(s): Yamel Senih ysenih@erpya.com www.erpya.com
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/**
* ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
* Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
* Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com https://github.com/EdwinBetanc0urt
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'

/**
Expand Down Expand Up @@ -70,10 +74,20 @@ export default {
},

/**
* Add Advance Query
* Add Advanced Query as Tab Panel
*/
addAdvanceQuery(state, { parentUuid, tabAdvanceQuery }) {
Vue.set(state.storedWindows[parentUuid], 'tabsList', tabAdvanceQuery)
setTabAdvancedQuery(state, {
parentUuid,
tabAdvanceQuery
}) {
if (isEmptyValue(state.storedWindows[parentUuid])) {
Vue.set(state.storedWindows, parentUuid, {
tabsList: []
})
}
const tabsList = state.storedWindows[parentUuid].tabsList
tabsList.push(tabAdvanceQuery)
Vue.set(state.storedWindows[parentUuid], 'tabsList', tabsList)
},

/**
Expand Down
63 changes: 33 additions & 30 deletions src/utils/ADempiere/dictionary/panel.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A.
// Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com www.erpya.com
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// utils and helper methods
/**
* ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
* Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
* Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com https://github.com/EdwinBetanc0urt
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

// Constants
import { IS_ADVANCED_QUERY } from '@/utils/ADempiere/dictionaryUtils'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { generateField } from '@/utils/ADempiere/dictionaryUtils.js'
import { getFieldTemplate } from '@/utils/ADempiere/lookupFactory.js'
import { isAddRangeField } from '@/utils/ADempiere/references'
import { IS_ADVANCE_QUERY } from '@/utils/ADempiere/dictionaryUtils'

/**
* Order the fields, then assign the groups to each field, and finally group
Expand Down Expand Up @@ -142,7 +146,7 @@ export function generatePanelAndFields({
// app attributes
isShowedFromUser: true,
isReadOnlyFromForm: false,
isAdvancedQuery: containerUuid.includes(IS_ADVANCE_QUERY),
isAdvancedQuery: containerUuid.includes(IS_ADVANCED_QUERY),
...fieldOverwrite
}

Expand Down Expand Up @@ -299,25 +303,24 @@ export function generateDependenFieldsList(fieldsList) {
}

export function panelAdvanceQuery({
isAdvancedQuery,
tabPanel,
listTabs
parentUuid,
containerUuid,
tabPanel
}) {
const tabAdvancedQuery = {
...tabPanel,
parentUuid: tabPanel.parentUuid + isAdvancedQuery,
containerUuid: tabPanel.containerUuid + isAdvancedQuery,
parentUuid: parentUuid + IS_ADVANCED_QUERY,
containerUuid: containerUuid + IS_ADVANCED_QUERY,
fieldsList: tabPanel.fieldsList.map(field => {
return {
...field,
isAdvancedQuery: true,
isShowedFromUser: false,
parentUuid: field.parentUuid + isAdvancedQuery,
containerUuid: field.containerUuid + isAdvancedQuery
isShowedFromUser: field.isSelectionColumn,
parentUuid: field.parentUuid + IS_ADVANCED_QUERY,
containerUuid: field.containerUuid + IS_ADVANCED_QUERY
}
}),
uuid: tabPanel.uuid + isAdvancedQuery
uuid: tabPanel.uuid + IS_ADVANCED_QUERY
}
listTabs.push(tabAdvancedQuery)
return listTabs
return tabAdvancedQuery
}
25 changes: 2 additions & 23 deletions src/utils/ADempiere/dictionary/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import store from '@/store'

// Constants
import {
IDENTIFIER_COLUMN_SUFFIX, IS_ADVANCE_QUERY
IDENTIFIER_COLUMN_SUFFIX
} from '@/utils/ADempiere/dictionaryUtils'
import {
ACTIVE, CLIENT, PROCESSING, PROCESSED, UUID,
Expand All @@ -31,7 +31,7 @@ import {
import { ROW_ATTRIBUTES } from '@/utils/ADempiere/tableUtils'
import { YES_NO } from '@/utils/ADempiere/references'

// Api Request Methods
// API Request Methods
import { getEntity } from '@/api/ADempiere/user-interface/persistence'

// Utils and Helpers Methods
Expand Down Expand Up @@ -1005,27 +1005,6 @@ export function generateTabs({
}
}

export function generateAdvanceQueryTabs(tabs) {
return tabs.map(tab => {
return {
...tab,
uuid: tab.uuid + IS_ADVANCE_QUERY
}
})
}

export function generateAdvanceQueryPanel(panel, actions) {
const { tabs } = panel
const uuid = panel.uuid + IS_ADVANCE_QUERY
store.dispatch(actions,
generateWindow({
...panel,
uuid,
tabs: generateAdvanceQueryTabs(tabs)
})
)
}

/**
* Manage the window tab panel
*/
Expand Down
4 changes: 2 additions & 2 deletions src/utils/ADempiere/dictionaryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export const IDENTIFIER_COLUMN_SUFFIX = `_ID`
export const UNIVERSALLY_UNIQUE_IDENTIFIER_COLUMN_SUFFIX = `_UUID`

/**
* Identifierm Field is Advance Query
* Suffix Field is Advanced Query
*/
export const IS_ADVANCE_QUERY = 'IS_ADVANCE_QUERY'
export const IS_ADVANCED_QUERY = '-IS_ADVANCED_QUERY'

/**
* Generate field to app
Expand Down

0 comments on commit 111d7d9

Please sign in to comment.