Report designer refinement and docs

This commit is contained in:
2021-10-13 17:44:34 +00:00
parent 53b38ea0f7
commit 5b228b1d82
57 changed files with 188 additions and 124 deletions

View File

@@ -1,6 +1,6 @@
# PLACEHOLDER
[Incomplete - under construction]
[this document under construction / pre-release]
#STANDARDS FOR AYANOVA DOCS

View File

@@ -1,6 +1,6 @@
# SERVICE RATES Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
Notes to include in docs:

View File

@@ -1,6 +1,6 @@
# TAX CODES Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
Notes to include in docs:

View File

@@ -1,6 +1,6 @@
# TRAVEL RATES Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
Notes to include in docs:

View File

@@ -1,6 +1,6 @@
# ATTACHMENTS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
todo: insert note in docs (ops?) if upload won't work from a device and error not evident check in the AyaNova client error log under help-About and see if there is an error 413 related to the recent file (camera image) upload, as it's likely not AyaNova restricting but a intermediary front end setting, e.g. NGinX
te about nginx somewhere or any front end when receive error 413 when attempt to upload a large attachment.

View File

@@ -4,5 +4,5 @@ This form is used to set the fields displayed and searched in select lists on fo
[Incomplete - under construction]
[this document under construction / pre-release]
This setting is *required* and controls which [translation](adm-translations.md) of AyaNova is used to display program text to the current logged in user.

View File

@@ -1,6 +1,6 @@
# ADM-GLOBAL-SETTINGS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
## Customer Access

View File

@@ -1,3 +1,3 @@
# ADM-HISTORY Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# MISC-ABOUT Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,6 +1,6 @@
# USER CUSTOMIZE FORM Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
#STANDARDS FOR AYANOVA DOCS

View File

