From 44ad3521ba9be5484a8c485286ac9fd9556a486c Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Fri, 6 Aug 2021 19:55:12 -0400 Subject: [PATCH] support Product Configuration (#969) * support Product Configuration * paint flowchart dynamically * minimal changes Workflow * remove comment Co-authored-by: elsiosanchez --- src/api/ADempiere/dictionary/workflow.js | 41 ++++ src/api/ADempiere/workflow.js | 26 +++ src/components/ADempiere/Badge/index.vue | 11 +- .../ADempiere/Form/WorkflowActivity/index.vue | 78 +------ src/components/ADempiere/Workflow/index.vue | 173 +++++++++++++++ .../modules/ADempiere/WorkflowActivity.js | 28 ++- src/store/modules/ADempiere/panel/actions.js | 3 + .../modules/ADempiere/process/actions.js | 12 + .../modules/ADempiere/process/mutations.js | 3 + .../modules/ADempiere/workflowDefinition.js | 75 +++++++ src/utils/ADempiere/dictionaryUtils.js | 2 +- src/views/ADempiere/Workflow/index.vue | 206 ++++++++++++++++++ src/views/login/index.vue | 1 + 13 files changed, 584 insertions(+), 75 deletions(-) create mode 100644 src/api/ADempiere/dictionary/workflow.js create mode 100644 src/components/ADempiere/Workflow/index.vue create mode 100644 src/store/modules/ADempiere/workflowDefinition.js create mode 100644 src/views/ADempiere/Workflow/index.vue diff --git a/src/api/ADempiere/dictionary/workflow.js b/src/api/ADempiere/dictionary/workflow.js new file mode 100644 index 00000000..ca42e4c2 --- /dev/null +++ b/src/api/ADempiere/dictionary/workflow.js @@ -0,0 +1,41 @@ +// 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 . + +// Get Instance for connection +import { request } from '@/utils/ADempiere/request' + +/** + * Request dictionary workflow metadata + * @param {string} uuid universally unique identifier + * @param {number} id, identifier + */ +export function requestWorkflowMetadata({ + uuid, + id +}) { + return request({ + url: '/dictionary/workflow', + method: 'get', + params: { + uuid, + id + } + }) + .then(workflowResponse => { + const { convertWorkflow } = require('@/utils/ADempiere/apiConverts/dictionary.js') + return convertWorkflow(workflowResponse) + }) +} diff --git a/src/api/ADempiere/workflow.js b/src/api/ADempiere/workflow.js index 52241e95..5239ecce 100644 --- a/src/api/ADempiere/workflow.js +++ b/src/api/ADempiere/workflow.js @@ -117,3 +117,29 @@ export function workflowActivities({ } }) } +// GET Workflows +/** + * Request Document Status List + * @param {string} tableName + * @param {number} pageSize + * @param {string} pageToken + */ +export function getWorkflow({ + tableName, + pageSize, + pageToken +}) { + return request({ + url: '/workflow/workflows', + method: 'get', + params: { + table_name: tableName, + // Page Data + pageToken, + pageSize + } + }) + .then(listWorkflowActivities => { + return listWorkflowActivities + }) +} diff --git a/src/components/ADempiere/Badge/index.vue b/src/components/ADempiere/Badge/index.vue index 56cb4669..0857f315 100644 --- a/src/components/ADempiere/Badge/index.vue +++ b/src/components/ADempiere/Badge/index.vue @@ -69,7 +69,16 @@ export default { }, computed: { getRecordNotification() { - return this.$store.getters.getNotificationProcess + return this.$store.getters.getNotificationProcess.map(item => { + if (item.typeActivity) { + return { + ...item, + name: item.name + ' ' + item.quantityActivities + } + } else { + return item + } + }) } }, watch: { diff --git a/src/components/ADempiere/Form/WorkflowActivity/index.vue b/src/components/ADempiere/Form/WorkflowActivity/index.vue index 893e31e6..9f145b79 100644 --- a/src/components/ADempiere/Form/WorkflowActivity/index.vue +++ b/src/components/ADempiere/Form/WorkflowActivity/index.vue @@ -45,37 +45,12 @@ - - -
- - {{ infoNode.description }} - - -
-
- - - - {{ $t('login.userName') }} {{ logs.user_name }}
- {{ logs.text_message }} -
-
-
-
-
-
-
@@ -105,12 +80,12 @@ + + + diff --git a/src/store/modules/ADempiere/WorkflowActivity.js b/src/store/modules/ADempiere/WorkflowActivity.js index a5ffec84..afdd4c90 100644 --- a/src/store/modules/ADempiere/WorkflowActivity.js +++ b/src/store/modules/ADempiere/WorkflowActivity.js @@ -1,7 +1,9 @@ import { workflowActivities } from '@/api/ADempiere/workflow.js' +import { isEmptyValue } from '@/utils/ADempiere' import { showMessage } from '@/utils/ADempiere/notification.js' +import language from '@/lang' const activity = { listActivity: [], @@ -19,9 +21,11 @@ export default { } }, actions: { - serverListActivity({ commit, getters, rootGetters }) { + serverListActivity({ commit, state, dispatch, rootGetters }, params) { + const userUuid = isEmptyValue(params) ? rootGetters['user/getUserUuid'] : params + const name = language.t('navbar.badge.activity') workflowActivities({ - userUuid: rootGetters['user/getUserUuid'] + userUuid }) .then(response => { const { listWorkflowActivities } = response @@ -35,6 +39,26 @@ export default { showClose: true }) }) + .finally(() => { + const notification = rootGetters.getNotificationProcess.find(notification => { + if (notification.typeActivity && notification.quantityActivities === state.listActivity.length) { + return notification + } + }) + if (isEmptyValue(notification)) { + commit('addNotificationProcess', { + name, + typeActivity: true, + quantityActivities: state.listActivity.length + }) + } else { + dispatch('updateNotifications', { + name, + typeActivity: true, + quantityActivities: state.listActivity.length + }) + } + }) }, selectedActivity({ commit }, activity) { commit('setCurrentActivity', activity) diff --git a/src/store/modules/ADempiere/panel/actions.js b/src/store/modules/ADempiere/panel/actions.js index 2b9b9903..567b3576 100644 --- a/src/store/modules/ADempiere/panel/actions.js +++ b/src/store/modules/ADempiere/panel/actions.js @@ -783,6 +783,9 @@ const actions = { default: executeAction = 'getFieldsFromTab' break + case 'workflow': + executeAction = 'getWorkflowFromServer' + break } return dispatch(executeAction, { diff --git a/src/store/modules/ADempiere/process/actions.js b/src/store/modules/ADempiere/process/actions.js index 7753d9b5..bcf9651d 100644 --- a/src/store/modules/ADempiere/process/actions.js +++ b/src/store/modules/ADempiere/process/actions.js @@ -1220,5 +1220,17 @@ export default { dispatch('updateOrderPos', false) }) }) + }, + updateNotifications({ commit, state }, + update + ) { + const notification = state.notificationProcess.map(notification => { + if (notification.name === update.name && notification.typeActivity && notification.quantityActivities !== update.quantityActivities) { + return { + ...update + } + } + }) + commit('updateNotificationProcess', notification) } } diff --git a/src/store/modules/ADempiere/process/mutations.js b/src/store/modules/ADempiere/process/mutations.js index c9fcc3cf..133ed284 100644 --- a/src/store/modules/ADempiere/process/mutations.js +++ b/src/store/modules/ADempiere/process/mutations.js @@ -14,6 +14,9 @@ export default { addNotificationProcess(state, payload) { state.notificationProcess.push(payload) }, + updateNotificationProcess(state, update) { + state.notificationProcess = update + }, // Delete process in execution afther some response from server deleteInExecution(state, payload) { state.inExecution = state.inExecution.filter(item => item.containerUuid !== payload.containerUuid) diff --git a/src/store/modules/ADempiere/workflowDefinition.js b/src/store/modules/ADempiere/workflowDefinition.js new file mode 100644 index 00000000..5b300971 --- /dev/null +++ b/src/store/modules/ADempiere/workflowDefinition.js @@ -0,0 +1,75 @@ +import { requestWorkflowMetadata } from '@/api/ADempiere/dictionary/workflow' +import { showMessage } from '@/utils/ADempiere/notification' +// import router from '@/router' +import language from '@/lang' + +const workflow = { + state: { + workflow: [] + }, + mutations: { + addWorkflow(state, payload) { + state.workflow.push(payload) + }, + dictionaryResetCacheWorkflow(state) { + state.workflow = [] + } + }, + actions: { + getWorkflowFromServer({ commit, dispatch }, { + id, + containerUuid, + routeToDelete + }) { + return new Promise(resolve => { + requestWorkflowMetadata({ + uuid: containerUuid, + id + }) + .then(workflowResponse => { + const panelType = 'workflow' + + // Panel for save on store + const newWorkflow = { + ...workflowResponse, + containerUuid, + fieldsList: [], + panelType + } + + commit('addWorkflow', newWorkflow) + + resolve(newWorkflow) + + const actions = [] + + // Add process menu + dispatch('setContextMenu', { + containerUuid, + actions + }) + }) + .catch(error => { + // router.push({ + // path: '/dashboard' + // }, () => {}) + // dispatch('tagsView/delView', routeToDelete) + showMessage({ + message: language.t('login.unexpectedError'), + type: 'error' + }) + console.warn(`Dictionary Workflow - Error ${error.code}: ${error.message}.`) + }) + }) + } + }, + getters: { + getWorkflowUuid: (state) => (workflowUuid) => { + return state.workflow.find( + item => item.uuid === workflowUuid + ) + } + } +} + +export default workflow diff --git a/src/utils/ADempiere/dictionaryUtils.js b/src/utils/ADempiere/dictionaryUtils.js index b5213191..a4be486c 100644 --- a/src/utils/ADempiere/dictionaryUtils.js +++ b/src/utils/ADempiere/dictionaryUtils.js @@ -672,7 +672,6 @@ export function convertAction(action) { isIndex: false, component: () => import('@/views/ADempiere/Unsupported') } - switch (action) { case 'B': actionAttributes.name = 'workbech' @@ -681,6 +680,7 @@ export function convertAction(action) { case 'F': actionAttributes.name = 'workflow' actionAttributes.icon = 'example' + actionAttributes.component = () => import('@/views/ADempiere/Workflow') break case 'P': actionAttributes.name = 'process' diff --git a/src/views/ADempiere/Workflow/index.vue b/src/views/ADempiere/Workflow/index.vue new file mode 100644 index 00000000..58bbced9 --- /dev/null +++ b/src/views/ADempiere/Workflow/index.vue @@ -0,0 +1,206 @@ + + + + + diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 68be1972..47a6994f 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -196,6 +196,7 @@ export default { }) .finally(() => { this.loading = false + this.$store.dispatch('serverListActivity') }) } else { console.log('error submit!!')