From 2564ce307f244bca3ba64150ad473103ad886c2b Mon Sep 17 00:00:00 2001 From: Leonel Matos Date: Mon, 25 Nov 2019 11:41:08 -0400 Subject: [PATCH] add feature print format selection in report viewer (#162) * add feature print format selection in report viewer * add service implementation * add print format list to context menu actions --- src/api/ADempiere/data.js | 4 ++ src/lang/ADempiere/en.js | 4 +- src/lang/ADempiere/es.js | 4 +- src/store/modules/ADempiere/data.js | 37 ++++++++++++++++++- src/store/modules/ADempiere/processControl.js | 20 ++++++++++ src/views/ADempiere/ReportViewer/index.vue | 13 ++----- 6 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/api/ADempiere/data.js b/src/api/ADempiere/data.js index cc98a996..6f695eb3 100644 --- a/src/api/ADempiere/data.js +++ b/src/api/ADempiere/data.js @@ -318,3 +318,7 @@ export function getDefaultValueFromServer(query) { export function getContextInfoValueFromServer({ uuid, query }) { return Instance.call(this).getContextInfoValue({ uuid: uuid, query: query }) } + +export function requestPrintFormats({ tableName, reportViewUuid, processUuid }) { + return Instance.call(this).requestPrintFormats({ tableName: tableName, reportViewUuid: reportViewUuid, processUuid: processUuid }) +} diff --git a/src/lang/ADempiere/en.js b/src/lang/ADempiere/en.js index da442a3a..21ceee36 100644 --- a/src/lang/ADempiere/en.js +++ b/src/lang/ADempiere/en.js @@ -154,7 +154,9 @@ export default { unsupportedSorry: 'Sorry', unsupportedHeadline: 'This view is currently unavailable', unsupportedInfo: 'Please check that the view is supported in this version, or click the button below to return to the homepage.', - unsupportedButton: 'Back to dashboard' + unsupportedButton: 'Back to dashboard', + printFormat: 'Print Format', + changePrintFormat: 'Change Print Format' }, table: { ProcessActivity: { diff --git a/src/lang/ADempiere/es.js b/src/lang/ADempiere/es.js index 4785c6a0..0e908321 100644 --- a/src/lang/ADempiere/es.js +++ b/src/lang/ADempiere/es.js @@ -154,7 +154,9 @@ export default { unsupportedSorry: 'Lo sentimos', unsupportedHeadline: 'Esta vista no está disponible actualmente', unsupportedInfo: 'Verifique que la vista sea compatible con esta versión, o haga clic en el botón a continuación para volver a la página de inicio.', - unsupportedButton: 'Volver al Panel de control' + unsupportedButton: 'Volver al Panel de control', + printFormat: 'Formato de Impresión', + changePrintFormat: 'Cambiar Formato de Impresión' }, table: { ProcessActivity: { diff --git a/src/store/modules/ADempiere/data.js b/src/store/modules/ADempiere/data.js index 8485c965..c5667075 100644 --- a/src/store/modules/ADempiere/data.js +++ b/src/store/modules/ADempiere/data.js @@ -5,7 +5,8 @@ import { getRecentItems, getDefaultValueFromServer, convertValueFromGRPC, - getContextInfoValueFromServer + getContextInfoValueFromServer, + requestPrintFormats } from '@/api/ADempiere' import { convertValuesMapToObject, isEmptyValue, showMessage, convertAction } from '@/utils/ADempiere' import language from '@/lang' @@ -16,7 +17,8 @@ const data = { recordDetail: [], recentItems: [], inGetting: [], - contextInfoField: [] + contextInfoField: [], + printFormatList: [] }, mutations: { addInGetting(state, payload) { @@ -89,6 +91,9 @@ const data = { }, setContextInfoField(state, payload) { state.contextInfoField.push(payload) + }, + setPrintFormatList(state, payload) { + state.printFormatList.push(payload) } }, actions: { @@ -762,6 +767,27 @@ const data = { .catch(error => { console.warn(`Error ${error.code} getting context info value for field ${error.message}`) }) + }, + requestPrintFormats({ commit }, parameters) { + return requestPrintFormats({ processUuid: parameters.processUuid }) + .then(response => { + const printFormatList = response.getPrintformatsList().map(printFormat => { + return { + uuid: printFormat.getUuid(), + name: printFormat.getName(), + description: printFormat.getDescription(), + isDefault: printFormat.getIsdefault() + } + }) + commit('setPrintFormatList', { + containerUuid: parameters.processUuid, + printFormatList: printFormatList + }) + return printFormatList + }) + .catch(error => { + console.error(error) + }) } }, getters: { @@ -887,6 +913,13 @@ const data = { info.contextInfoUuid === contextInfoUuid && info.sqlStatement === sqlStatement ) + }, + getPrintFormatList: (state) => (containerUuid) => { + var printFormatList = state.printFormatList.find(list => list.containerUuid === containerUuid) + if (printFormatList) { + return printFormatList.printFormatList + } + return [] } } } diff --git a/src/store/modules/ADempiere/processControl.js b/src/store/modules/ADempiere/processControl.js index da3ff5a1..84742f5e 100644 --- a/src/store/modules/ADempiere/processControl.js +++ b/src/store/modules/ADempiere/processControl.js @@ -239,6 +239,26 @@ const processControl = { if (reportType !== 'pdf' && reportType !== 'html') { link.click() } + // Print formats to context menu + var printFormatList = { + name: language.t('views.printFormat'), + type: 'summary', + action: '', + childs: [], + option: 'printFormat' + } + printFormatList.childs = rootGetters.getPrintFormatList(processResult.processUuid) + if (!printFormatList.childs.length) { + dispatch('requestPrintFormats', { + processUuid: processResult.processUuid + }) + .then(response => { + printFormatList.childs = response + // Get contextMenu metadata and concat print Format List with contextMenu actions + var contextMenuMetadata = rootGetters.getContextMenu(processResult.processUuid) + contextMenuMetadata.actions.push(printFormatList) + }) + } } // assign new attributes Object.assign(processResult, { diff --git a/src/views/ADempiere/ReportViewer/index.vue b/src/views/ADempiere/ReportViewer/index.vue index b549cc5e..45697caa 100644 --- a/src/views/ADempiere/ReportViewer/index.vue +++ b/src/views/ADempiere/ReportViewer/index.vue @@ -10,7 +10,7 @@
-

+