This commit is contained in:
2021-12-28 19:01:28 +00:00
parent b6e4878269
commit 9085b6e88d
6 changed files with 114 additions and 100 deletions

View File

@@ -299,6 +299,8 @@ TESTING INFO:
- 1 todo: cancellable reporting?? Jobify it just like any other long running job, it's necessary unfortunately and then put a cancel button - 1 todo: cancellable reporting?? Jobify it just like any other long running job, it's necessary unfortunately and then put a cancel button
- direct print report from url must be tested and fixed up - direct print report from url must be tested and fixed up
http://localhost:8080/viewreport/103/57
redocument as the format has changed and also update the notify code as the format has changed no longer a query string but a full path as in above
- upload and test on devops - upload and test on devops
- give to Joyce to mangle - give to Joyce to mangle

View File

@@ -639,38 +639,38 @@ export default {
PDFTime: window.$gz.locale.utcDateToShortTimeLocalized(nowUtc) PDFTime: window.$gz.locale.utcDateToShortTimeLocalized(nowUtc)
}; };
}, },
/////////////////////////////////// // ///////////////////////////////////
// RENDER REPORT DIRECTLY // // RENDER REPORT DIRECTLY
// // //
// // //
async renderReport(objectid, reportid, redirectNotPopup) { // async renderReport(objectid, reportid, redirectNotPopup) {
const reportDataOptions = { // const reportDataOptions = {
ReportId: reportid, // ReportId: reportid,
SelectedRowIds: [objectid], // SelectedRowIds: [objectid],
ClientMeta: this.reportClientMetaData() // ClientMeta: this.reportClientMetaData()
}; // };
const res = await window.$gz.api.upsert("report/render", reportDataOptions); // const res = await window.$gz.api.upsert("report/render", reportDataOptions);
if (res.error) { // if (res.error) {
if (redirectNotPopup) { // if (redirectNotPopup) {
return res; // return res;
} else { // } else {
throw new Error(window.$gz.errorHandler.errorToString(res)); // throw new Error(window.$gz.errorHandler.errorToString(res));
} // }
} else { // } else {
const reportUrl = window.$gz.api.reportDownloadUrl(res.data); // const reportUrl = window.$gz.api.reportDownloadUrl(res.data);
if (redirectNotPopup) { // if (redirectNotPopup) {
//used for direct report open from direct report view url // //used for direct report open from direct report view url
window.location.replace(reportUrl); // window.location.replace(reportUrl);
} else { // } else {
if (window.open(reportUrl, "Report") == null) { // if (window.open(reportUrl, "Report") == null) {
throw new Error( // throw new Error(
"Problem displaying report in new window. Browser must allow pop-ups to view reports; check your browser setting" // "Problem displaying report in new window. Browser must allow pop-ups to view reports; check your browser setting"
); // );
} // }
} // }
} // }
}, // },
/////////////////////////////////// ///////////////////////////////////
// FETCH BIZ OBJECT NAME // FETCH BIZ OBJECT NAME
// //

View File

