Skip to content

Commit

Permalink
fix: Change report output.
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt committed Jul 21, 2024
1 parent cd4dee2 commit c5ac2ef
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 155 deletions.
4 changes: 1 addition & 3 deletions src/api/ADempiere/logs/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ export function listProcessLogsRequest({
search_value: searchValue
}
}).then(processLogResponse => {
const { convertProcessLog } = require('@/utils/ADempiere/apiConverts/process.js')

return {
recordCount: processLogResponse.record_count,
processLogsList: processLogResponse.process_logs.map(itemProcess => {
return convertProcessLog(itemProcess)
return itemProcess
}),
nextPageToken: processLogResponse.next_page_token
}
Expand Down
39 changes: 7 additions & 32 deletions src/api/ADempiere/reportManagement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,51 +59,26 @@ export function generateReportRequest({
// Get report output from parameters
export function getReportOutputRequest({
processId,
processUuid,
tableName,
printFormatUuid,
reportViewUuid,
printFormatId,
reportViewId,
isSummary,
reportName,
reportType,
parametersList = [],
// query criteria
query,
whereClause,
orderByClause
filters = ''
}) {
const filters = parametersList.map(parameter => {
return {
column_name: parameter.columnName,
value: parameter.value
}
})

return request({
url: '/user-interface/process/report-output',
url: `/report-management/report-output/${processId}/${tableName}`,
method: 'get',
params: {
process_id: processId,
process_uuid: processUuid,
table_name: tableName,
// reference
print_format_uuid: printFormatUuid,
report_view_uuid: reportViewUuid,
print_format_id: printFormatId,
report_view_id: reportViewId,
is_summary: isSummary,
report_name: reportName,
report_type: reportType,
// DSL Query
filters,
criteria: filters,
// Custom Query
query,
where_clause: whereClause,
order_by_clause: orderByClause
filters
}
})
.then(reportOutpuResponse => {
const { convertReportOutput } = require('@/utils/ADempiere/apiConverts/report.js')

return convertReportOutput(reportOutpuResponse)
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ export default defineComponent({
const currentPrintFormat = reportAsPrintFormat.value.childs.find(printFormat => {
return printFormat.id === reportAsPrintFormatValue.value
})
if (isEmptyValue(currentPrintFormat)) {
return ''
if (!isEmptyValue(currentPrintFormat)) {
return currentPrintFormat.tableName
}
return currentPrintFormat.tableName
return ''
})

const reportTypeFormat = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/ADempiere/dictionary/report/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default {
...runReportAsPrintFormat,
containerId: reportId
}
const printFormats = rootGetters.getPrintFormatList(reportId)
const printFormats = rootGetters.getPrintFormatsList(reportId)
if (!isEmptyValue(printFormats)) {
const printFormatChilds = []
printFormats.forEach(printFormat => {
Expand Down
17 changes: 2 additions & 15 deletions src/store/modules/ADempiere/processManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import Vue from 'vue'

import lang from '@/lang'
import router from '@/router'

Expand All @@ -40,21 +38,10 @@ import {
containerManager
} from '@/utils/ADempiere/dictionary/process.js'

const initState = {
printFormatList: {}
}

const processManager = {
state: initState,
state: {},

mutations: {
setPrintFormatsList(state, { containerUuid, printFormatList }) {
Vue.set(state.printFormatList, containerUuid, printFormatList)
},
resetStateProcessManager(state) {
state = initState
}
},
mutations: {},

actions: {
processActionPerformed({ dispatch, getters }, {
Expand Down
120 changes: 85 additions & 35 deletions src/store/modules/ADempiere/reportManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
} from '@/utils/ADempiere/dictionary/report.js'

const initState = {
printFormatList: {},
printFormatsList: {},
reportViewsList: {},
drillTablesList: {},
reportsOutput: {},
Expand All @@ -55,8 +55,8 @@ const reportManager = {
state: initState,

mutations: {
setPrintFormatsList(state, { reportId, printFormatList }) {
Vue.set(state.printFormatList, reportId, printFormatList)
setPrintFormatsList(state, { reportId, printFormatsList }) {
Vue.set(state.printFormatsList, reportId, printFormatsList)
},
setReportViewsList(state, { containerUuid, reportViewsList }) {
Vue.set(state.reportViewsList, containerUuid, reportViewsList)
Expand Down Expand Up @@ -222,8 +222,9 @@ const reportManager = {

commit('setReportOutput', {
...output,
reportId: reportDefinition.id,
reportUuid: reportDefinition.uuid,
instanceUuid: instance_id,
reportUuid: containerUuid,
link,
parameters,
url: link.href,
Expand All @@ -249,7 +250,7 @@ const reportManager = {
}
commit('setReportGenerated', {
containerUuid,
parameters,
parametersList: parameters,
reportType,
printFormatId,
reportViewId
Expand Down Expand Up @@ -318,7 +319,8 @@ const reportManager = {
commit('setReportOutput', {
...output,
instanceUuid,
reportUuid: containerUuid,
reportId: reportDefinition.id,
reportUuid: reportDefinition.uuid,
link,
parametersList,
url: link.href,
Expand Down Expand Up @@ -350,36 +352,40 @@ const reportManager = {
reportId
}) {
return new Promise(resolve => {
listPrintFormatsRequest({ reportId })
listPrintFormatsRequest({
reportId
})
.then(async printFormatResponse => {
const printFormatList = await Promise.all(
printFormatResponse.print_formats.map(async printFormatItem => {
const printFormatsList = printFormatResponse.print_formats.map(printFormatItem => {
return {
...printFormatItem,
reportId: reportId
}
})

commit('setPrintFormatsList', {
reportId,
printFormatsList
})

const tableNamesList = [...new Set(printFormatsList.map(printFormatItem => printFormatItem.table_name))]
await Promise.all(
tableNamesList.map(async tableNameItem => {
await Promise.allSettled([
dispatch('getReportViewsFromServer', {
reportId,
// TODO: Verify if table name is required
tableName: printFormatItem.table_name
tableName: tableNameItem
}),
dispatch('getDrillTablesFromServer', {
reportId,
tableName: printFormatItem.table_name
tableName: tableNameItem
})
])

return {
...printFormatItem,
// reportUuid: reportDefinition.uuid,
reportId: reportId
}
})
)

commit('setPrintFormatsList', {
reportId,
printFormatList
})

resolve(printFormatList)
resolve(printFormatsList)
})
.catch(error => {
console.warn(`Error getting print formats: ${error.message}. Code: ${error.code}.`)
Expand Down Expand Up @@ -477,21 +483,51 @@ const reportManager = {
parametersList = []
}) {
return new Promise(resolve => {
const reportDefinition = rootGetters.getStoredReport(uuid)
const reportOutput = getters.getReportOutput(instanceUuid)
const {
table_name: outputTableName,
print_format_id: outputPrintFormatId,
report_view_id: outputReportViewId,
report_type: outputReportType
} = reportOutput

if (isEmptyValue(printFormatId) || printFormatId <= 0) {
const printFormat = getters.getDefaultPrintFormat(uuid)
if (!isEmptyValue(printFormat)) {
printFormatId = printFormat.printFormatId
printFormatId = outputPrintFormatId
if (isEmptyValue(printFormatId) || printFormatId <= 0) {
const printFormat = getters.getDefaultPrintFormat(uuid)
if (!isEmptyValue(printFormat)) {
printFormatId = printFormat.printFormatId
}
}
}

if (isEmptyValue(reportViewId) || reportViewId <= 0) {
reportViewId = outputReportViewId
}

if (isEmptyValue(reportType)) {
reportType = outputReportType
}

if (isEmptyValue(tableName)) {
tableName = outputTableName
}

if (isEmptyValue(parametersList)) {
parametersList = rootGetters.getParametersToServer({
containerUuid: uuid
})
}

let filters = '{}'
if (!isEmptyValue(parametersList)) {
filters = JSON.stringify(parametersList)
}

getReportOutputRequest({
processUuid: uuid,
parametersList,
processId: reportDefinition.id,
filters,
printFormatId,
reportViewId,
isSummary,
Expand All @@ -510,17 +546,31 @@ const reportManager = {
outputStream: response.output_stream,
type: response.mime_type
})

// router.push({
// path: `/report-viewer/${reportDefinition.id}/${instanceUuid}`,
// name: REPORT_VIEWER_NAME,
// params: {
// reportId: reportDefinition.id,
// reportUuid: reportDefinition.uuid,
// instanceUuid,
// fileName: response.file_name + instance_id,
// // menuParentUuid,
// name: response.name + instance_id,
// tableName: response.table_name
// }
// }, () => {})
}

const reportOutput = {
...response,
reportId: id,
reportUuid: uuid,
reportId: reportDefinition.id,
reportUuid: reportDefinition.uuid,
isError: false,
instanceUuid,
isReport: true,
link,
parametersList,
parameters: parametersList,
url: link.href,
download: link.download
}
Expand Down Expand Up @@ -653,16 +703,16 @@ const reportManager = {
return state.reportsOutput[instanceUuid]
},

getPrintFormatList: (state) => (reportId) => {
return state.printFormatList[reportId] || []
getPrintFormatsList: (state) => (reportId) => {
return state.printFormatsList[reportId] || []
},
getPrintFormat: (state, getters) => ({ reportId, printFormatId }) => {
return getters.getPrintFormatList(reportId).find(printFormat => {
return getters.getPrintFormatsList(reportId).find(printFormat => {
return printFormat.id === printFormatId
})
},
getDefaultPrintFormat: (state, getters) => (reportId) => {
const printFormatsList = getters.getPrintFormatList(reportId)
const printFormatsList = getters.getPrintFormatsList(reportId)

if (isEmptyValue(printFormatsList)) {
return undefined
Expand Down
26 changes: 0 additions & 26 deletions src/utils/ADempiere/apiConverts/process.js

This file was deleted.

Loading

0 comments on commit c5ac2ef

Please sign in to comment.