Report designer refinement and docs
This commit is contained in:
@@ -3,15 +3,17 @@ let PreParedReportDataObject = null;
|
||||
//////////////////////////////////
|
||||
// Pre render function
|
||||
//
|
||||
async function ayPreRender(ayAllData) {
|
||||
async function ayPreRender(ayData) {
|
||||
if (typeof ayPrepareData === "function") {
|
||||
PreParedReportDataObject = await ayPrepareData(ayAllData);
|
||||
PreParedReportDataObject = await ayPrepareData(ayData);
|
||||
} else {
|
||||
PreParedReportDataObject = ayAllData;
|
||||
PreParedReportDataObject = ayData;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//##################################### HANDLEBARS HELPERS ###################################################
|
||||
|
||||
///////////////////////////////////////
|
||||
// Set our stock handlebars helpers
|
||||
//
|
||||
@@ -129,6 +131,9 @@ function ayRegisterHelpers() {
|
||||
});
|
||||
} //eof
|
||||
|
||||
|
||||
//##################################### LOCALIZATION & TRANSLATION ###################################################
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Turn a utc date into a displayable
|
||||
// short date and time
|
||||
@@ -264,6 +269,9 @@ async function ayGetTranslations(keys) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//##################################### API UTILITIES ###################################################
|
||||
|
||||
///////////////////////////////////
|
||||
// GET DATA FROM API SERVER
|
||||
//
|
||||
@@ -318,12 +326,6 @@ async function ayPostToAPI(route, data, token) {
|
||||
}
|
||||
}
|
||||
|
||||
//Utils
|
||||
function ayPad(n, width, z) {
|
||||
z = z || "0";
|
||||
n = n + "";
|
||||
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// attachment download URL
|
||||
@@ -345,3 +347,41 @@ function attachmentDownloadUrl(fileId, ctype) {
|
||||
|
||||
return AYMETA.ayServerMetaData.ayApiUrl + url;
|
||||
}
|
||||
|
||||
//##################################### CODE UTILITIES ###################################################
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Group by function
|
||||
// reshapes input array into a new array grouped with
|
||||
// a key named "group" with that group's key value
|
||||
// and a key named "items" to contain all items
|
||||
// for that group and also a "count" of items added
|
||||
//
|
||||
//
|
||||
function ayGroupByKey(reportDataArray, groupByKeyName) {
|
||||
//array to hold grouped data
|
||||
const ret = [];
|
||||
//iterate through the raw reprot data
|
||||
for (let i = 0; i < reportDataArray.length; i++) {
|
||||
//search the ret array for a group with this name and if found return a reference to that group object
|
||||
let groupObject = ret.find(z => z.group == reportDataArray[i][groupByKeyName]);
|
||||
if (groupObject != undefined) {
|
||||
//there is already a matching group in the return array so just push this raw report data record into it
|
||||
groupObject.items.push(reportDataArray[i]);
|
||||
//update the count for this group's items
|
||||
groupObject.count++;
|
||||
} else {
|
||||
//No group yet, so start a new one in the ret array and push this raw report data record
|
||||
ret.push({ group: reportDataArray[i][groupByKeyName], items: [reportDataArray[i]], count: 1 });
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//Utils
|
||||
function ayPad(n, width, z) {
|
||||
z = z || "0";
|
||||
n = n + "";
|
||||
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user