IO-888 Sorted Speedprint
This commit is contained in:
@@ -8,6 +8,7 @@ import { setEmailOptions } from "../redux/email/email.actions";
|
||||
import { store } from "../redux/store";
|
||||
import client from "../utils/GraphQLClient";
|
||||
import { TemplateList } from "./TemplateConstants";
|
||||
import _ from "lodash";
|
||||
const server = process.env.REACT_APP_REPORTS_SERVER_URL;
|
||||
jsreport.serverUrl = server;
|
||||
|
||||
@@ -63,7 +64,7 @@ export async function RenderTemplates(
|
||||
renderAsHtml = false
|
||||
) {
|
||||
//Query assets that match the template name. Must be in format <<templateName>>.query
|
||||
let templateAndData = [];
|
||||
let unsortedTemplatesAndData = [];
|
||||
let proms = [];
|
||||
templateObjects.forEach((template) => {
|
||||
proms.push(
|
||||
@@ -71,7 +72,7 @@ export async function RenderTemplates(
|
||||
let { contextData, useShopSpecificTemplate } = await fetchContextData(
|
||||
template
|
||||
);
|
||||
templateAndData.push({
|
||||
unsortedTemplatesAndData.push({
|
||||
templateObject: template,
|
||||
contextData,
|
||||
useShopSpecificTemplate,
|
||||
@@ -80,6 +81,22 @@ export async function RenderTemplates(
|
||||
);
|
||||
});
|
||||
await Promise.all(proms);
|
||||
|
||||
//Re-order list to follow speedprint.
|
||||
// var templateAndData = _.sortBy(unsortedTemplatesAndData, function (item) {
|
||||
// return templateObjects.findIndex(
|
||||
// (template) => template.name === item.templateObject.name
|
||||
// );
|
||||
// });
|
||||
|
||||
unsortedTemplatesAndData.sort(function (a, b) {
|
||||
return (
|
||||
templateObjects.findIndex((x) => x.name === a.templateObject.name) -
|
||||
templateObjects.findIndex((x) => x.name === b.templateObject.name)
|
||||
);
|
||||
});
|
||||
const templateAndData = unsortedTemplatesAndData;
|
||||
|
||||
let rootTemplate = templateAndData.shift();
|
||||
|
||||
let reportRequest = {
|
||||
|
||||
Reference in New Issue
Block a user