Skip to content

Commit

Permalink
fix: Open SB from button or process associated. (PanJiaChen#2644)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt authored Sep 16, 2024
1 parent 7380a37 commit 7440042
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/api/ADempiere/dictionary/smart-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { request } from '@/utils/ADempiere/request'
* @param {number} id, identifier
*/
export function requestBrowserMetadata({
id: uuid,
uuid,
language,
dictionaryCode
}) {
Expand Down
11 changes: 6 additions & 5 deletions src/components/ADempiere/FieldDefinition/FieldButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,16 @@ export default {
}
}

if (this.metadata.process.browser_id) {
if (this.metadata.process.browser_id > 0) {
return {
is: 'svg-icon',
'icon-class': 'search',
start: () => openBrowserAssociated.openBrowserAssociated({
parentUuid: this.parentUuid,
containerUuid: this.containerUuid,
uuid: this.metadata.process.uuid,
browserId: this.metadata.process.browser.id
browserUuid: this.metadata.process.browser.uuid,
browserId: this.metadata.process.browser.internal_id
}),
isEnabled: () => generateReportOfWindow.enabled({
parentUuid: this.parentUuid,
Expand All @@ -248,15 +249,15 @@ export default {
}
}

if (this.metadata.process.form_id) {
if (this.metadata.process.form_id > 0) {
return {
is: 'svg-icon',
'icon-class': 'search',
start: () => openFormAssociated.openFormAssociated({
parentUuid: this.parentUuid,
containerUuid: this.containerUuid,
uuid: this.metadata.process.uuid,
formId: this.metadata.process.form.id,
formId: this.metadata.process.form.internal_id,
formUuid: this.metadata.process.form.uuid
}),
isEnabled: () => openFormAssociated.enabled({
Expand All @@ -266,7 +267,7 @@ export default {
}
}

if (this.metadata.process.workflow_id) {
if (this.metadata.process.workflow_id > 0) {
return {
is: 'svg-icon',
'icon-class': 'example',
Expand Down
6 changes: 3 additions & 3 deletions src/store/modules/ADempiere/dictionary/browser/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { templateBrowser } from '@/utils/ADempiere/dictionary/browser/templateBr

export default {
getBrowserDefinitionFromServer({ commit, state, dispatch, rootGetters }, {
id,
uuid,
parentUuid = '', // context of associated
containerUuid = '' // context of associated
}) {
Expand All @@ -61,15 +61,15 @@ export default {
const dictionaryCode = rootGetters['user/getDictionaryCode']

requestBrowserMetadata({
id,
uuid,
language,
dictionaryCode
})
.then(browserResponse => {
const browser = templateBrowser(browserResponse)
const browserUuid = browser.uuid
commit('addBrowserUuidToList', {
id: browser.id,
id: browser.internal_id,
uuid: browserUuid
})

Expand Down
15 changes: 10 additions & 5 deletions src/utils/ADempiere/dictionary/window/actionsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,21 @@ export const openBrowserAssociated = {
isSvgIcon: true,
icon: 'search',
actionName: 'openBrowserAssociated',
openBrowserAssociated: function({ parentUuid, containerUuid, uuid, browserId }) {
openBrowserAssociated: function({ parentUuid, containerUuid, uuid, browserId, browserUuid }) {
if (isEmptyValue(browserId) || browserId <= 0) {
const process = store.getters.getStoredProcessFromTab({
windowUuid: parentUuid,
tabUuid: containerUuid,
processUuid: uuid
})
browserId = process.browser.id
browserId = process.browser_id
if (isEmptyValue(browserUuid)) {
browserUuid = process.browser.uuid
}
}
if (isEmptyValue(browserUuid)) {
browserUuid = store.getters.getStoredBrowserUuidById(browserId)
}
const browserUuid = store.getters.getStoredBrowserUuidById(browserId)
const storedBrowser = store.getters.getStoredBrowser(browserUuid)
if (!isEmptyValue(storedBrowser)) {
// overwrite values
Expand Down Expand Up @@ -128,8 +133,8 @@ export const openBrowserAssociated = {
router.push({
name: 'Smart Browser',
params: {
browserId: browserId
// browserUuid
browserId: browserId,
browserUuid: browserUuid
},
query: {
parentUuid,
Expand Down
44 changes: 25 additions & 19 deletions src/views/ADempiere/Browser/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import { computed, defineComponent, ref } from '@vue/composition-api'

import language from '@/lang'
import router from '@/router'
import store from '@/store'

// Componets and Mixins
Expand Down Expand Up @@ -126,40 +127,45 @@ export default defineComponent({
}
},

setup(props, { root }) {
setup() {
const isLoadedMetadata = ref(false)
const browserMetadata = ref({})
const containerManagerProcess = ref({})
const currentRoute = router.app._route

// as window source
let parentUuid = ''
if (!isEmptyValue(root.$route.query) && !isEmptyValue(root.$route.query.parentUuid)) {
parentUuid = root.$route.query.parentUuid
if (!isEmptyValue(currentRoute.query) && !isEmptyValue(currentRoute.query.parentUuid)) {
parentUuid = currentRoute.query.parentUuid
}
// as tab source
let containerUuid = ''
if (!isEmptyValue(root.$route.query) && !isEmptyValue(root.$route.query.containerUuid)) {
containerUuid = root.$route.query.containerUuid
if (!isEmptyValue(currentRoute.query) && !isEmptyValue(currentRoute.query.containerUuid)) {
containerUuid = currentRoute.query.containerUuid
}

let browserId = -1
// set uuid with linked menu
if (!isEmptyValue(root.$route.meta) && !isEmptyValue(root.$route.meta.uuid)) {
browserId = root.$route.meta.action_uuid.toString()
if (!isEmptyValue(currentRoute.meta) && !isEmptyValue(currentRoute.meta.uuid)) {
browserId = currentRoute.meta.action_uuid.toString()
}
// set uuid from associated browser without menu
if (!isEmptyValue(root.$route.params) && !isEmptyValue(root.$route.params.browserId)) {
browserId = root.$route.params.browserId.toString()
}
// set uuid from test
if (!isEmptyValue(props.uuid)) {
browserId = props.uuid
if (!isEmptyValue(currentRoute.params) && !isEmptyValue(currentRoute.params.browserId)) {
browserId = currentRoute.params.browserId.toString()
}

const browserUuid = computed(() => {
let uuid = root.$route.meta.uuid
if (isEmptyValue(uuid)) {
uuid = store.getters.getStoredBrowserUuidById(browserId)
let uuid = store.getters.getStoredBrowserUuidById(browserId)
if (!isEmptyValue(currentRoute.meta)) {
if (isEmptyValue(uuid) && !isEmptyValue(currentRoute.meta.uuid)) {
uuid = currentRoute.meta.uuid
}
if (isEmptyValue(uuid) && !isEmptyValue(currentRoute.meta.action_uuid)) {
uuid = currentRoute.meta.action_uuid
}
}
if (isEmptyValue(uuid) && !isEmptyValue(currentRoute.params) && !isEmptyValue(currentRoute.params.browserUuid)) {
uuid = currentRoute.params.browserUuid.toString()
}
return uuid
})
Expand Down Expand Up @@ -256,10 +262,10 @@ export default defineComponent({
const { containerManager: containerManagerByProcess } = mixinProcess(processUuid)
containerManagerProcess.value = containerManagerByProcess

if (!isEmptyValue(root.$route.params) && !isEmptyValue(root.$route.params.browserId)) {
if (!isEmptyValue(currentRoute.params) && !isEmptyValue(currentRoute.params.browserId)) {
// update name in tag view
store.dispatch('tagsView/updateVisitedView', {
...root.$route,
...currentRoute,
title: `${language.t('route.smartBrowser')}: ${browser.name}`
})
}
Expand All @@ -278,7 +284,7 @@ export default defineComponent({

store.dispatch('getBrowserDefinitionFromServer', {
// id: browserId,
id: browserUuid.value,
uuid: browserUuid.value,
parentUuid,
containerUuid
})
Expand Down

0 comments on commit 7440042

Please sign in to comment.