This commit is contained in:
@@ -382,6 +382,13 @@ namespace AyaNova.Biz
|
|||||||
//add Marked for markdown processing
|
//add Marked for markdown processing
|
||||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-md.js") });
|
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-md.js") });
|
||||||
|
|
||||||
|
//Wait, might not need luxon, it appears I only use that for relative date calculations
|
||||||
|
//Luxon https://moment.github.io/luxon/
|
||||||
|
// await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-lux.js") });
|
||||||
|
|
||||||
|
|
||||||
|
//VueCurrencyInput - base currency handling lib whatever that is
|
||||||
|
|
||||||
//add stock helpers
|
//add stock helpers
|
||||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") });
|
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") });
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,46 @@
|
|||||||
|
//////////////////////////////////
|
||||||
|
// Pre render function
|
||||||
|
//
|
||||||
|
async function ayPreRender(ayAllData) {
|
||||||
|
if (typeof ayPrepareData === "function") {
|
||||||
|
return await ayPrepareData(ayAllData);
|
||||||
|
} else {
|
||||||
|
return ayAllData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
"AYMETA": {
|
||||||
|
"ayReportMetaData": { "Id": 1, "Name": "report translation test", "Notes": "", "ObjectType": "Widget", "DataListKey": "", "ListView":"", "SelectedRowIds": "90" },
|
||||||
|
"ayClientMetaData": {
|
||||||
|
"UserName": "AyaNova SuperUser",
|
||||||
|
"Authorization": "BearereyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxNjAwMjYzOTEzIiwiaXNzIjoiYXlhbm92YS5jb20iLCJpZCI6IjEifQ.NGpDgg8mf54oTU8fyExBf1yXnsaIaHedGFmKLKlNCZ4",
|
||||||
|
"TimeZoneName": "America/Los_Angeles", "LanguageName": "en-US", "Hour12": true, "CurrencyName": "USD", "DefaultLocale": "en" }
|
||||||
|
*/
|
||||||
|
|
||||||
|
///////////////////////////////////////
|
||||||
|
// Set our stock handlebars helpers
|
||||||
|
//
|
||||||
function ayRegisterHelpers() {
|
function ayRegisterHelpers() {
|
||||||
Handlebars.registerHelper("ayCaps", function (aString) {
|
Handlebars.registerHelper("ayCaps", function (aString) {
|
||||||
return aString.toUpperCase();
|
return aString.toUpperCase();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper("ayDateTime", function (timestamp) {
|
||||||
|
return utcDateToShortDateAndTimeLocalized(timestamp);
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper("ayDate", function (timestamp) {
|
||||||
|
return utcDateToShortDateLocalized(timestamp);
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper("ayTime", function (timestamp) {
|
||||||
|
return utcDateToShortTimeLocalized(timestamp);
|
||||||
|
});
|
||||||
|
|
||||||
|
//ayDecimal
|
||||||
|
//ayCurrency
|
||||||
|
|
||||||
Handlebars.registerHelper("ayMarkdown", function (astring) {
|
Handlebars.registerHelper("ayMarkdown", function (astring) {
|
||||||
return marked(astring, { breaks: true });
|
return marked(astring, { breaks: true });
|
||||||
});
|
});
|
||||||
@@ -33,12 +71,75 @@ function ayRegisterHelpers() {
|
|||||||
});
|
});
|
||||||
} //eof
|
} //eof
|
||||||
|
|
||||||
async function ayPreRender(ayAllData) {
|
///////////////////////////////////////////
|
||||||
if (typeof ayPrepareData === "function") {
|
// Turn a utc date into a displayable
|
||||||
return await ayPrepareData(ayAllData);
|
// short date and time
|
||||||
} else {
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
|
||||||
return ayAllData;
|
//
|
||||||
|
function utcDateToShortDateAndTimeLocalized(value) {
|
||||||
|
if (!value) {
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z")
|
||||||
|
let parsedDate = new Date(value);
|
||||||
|
|
||||||
|
//is it a valid date?
|
||||||
|
if (!(parsedDate instanceof Date && !isNaN(parsedDate))) {
|
||||||
|
return "not valid";
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedDate.toLocaleString(AYMETA.ayClientMetaData.LanguageName, {
|
||||||
|
timeZone: AYMETA.ayClientMetaData.TimeZoneName,
|
||||||
|
dateStyle: "short",
|
||||||
|
timeStyle: "short",
|
||||||
|
hour12: AYMETA.ayClientMetaData.Hour12
|
||||||
|
});
|
||||||
|
}
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// Turn a utc date into a displayable
|
||||||
|
// short date
|
||||||
|
//
|
||||||
|
function utcDateToShortDateLocalized(value) {
|
||||||
|
if (!value) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z")
|
||||||
|
let parsedDate = new Date(value);
|
||||||
|
|
||||||
|
//is it a valid date?
|
||||||
|
if (!(parsedDate instanceof Date && !isNaN(parsedDate))) {
|
||||||
|
return "not valid";
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedDate.toLocaleDateString(AYMETA.ayClientMetaData.LanguageName, {
|
||||||
|
timeZone: AYMETA.ayClientMetaData.TimeZoneName,
|
||||||
|
dateStyle: "short"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// Turn a utc date into a displayable
|
||||||
|
// short time
|
||||||
|
//
|
||||||
|
function utcDateToShortTimeLocalized(value) {
|
||||||
|
if (!value) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z")
|
||||||
|
let parsedDate = new Date(value);
|
||||||
|
|
||||||
|
//is it a valid date?
|
||||||
|
if (!(parsedDate instanceof Date && !isNaN(parsedDate))) {
|
||||||
|
return "not valid";
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedDate.toLocaleTimeString(AYMETA.ayClientMetaData.LanguageName, {
|
||||||
|
timeZone: AYMETA.ayClientMetaData.TimeZoneName,
|
||||||
|
timeStyle: "short",
|
||||||
|
hour12: AYMETA.ayClientMetaData.Hour12
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user