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

feat: Process associated browser. #1454

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
37 changes: 15 additions & 22 deletions src/components/ADempiere/ActionMenu/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@command="runAction"
@click="runDefaultAction"
>
{{ defaultActionName }}
{{ actionsManager.defaultActionName }}

<el-dropdown-menu slot="dropdown">
<el-dropdown-item
Expand Down Expand Up @@ -84,14 +84,13 @@
</b>
</span>

<p
v-if="!isEmptyValue(childs.description)"
class="description"
>
{{ childs.description }}
</p>
<p v-else class="description">
{{ $t('data.noDescription') }}
<p class="description">
<template v-if="isEmptyValue(childs.description)">
{{ $t('data.noDescription') }}
</template>
<template v-else>
{{ childs.description }}
</template>
</p>
</el-dropdown-item>
</el-scrollbar>
Expand All @@ -104,8 +103,14 @@
{{ action.name }}
</b>
</span>

<p class="description">
{{ $t('data.noDescription') }}
<template v-if="isEmptyValue(action.description)">
{{ $t('data.noDescription') }}
</template>
<template v-else>
{{ action.description }}
</template>
</p>
</div>
</div>
Expand Down Expand Up @@ -165,16 +170,6 @@ export default defineComponent({
return false
})

const defaultActionName = computed(() => {
if (!root.isEmptyValue(tableName)) {
if (isWithRecord.value) {
return root.$t('window.newRecord')
}
return root.$t('data.undo')
}
return root.$t('actionMenu.runProcessOrReport')
})

const defaultActionToRun = computed(() => {
if (isUndoAction.value) {
return actionsList.value[2]
Expand Down Expand Up @@ -207,8 +202,6 @@ export default defineComponent({

return {
actionsList,
// computeds
defaultActionName,
// methods
runAction,
runDefaultAction
Expand Down
62 changes: 62 additions & 0 deletions src/store/modules/ADempiere/actionMenuManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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 [email protected] 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/>.

import Vue from 'vue'

// utils and helper methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'

const initState = {
actionMenuManager: {}
}

const actionMenuManager = {
state: initState,

mutations: {
setActionMenu(state, {
containerUuid,
actionsList
}) {
Vue.set(state.actionMenuManager, containerUuid, {
containerUuid,
actionsList
})
},

resetStateActionMenuManager(state) {
state = initState
}
},

getters: {
/**
* Get actions list of container
* @param {string} containerUuid
* @returns {array}
*/
getStoredActionsMenu: (state) => ({ containerUuid }) => {
const actionContainer = state.actionMenuManager[containerUuid]
if (!isEmptyValue(actionContainer)) {
return actionContainer.actionsList
}

return []
}
}
}

export default actionMenuManager
67 changes: 66 additions & 1 deletion src/store/modules/ADempiere/dictionary/browser/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import router from '@/router'
// api request methods
import { requestBrowserMetadata } from '@/api/ADempiere/dictionary/smart-browser.js'

// constants
import {
refreshBrowserSearh,
runProcessOrReport,
sharedLink,
zoomWindow
} from '@/utils/ADempiere/constants/actionsMenuList'

// utils and helper methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { generatePanelAndFields } from '@/utils/ADempiere/dictionary/panel.js'
Expand All @@ -44,6 +52,11 @@ export default {
})
commit('addBrowserToList', browserDefinition)

dispatch('setBrowserActionsMenu', {
containerUuid: browserDefinition.uuid
})

// set default values into fields
dispatch('setBrowserDefaultValues', {
containerUuid: browserDefinition.uuid,
fieldsList: browserDefinition.fieldsList
Expand All @@ -54,10 +67,59 @@ export default {
})
},

/**
* Set actions menu to browser
* @param {string} containerUuid
*/
setBrowserActionsMenu({ commit, getters }, {
containerUuid
}) {
const browserDefinition = getters.getStoredBrowser(containerUuid)

const actionsList = []

// process associated
if (!isEmptyValue(browserDefinition.process)) {
const { uuid, name, description } = browserDefinition.process
const actionProcess = {
...runProcessOrReport,
uuid,
name,
description
}

actionsList.push(actionProcess)
}

// action refresh browser search
actionsList.push(refreshBrowserSearh)

// add action zoom window
if (!isEmptyValue(browserDefinition.window)) {
const { uuid, name, description } = browserDefinition.window
const zoomAction = {
...zoomWindow,
uuid,
name: `${zoomWindow.name}: ${name}`,
description
}

actionsList.push(zoomAction)
}

// action shared link
actionsList.push(sharedLink)

commit('setActionMenu', {
containerUuid: browserDefinition.uuid,
actionsList
})
},

/**
* Set default values to panel
* @param {string} parentUuid
* @param {string} containerUuid
* @param {array} fieldsList
*/
setBrowserDefaultValues({ dispatch, getters }, {
containerUuid,
Expand Down Expand Up @@ -87,6 +149,9 @@ export default {

/**
* Used by components/fields/filterFields
* @param {string} containerUuid
* @param {array} fieldsShowed fields to displayed
* @param {array} fieldsList all fields list in container
*/
changeBrowserFieldShowedFromUser({ commit, dispatch, getters, rootGetters }, {
containerUuid,
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/ADempiere/dictionary/browser/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default {
},

/**
* Determinate if panel is ready fron send, all fiedls mandatory and displayed with values
* Determinate if panel is ready to send, all fields mandatory and displayed with values
* @param {string} containerUuid
* @param {object} row, data to compare if is table
* @returns {object}
Expand Down
2 changes: 2 additions & 0 deletions src/utils/ADempiere/constants/actionsMenuList.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const zoomWindow = {
icon: 'el-icon-zoom-in',
type: 'zoom',
actionName: 'zoomWindow',
uuid: null,
zoomWindow: ({ uuid }) => {
zoomIn({
uuid
Expand Down Expand Up @@ -216,6 +217,7 @@ export const runProcessOrReport = {
svg: false,
icon: 'el-icon-setting',
actionName: 'runProcessOrReport',
uuid: null,
runProcessOrReport: ({ root, containerUuid }) => {
root.$store.dispatch('startProcess', {
containerUuid
Expand Down
25 changes: 5 additions & 20 deletions src/views/ADempiere/Browser/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ import {
isReadOnlyField, isReadOnlyColumn
} from '@/utils/ADempiere/dictionary/browser.js'

// constants
import {
refreshBrowserSearh,
sharedLink,
zoomWindow
} from '@/utils/ADempiere/constants/actionsMenuList'

export default defineComponent({
name: 'BrowserView',

Expand Down Expand Up @@ -338,19 +331,11 @@ export default defineComponent({
const actionsManager = ref({
containerUuid: browserUuid,

getActionList: () => [
refreshBrowserSearh,
{
...zoomWindow,
uuid: root.isEmptyValue(storedBrowser.value)
? null
: storedBrowser.value.window
? storedBrowser.value.window.uuid
: null
},

sharedLink
]
defaultActionName: root.$t('actionMenu.runProcessOrReport'),

getActionList: () => root.$store.getters.getStoredActionsMenu({
containerUuid: browserUuid
})
})

const relationsManager = ref({
Expand Down
3 changes: 3 additions & 0 deletions src/views/ADempiere/Window/MultiTabWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ export default defineComponent({
const actionsManager = ref({
parentUuid: props.windowMetadata.uuid,
containerUuid: props.windowMetadata.currentTabUuid,

defaultActionName: root.$t('window.newRecord'),

getActionList: () => [
createNewRecord,
refreshRecords,
Expand Down