@@ -1,3 +1,3 @@
# DATA-LIST-COLUMN-VIEW Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# MISC-RECORD HISTORY Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# CLIENT LOG FORM HELP Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# NOTIFICATION Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,15 +1,15 @@
# REPORT TEMPLATE EDITOR
[Incomplete - under construction]
[this document under construction / pre-release]
AyaNova report templates are html based template documents that are used with the [Handlebars](https://handlebarsjs.com/) templating language to generate html documents that are rendered to .PDF [Portable document format](https://en.wikipedia.org/wiki/PDF) files.
AyaNova report templates are HTML based template documents that are used with the [Handlebars](https://handlebarsjs.com/) templating language to generate HTML documents that are rendered to .PDF [Portable document format](https://en.wikipedia.org/wiki/PDF) files.
HTML and Javascript along with Handlebars templates are used to customize the existing reports in AyaNova and make new ones.
AyaNova comes with a built in report template editor and reports can be created or customized directly within AyaNova.
## Render process
## How reports are rendered by AyaNova
When a report is rendered the following steps take place behind the scenes:
@@ -17,26 +17,20 @@ When a report is rendered the following steps take place behind the scenes:
* The server retrieves the report template from the database, "re-hydrates" the business objects in memory and feeds the data to the report template to be processed by the Handlebars templating engine
* The resulting HTML document is rendered and converted to a .PDF format document and a download URL is sent back to the user's browser to download and open the .pdf document.
### Linking directly to a rendered report
The AyaNova client supports directly linking to a report in an URL, primarily for Customer notification purposes. Only single objects can be linked to for reporting, not lists of objects.
The AyaNova client application expects report urls format as follows: `[PATH_TO_AYANOVA_APP_URL]/viewreport?oid=[objectid]&rid=[reportid]`
If the user is not already logged in, they will be prompted to login first before the report is rendered.
## Report designer template sections
A report template contains several sections:
The report editor has several sections:
### Properties
These are the properties of the report outside of the actual report template itself:
These are the general properties of the report:
* `Name` the name of the report as it is displayed to users for selection. As with all named objects in AyaNova it must be unique, no two reports can have the same name.
* `Active` this controls report availability to users. Set to inactive to keep a report template in the databse but not make it available to users.
* `Roles` this sets which User Roles are allowed to access the report. (*Security note*: no matter what is set here, the server will still not provide data to a report if that data is outside of the Roles of the current user so reporting is not a way to get access to information that is not permitted for a User)
* `Notes` about the template, only displayed in the designer UI, usually reference notes for the people involved in designing the reports.
* `Name` the name of the report as it is displayed to users for selection; no two reports **for the same object type** can have the same name, however you can re-use a name for reports for different AyaNova Types
* `Who can select` this sets which User Roles are allowed to access the report. (*Security note*: no matter what is set here, the server will still not provide data to a report if that data is outside of the Roles of the current user so reporting is not a way to get access to information that is not permitted for a User)
* `Type` this controls the Type of AyaNova object for which this report will be offered as an option. This is useful for duplicating a report for use with a different type of object. For example if you have a report made for a Customer type object you can save a copy and change the Type to HeadOffice for use with a Head Office type object as the fields are almost identical so it will work for either object with only slight changes
* `Active` this controls report availability to users. Set to inactive to keep a report template in the databse but not make it available to users
* `Notes` about the template, only displayed in the designer UI, usually reference notes for the people involved in designing the reports
### PDF Options
@@ -87,25 +81,25 @@ In order to get up to speed quickly with report design we recommend looking over
### CSS
This section is provided to define the HTML Cascading Style Sheet for the report document. This section is optional.
This section is provided to optionally define your own HTML Cascading Style Sheet for the report document.
### Prepare
This section is provided as a way to change the data provided to the report *before* it is rendered.
Typically this function is used to retrieve and / or alter data that is fed to the report template.
Typically this function is used to retrieve and / or alter data that is fed to the report template. For example changing the data from a list of Customer Units to Group By Customer.
Use of the `ayPrepareData` function is optional but the function *must* be present in it's default format even if not used as it is *always* called by the rendering process and will result in an error if missing.
This is the minimum required default definition:
```
async function ayPrepareData(ayAllData) {
return ayAllData;
async function ayPrepareData(ayData) {
return ayData;
}
```
`ayAllData` parameter is an object containing all data provided for the report and is detailed below in the Report Data Objects section.
`ayData` parameter is an object containing all data required to render the report and is detailed below in the [Report Data Objects](#report-data-objects) section.
Note that the SAMPLE DATA section of the user interface in the report designer shows the raw data *before* it is passed to this function, not how it would look *after* this function is run. If you need to see how the data is shaped after a ayPrepareData you can make use of the `ayJSON` helper documented below to view the raw data on the rendered report itself.
@@ -124,9 +118,10 @@ If you do not see this section it means the report designer was opened directly
## Report data objects
When a report template is processed, business object data is provided to the template along with other data. Some of this data is used internally by the provided helpers and you have full access to these data values in your templates and helper / pre-render scripts.
When a report template is processed, business object data is provided to the template along with other data. Some of this data is used internally by the provided helpers and you have full access to these data values in your templates, Handlebar helpers and PrepareData scripts.
The object provided has the following format:
In the `ayPrepareData` function on the Prepare Data tab of the report designer the `ayData` parameter contains three properties detailed below you can use in preparing data:
```{
ayReportData:[...array of business object data...],
@@ -135,9 +130,11 @@ The object provided has the following format:
}
```
In the report template section you must access these three variables by their names directly in your own Handlebars Helpers or in the report's Template. i.e. they are not contained within an object like they are in ayPrepareData but stand alone.
### ayReportData
This is the main business object data provided to the template. It will be identical to the object you see in the `SAMPLE DATA` area of the report designer user interface and is fetched from the server using the same method that populates the report when rendered ensuring consistency between design and rendered report.
This is the main business object data provided to the template. It will be identical in format to the object you see in the `SAMPLE DATA` area of the report designer user interface and is fetched from the server using the same method that populates the report when rendered ensuring consistency between design and rendered report. Note that the Report Designer Sample Data section shows only a limited subset of the entire data that will be provided to the report as it is intended to be a quick sample to show the structure of that particular data, not all the records.
It is *always* provided as an Array. In the case of a single object it will be an array of one, in the case of multiple objects it will be the same object definition but repeated for each object.
@@ -147,6 +144,50 @@ For example if you are reporting off a Customer you would design a report that c
The data provided to the report consists of the same fields visible in the user interface when editing that record and in addition, where appropriate, extra fields to bring in commonly required data from other objects that are linked.
### ayClientMetaData
When a report is rendered some settings from AyaNova running at the User's browser are sent along with the report and are used as required to provide Translations and localized date, time and currency display formats as per the User's preferences as well as the current logged in User's API credential Bearer token and some other Client dependent settings.
You can see what data is provided by using the ayJson helper as in the example above on the report. As of the time of this writing the current values provided are:
```
ayClientMetaData:
{
"UserName": "AyaNova username",
"Authorization": "Bearer eJhbGciO...token...data...hb9JyjcWl3Tib",
"DownloadToken": "IslXKU....token....data...here....Bg2Vx0yT2rQ",
"TimeZoneName": "America/Los_Angeles",
"LanguageName": "en-US",
"Hour12": true,
"CurrencyName": "USD",
"DefaultLocale": "en"
}
```
Most of these properties are intended to be used by the translation and localization [Helper utilities](#built-in-handlebars-helpers) we provide for reporting and some are useful for calling API methods via our [API convenience functions](#api-convenience-functions) provided
### ayServerMetaData
When a report is rendered some settings from the local AyaNova Server are injected into the report data and are used as required to access local server relative settings. For example the URL path to the local AyaNova server's API so that API methods can be called directly in the report template relative to the server's local path.
You can see what data is provided by using the ayJson helper as in the example above on the report. As of the time of this writing the current values provided are:
```
ayServerMetaData:
{
"ayApiUrl": "http://127.0.0.1:7575/api/v8/",
"HasSmallLogo": true,
"HasMediumLogo": true,
"HasLargeLogo": true
}
```
(Note: this is an example only, your server may be different)
* ayApiUrl - this is the URL of the server relative to the report generator and is useful for calling AyaNova API methods in your prepare data function to bring in sources of information from other areas of AyaNova that might not be directly available to your report
* HasXXLogo - these keys are set to true if a Logo has been uploaded for each size to AyaNova and are useful for controlling whether or not to show a logo on a report template as can be seen in many of our sample reports
#### Custom fields
In AyaNova an object can have up to 16 customizable fields of extra data. In the `SAMPLE DATA` area of the reported editor interface you can see the custom field data, for example:
@@ -192,44 +233,10 @@ Currency and decimal number values are provided in simple decimal notation and f
Translated text is displayed in the current logged in User's default Translation setting using the `ayT` Handlebars helper.
### ayClientMetaData
When a report is rendered some settings from the Client browser are sent along with the report and are used as required to localize date, time and currency display formats as well as the current logged in User's API credential Bearer token and some other Client dependent settings.
## Built in Handlebars helpers
You can see what data is provided by using the ayJson helper as in the example above on the report. As of the time of this writing the current values provided are:
```
ayClientMetaData:
{
"UserName": "AyaNova username",
"Authorization": "Bearer eJhbGciO...token...data...hb9JyjcWl3Tib",
"TimeZoneName": "America/Los_Angeles",
"LanguageName": "en-US",
"Hour12": true,
"CurrencyName": "USD",
"DefaultLocale": "en"
}
```
### ayServerMetaData
When a report is rendered some settings from the local AyaNova Server are injected into the report data and are used as required to access local server relative settings. For example the URL path to the local AyaNova server's API so that API methods can be called directly in the report template relative to the server's local path.
You can see what data is provided by using the ayJson helper as in the example above on the report. As of the time of this writing the current values provided are:
```
ayServerMetaData:
{
"ayApiUrl": "http://127.0.0.1:7575/api/v8/"
}
```
(Note: The value is an example only, your server may report a different value for the api url)
## Built in helpers
Several helpers are pre-defined for use with reports:
Several Handlebars helpers are pre-defined for use with reports:
### ayBC
@@ -347,6 +354,16 @@ Format a Wiki Markdown formatted field such as a Wiki field on an object into HT
This is what you use to display a Wiki (or any Markdown formatted text) in a report. AyaNova uses the [Marked](https://marked.js.org/) library to turn Markdown into HTML for display both in the user interface and in reports.
## Built in utility functions
AyaNova comes with some utility functions that you can call from your own helpers or ayPrepareData function.
### Group by
ayGroupByKey
## API Usage
Note that you can use the full power of the [AyaNova developer's API](api-intro.md) with your reports to incorporate data from anywhere in AyaNova as required.
@@ -424,3 +441,10 @@ async function ayPrepareData(reportData) {
## How to link directly to a report
The AyaNova client supports directly linking to a report in an URL, primarily for Customer notification purposes. Only single objects can be linked to for reporting, not lists of objects.
The AyaNova client application expects report urls format as follows: `[PATH_TO_AYANOVA_APP_URL]/viewreport?oid=[objectid]&rid=[reportid]`
If the user is not already logged in, they will be prompted to login first before the report is rendered.

View File

@@ -1,3 +1,3 @@
# MISC-REVIEW (was followup) Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,5 +1,5 @@
# CUSTOMER-CONTACT Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
This form is used to manage Customer type Users known as "Contacts" in AyaNova.

View File

@@ -1,3 +1,3 @@
# CUSTOMER-CSR Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# CUST-CUSTOMER-NOTES Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# CUSTOMER-WORKORDERS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,6 +1,6 @@
# CUST-CUSTOMERS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
todo: a standard link to general how to use the data-table at the top of every list help doc
todo: a standard link to how to use controls at the top of every form doc

View File

@@ -1,3 +1,3 @@
# CUST-HEADOFFICES Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# HOME-DASHBOARD Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# HOME-MEMOS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# HOME-REMINDERS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,6 +1,6 @@
# HOME-REVIEWS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
notes:
All users can see reviews assigned to them in their home menu

View File

@@ -1,3 +1,3 @@
# HOME-TRANSLATION Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# INV-PART-ASSEMBLIES Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# INV-TRANSACTIONS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# INV-PART-INVENTORY Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# INV-PART-REQUESTS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# INV-PART-SERIALS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# INV-PART-STOCK-LEVELS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# INV-PART-WAREHOUSES Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# INV-PARTS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# INV-PO-RECEIPTS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,6 +1,6 @@
# INV-POS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
## OVERVIEW

View File

@@ -1,6 +1,6 @@
# OPERATIONS BACKUP FORM
[Incomplete - under construction]
[this document under construction / pre-release]
AyaNova can automatically back up to the local file system once per day at a selected time.

View File

@@ -1,3 +1,3 @@
# OPS-JOBS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# OPS-LOG Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# OPS-NOTIFY-QUEUE Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# OPS SERVER STATE
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# SVC-CSR Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,6 +1,6 @@
# SVC-LOANERS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
## Shadow units

View File

@@ -1,3 +1,3 @@
# SVC-METER-READINGS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,6 +1,6 @@
# SVC-PMs Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
### Automatic date calculations

View File

@@ -1,3 +1,3 @@
# SVC-PROJECTS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,5 +1,5 @@
# SVC-QUOTES Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
Notes for docs:

View File

@@ -1,3 +1,3 @@
# SVC-TASK-GROUPS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# SVC-UNIT-MODELS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,3 +1,3 @@
# SVC-UNITS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,4 +1,4 @@
# svc-work-order-item-priority Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,4 +1,4 @@
# svc-work-order-item-status Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -1,6 +1,6 @@
# svc-work-order-status Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
todo: locking - locks workorder from edit (other than status for roles that are in status can remove)
todo: completed - used for notification processing

View File

@@ -1,6 +1,6 @@
# SVC-WORKORDERS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]
docs / sections required

View File

@@ -1,3 +1,3 @@
# VENDORS Placeholder
[Incomplete - under construction]
[this document under construction / pre-release]

View File

@@ -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;
}