@@ -71,6 +71,12 @@ export default new Router({
component: () => component: () =>
import(/* webpackChunkName: "ay-common" */ "./views/ay-open.vue") import(/* webpackChunkName: "ay-common" */ "./views/ay-open.vue")
}, },
{
path: "/viewreport/:oid/:rid",
name: "ay-report-view",
component: () =>
import(/* webpackChunkName: "ay-common" */ "./views/ay-report-view.vue")
},
{ {
path: "/about", path: "/about",
name: "ay-about", name: "ay-about",
@@ -1064,27 +1070,27 @@ export default new Router({
}, },
//############################## SPECIAL ROUTES ############################### //############################## SPECIAL ROUTES ###############################
{ // {
//REPORT VIEW FROM URL // //REPORT VIEW FROM URL
path: "/viewreport", // path: "/viewreport",
beforeEnter: async (to, from, next) => { // beforeEnter: async (to, from, next) => {
//open report links have a query string /viewreport?oid=[objectid]&rid=[reportid] // //open report links have a query string /viewreport?oid=[objectid]&rid=[reportid]
const objectId = parseInt(to.query.oid); // const objectId = parseInt(to.query.oid);
const reportId = parseInt(to.query.rid); // const reportId = parseInt(to.query.rid);
const res = await window.$gz.api.renderReport(objectId, reportId, true); // const res = await window.$gz.api.renderReport(objectId, reportId, true);
if (res.error) { // if (res.error) {
//log the error and do a popup for it // //log the error and do a popup for it
const msg = `/viewReport, query ${JSON.stringify( // const msg = `/viewReport, query ${JSON.stringify(
to.query // to.query
)}, server error: ${JSON.stringify(res.error)}`; // )}, server error: ${JSON.stringify(res.error)}`;
window.$gz.eventBus.$emit("notify-error", msg); // window.$gz.eventBus.$emit("notify-error", msg);
next("/applog"); // next("/applog");
} // }
next(false); // next(false);
} // }
}, // },
{ {
path: "/ay-evaluate", path: "/ay-evaluate",

View File

@@ -873,54 +873,6 @@ export default {
vm.rendering = false; vm.rendering = false;
window.$gz.errorHandler.handleFormError(ex, vm); window.$gz.errorHandler.handleFormError(ex, vm);
} }
},
async xxrender() {
const vm = this;
if (vm.$route.params.recordid == 0) {
return;
}
const reportDataOptions = vm.$route.params.reportDataOptions;
if (!reportDataOptions) {
throw new Error(
"Missing report data: to view report must come here from an object edit form or list so data can be provided for viewing the report"
);
}
reportDataOptions.ReportId = vm.obj.id;
//Meta data from client for use by report script
reportDataOptions.ClientMeta = window.$gz.api.reportClientMetaData();
window.$gz.form.setFormState({
vm: vm,
loading: true
});
try {
window.$gz.form.deleteAllErrorBoxErrors(vm);
vm.rendering = true;
const res = await window.$gz.api.upsert(
"report/render",
reportDataOptions
);
vm.rendering = false;
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
const reportUrl = window.$gz.api.reportDownloadUrl(res.data);
if (window.open(reportUrl, "Report") == null) {
vm.formState.serverError =
"Problem displaying report in new window. Browser must allow pop-ups to view reports; check your browser setting";
window.$gz.form.setErrorBoxErrors(vm);
}
}
} catch (ex) {
vm.rendering = false;
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
vm.rendering = false;
window.$gz.form.setFormState({
vm: vm,
loading: false
});
}
} }
} }
}; };

View File

@@ -0,0 +1,43 @@
<template>
<div>
<span>📖...</span>
<gz-report-selector ref="reportSelector"></gz-report-selector>
</div>
</template>
<script>
//THIS FORM IS USED WHEN CLICKING ON A REPORT URL FROM A NOTIFICATION EMAIL ETC
//it's only ever called from the router directly
export default {
data() {
return {};
},
async created() {
const vm = this;
//open report links have url format /viewreport/[objectid]/[reportid]
//path: "/viewreport/:oid/:rid",
const objectId = parseInt(vm.$route.params.oid);
const reportId = parseInt(vm.$route.params.rid);
if (!objectId || !reportId) {
throw new Error(
"Missing report data: oid or rid are not set, unable to render report"
);
}
const reportDataOptions = {
ReportId: reportid,
SelectedRowIds: [objectid],
ClientMeta: window.$gz.api.reportClientMetaData()
};
try {
await vm.$refs.reportSelector.open(reportDataOptions, reportid);
} catch (ex) {
vm.rendering = false;
window.$gz.errorHandler.handleFormError(ex, vm);
}
}
};
</script>

View File

@@ -589,9 +589,20 @@ export default {
(async function() { (async function() {
//open report links have a query string /viewreport?oid=[objectid]&rid=[reportid] //open report links have a query string /viewreport?oid=[objectid]&rid=[reportid]
const searchParams = new URLSearchParams(vm.$route.params.search); const searchParams = new URLSearchParams(vm.$route.params.search);
const objectId = parseInt(searchParams.get("oid")); //const objectId = parseInt(searchParams.get("oid"));
const reportId = parseInt(searchParams.get("rid")); const reportId = parseInt(searchParams.get("rid"));
await window.$gz.api.renderReport(objectId, reportId); //objectid,reportid //await window.$gz.api.renderReport(objectId, reportId); //objectid,reportid
const reportDataOptions = {
ReportId: reportId,
SelectedRowIds: [parseInt(searchParams.get("oid"))],
ClientMeta: window.$gz.api.reportClientMetaData()
};
try {
await vm.$refs.reportSelector.open(reportDataOptions, reportId);
} catch (ex) {
window.$gz.errorHandler.handleFormError(ex, vm);
}
})(); })();
vm.$router.push(vm.$store.state.homePage); vm.$router.push(vm.$store.state.homePage);
} else { } else {