Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set default values with containerManager. #1410

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ADempiere/PanelDefinition/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default defineComponent({
const metadata = ref({})

if (root.$route.query.action === 'create-new') {
root.$store.dispatch('dataManager/setDefaultValues', {
props.containerManager.setDefaultValues({
parentUuid: props.parentUuid,
containerUuid: props.containerUuid
})
Expand Down
80 changes: 80 additions & 0 deletions src/store/modules/ADempiere/dictionary/window/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// 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 router from '@/router'

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

Expand Down Expand Up @@ -113,5 +115,83 @@ export default {
})
}
}
},

/**
* Set default values to panel
* @param {string} parentUuid
* @param {string} containerUuid
* TODO: Evaluate if it is necessary to parse the default values
*/
setTabDefaultValues({ commit, dispatch, rootGetters }, {
parentUuid,
containerUuid,
isOverWriteParent = true
}) {
return new Promise(resolve => {
const tab = rootGetters.getStoredTab(parentUuid, containerUuid)

const currentRoute = router.app._route
delete currentRoute.query.filters
// set action
router.push({
name: currentRoute.name,
params: {
...currentRoute.params
},
query: {
...currentRoute.query,
action: 'create-new'
}
}, () => {})

let defaultAttributes = rootGetters.getParsedDefaultValues({
parentUuid,
containerUuid,
isSOTrxMenu: currentRoute.meta.isSalesTransaction,
fieldsList: tab.fieldsList
})

// set vales with permant link
if (!rootGetters['permantLink/isReadFilters'] &&
containerUuid === rootGetters['permantLink/getLinkContainerUuid']) {
const parsedFilters = rootGetters['permantLink/getParsedFilters']
if (!isEmptyValue(parsedFilters)) {
// merge values
defaultAttributes = defaultAttributes.map(attribute => {
const filterValue = parsedFilters[attribute.columnName]
return {
...attribute,
value: filterValue
}
})
}

commit('permantLink/setIsReadFilters', null, {
root: true
})
}

defaultAttributes.forEach(attribute => {
commit('addChangeToPersistenceQueue', {
...attribute,
containerUuid
}, {
root: true
})
})

dispatch('updateValuesOfContainer', {
parentUuid,
containerUuid,
isOverWriteParent,
attributes: defaultAttributes
}, {
root: true
})

resolve(defaultAttributes)
})
}

}
77 changes: 0 additions & 77 deletions src/store/modules/ADempiere/windowManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,83 +70,6 @@ const windowManager = {
},

actions: {
/**
* Set default values to panel
* @param {string} parentUuid
* @param {string} containerUuid
* TODO: Evaluate if it is necessary to parse the default values
*/
setDefaultValues({ commit, dispatch, rootGetters }, {
parentUuid,
containerUuid,
isOverWriteParent = true
}) {
return new Promise(resolve => {
const tab = rootGetters.getStoredTab(parentUuid, containerUuid)

const currentRoute = router.app._route
delete currentRoute.query.filters
// set action
router.push({
name: currentRoute.name,
params: {
...currentRoute.params
},
query: {
...currentRoute.query,
action: 'create-new'
}
}, () => {})

let defaultAttributes = rootGetters.getParsedDefaultValues({
parentUuid,
containerUuid,
isSOTrxMenu: currentRoute.meta.isSalesTransaction,
fieldsList: tab.fieldsList
})

// set vales with permant link
if (!rootGetters['permantLink/isReadFilters'] &&
containerUuid === rootGetters['permantLink/getLinkContainerUuid']) {
const parsedFilters = rootGetters['permantLink/getParsedFilters']
if (!isEmptyValue(parsedFilters)) {
// merge values
defaultAttributes = defaultAttributes.map(attribute => {
const filterValue = parsedFilters[attribute.columnName]
return {
...attribute,
value: filterValue
}
})
}

commit('permantLink/setIsReadFilters', null, {
root: true
})
}

defaultAttributes.forEach(attribute => {
commit('addChangeToPersistenceQueue', {
...attribute,
containerUuid
}, {
root: true
})
})

dispatch('updateValuesOfContainer', {
parentUuid,
containerUuid,
isOverWriteParent,
attributes: defaultAttributes
}, {
root: true
})

resolve(defaultAttributes)
})
},

createEntity({
rootGetters
}, {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ADempiere/constants/actionsMenuList.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const createNewRecord = {
icon: 'el-icon-circle-plus-outline',
actionName: 'createNewRecord',
createNewRecord: ({ root, parentUuid, containerUuid }) => {
root.$store.dispatch('dataManager/setDefaultValues', {
root.$store.dispatch('setTabDefaultValues', {
parentUuid,
containerUuid
})
Expand Down
7 changes: 7 additions & 0 deletions src/views/ADempiere/Browser/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ export default defineComponent({
})
},

setDefaultValues: ({ parentUuid, containerUuid }) => {
root.$store.dispatch('setBrowserDefaultValues', {
parentUuid,
containerUuid
})
},

/**
* Is displayed field in panel single record
*/
Expand Down
6 changes: 6 additions & 0 deletions src/views/ADempiere/Process/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ export default defineComponent({
// })
},

setDefaultValues: ({ containerUuid }) => {
root.$store.dispatch('setProcessDefaultValues', {
containerUuid
})
},

isDisplayedField,

isReadOnlyField({
Expand Down
2 changes: 1 addition & 1 deletion src/views/ADempiere/Window/MultiTabWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default defineComponent({

seekRecord: ({ row, tableName, parentUuid, containerUuid }) => {
if (root.isEmptyValue(row)) {
root.$store.dispatch('dataManager/setDefaultValues', {
root.$store.dispatch('setTabDefaultValues', {
parentUuid,
containerUuid
})
Expand Down
7 changes: 7 additions & 0 deletions src/views/ADempiere/Window/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ export default defineComponent({
return new Promise()
},

setDefaultValues: ({ parentUuid, containerUuid }) => {
root.$store.dispatch('setTabDefaultValues', {
parentUuid,
containerUuid
})
},

seekRecord: function(eventInfo) {
console.log('seekRecord: ', eventInfo)
// return new Promise()
Expand Down