From 0d7aa7c72f9bf552f138f9ead5ffbff536481cb7 Mon Sep 17 00:00:00 2001 From: Edwin Betancourt Date: Thu, 23 Apr 2020 20:33:40 -0400 Subject: [PATCH] fix: Mandatory fields empty. (#456) --- .../ADempiere/ContextMenu/contextMenuMixin.js | 112 +++++++++--------- src/store/modules/ADempiere/panel.js | 2 +- src/utils/ADempiere/notification.js | 10 +- 3 files changed, 66 insertions(+), 58 deletions(-) diff --git a/src/components/ADempiere/ContextMenu/contextMenuMixin.js b/src/components/ADempiere/ContextMenu/contextMenuMixin.js index 024b76b6..752e6613 100644 --- a/src/components/ADempiere/ContextMenu/contextMenuMixin.js +++ b/src/components/ADempiere/ContextMenu/contextMenuMixin.js @@ -415,59 +415,7 @@ export const contextMixin = { }, runAction(action) { if (action.type === 'action') { - // run process or report - const fieldNotReady = this.$store.getters.isNotReadyForSubmit(this.$route.meta.uuid) - if (!fieldNotReady) { - let containerParams = this.$route.meta.uuid - if (this.lastParameter !== undefined) { - containerParams = this.lastParameter - } - - let menuParentUuid = this.menuParentUuid - if (this.isEmptyValue(menuParentUuid) && this.$route.params) { - if (!this.isEmptyValue(this.$route.params.menuParentUuid)) { - menuParentUuid = this.$route.params.menuParentUuid - } - } - - if (this.panelType === 'process') { - this.$store.dispatch('setTempShareLink', { - processId: this.$route.params.processId, - href: window.location.href - }) - } - - let reportFormat = action.reportExportType - if (this.isEmptyValue(reportFormat)) { - reportFormat = this.$route.query.reportType - if (this.isEmptyValue(reportFormat)) { - reportFormat = this.$route.meta.reportFormat - if (this.isEmptyValue(reportFormat)) { - reportFormat = 'html' - } - } - } - - this.$store.dispatch(action.action, { - action, - parentUuid: this.containerUuid, - containerUuid: containerParams, // EVALUATE IF IS action.uuid - panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) - reportFormat, // this.$route.query.reportType ? this.$route.query.reportType : action.reportExportType, - menuParentUuid, // to load relationsList in context menu (report view) - routeToDelete: this.$route - }) - .catch(error => { - console.warn(error) - }) - } else { - this.showNotification({ - type: 'warning', - title: this.$t('notifications.emptyValues'), - name: '' + fieldNotReady.name + '. ', - message: this.$t('notifications.fieldMandatory') - }) - } + this.executeAction(action) } else if (action.type === 'process') { // run process associate with view (window or browser) this.showModal(action) @@ -499,6 +447,64 @@ export const contextMixin = { this.updateReport(action) } }, + executeAction(action) { + let containerParams = this.$route.meta.uuid + if (this.lastParameter !== undefined) { + containerParams = this.lastParameter + } + const fieldsNotReady = this.$store.getters.getFieldListEmptyMandatory({ + containerUuid: containerParams + }) + + // run process or report + if (this.isEmptyValue(fieldsNotReady)) { + let menuParentUuid = this.menuParentUuid + if (this.isEmptyValue(menuParentUuid) && this.$route.params) { + if (!this.isEmptyValue(this.$route.params.menuParentUuid)) { + menuParentUuid = this.$route.params.menuParentUuid + } + } + + if (this.panelType === 'process') { + this.$store.dispatch('setTempShareLink', { + processId: this.$route.params.processId, + href: window.location.href + }) + } + + let reportFormat = action.reportExportType + if (this.isEmptyValue(reportFormat)) { + reportFormat = this.$route.query.reportType + if (this.isEmptyValue(reportFormat)) { + reportFormat = this.$route.meta.reportFormat + if (this.isEmptyValue(reportFormat)) { + reportFormat = 'html' + } + } + } + + this.$store.dispatch(action.action, { + action, + parentUuid: this.containerUuid, + containerUuid: containerParams, // EVALUATE IF IS action.uuid + panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) + reportFormat, // this.$route.query.reportType ? this.$route.query.reportType : action.reportExportType, + menuParentUuid, // to load relationsList in context menu (report view) + routeToDelete: this.$route + }) + .catch(error => { + console.warn(error) + }) + } else { + this.showNotification({ + type: 'warning', + title: this.$t('notifications.emptyValues'), + name: '' + fieldsNotReady + '. ', + message: this.$t('notifications.fieldMandatory'), + isRedirect: false + }) + } + }, updateReport(action) { let instanceUuid = action.instanceUuid if (this.isEmptyValue(instanceUuid)) { diff --git a/src/store/modules/ADempiere/panel.js b/src/store/modules/ADempiere/panel.js index 899b9a45..8e30ab25 100644 --- a/src/store/modules/ADempiere/panel.js +++ b/src/store/modules/ADempiere/panel.js @@ -1049,7 +1049,7 @@ const panel = { if (row) { value = row[fieldItem.columnName] } - if (fieldIsDisplayed(fieldItem) && isMandatory && !isEmptyValue(value)) { + if (fieldIsDisplayed(fieldItem) && isMandatory && isEmptyValue(value)) { return true } }) diff --git a/src/utils/ADempiere/notification.js b/src/utils/ADempiere/notification.js index 80122835..172b2cb9 100644 --- a/src/utils/ADempiere/notification.js +++ b/src/utils/ADempiere/notification.js @@ -20,7 +20,7 @@ export function hasTranslation(text) { * @param {string} name * @param {array} logs */ -export function showNotification({ type, title, message, summary, name, logs = [] }) { +export function showNotification({ type, title, message, summary, name, logs = [], isRedirect = true }) { title = hasTranslation(title) if (message) { message = hasTranslation(message) @@ -52,9 +52,11 @@ export function showNotification({ type, title, message, summary, name, logs = [ position: 'bottom-right', dangerouslyUseHTMLString: true, onClick() { - router.push({ - name: 'ProcessActivity' - }) + if (isRedirect) { + router.push({ + name: 'ProcessActivity' + }) + } } }) }