This commit is contained in:
2020-09-15 23:21:44 +00:00
parent 7bb9d775f1
commit 76ba6efbab
2 changed files with 33 additions and 30 deletions

View File

@@ -138,7 +138,7 @@ namespace AyaNova.Biz
System.IO.DirectoryInfo di = new DirectoryInfo(ReportFilesPath); System.IO.DirectoryInfo di = new DirectoryInfo(ReportFilesPath);
foreach (FileInfo file in di.EnumerateFiles()) foreach (FileInfo file in di.EnumerateFiles())
{ {
if (file.Extension.ToLowerInvariant() == "ayrt") if (file.Extension.ToLowerInvariant() == ".ayrt")
await r.ImportAsync(JObject.Parse(await File.ReadAllTextAsync(file.FullName))); await r.ImportAsync(JObject.Parse(await File.ReadAllTextAsync(file.FullName)));
} }
} }

View File

@@ -13,33 +13,36 @@ async function ayPreRender(ayAllData) {
// Set our stock handlebars helpers // Set our stock handlebars helpers
// //
function ayRegisterHelpers() { function ayRegisterHelpers() {
Handlebars.registerHelper("ayCaps", function (aString) { Handlebars.registerHelper("ayCaps", function (ayValue) {
return aString.toUpperCase(); return ayValue.toUpperCase();
}); });
Handlebars.registerHelper("ayDateTime", function (timestamp) { Handlebars.registerHelper("ayDateTime", function (ayValue) {
return utcDateToShortDateAndTimeLocalized(timestamp); return utcDateToShortDateAndTimeLocalized(ayValue);
}); });
Handlebars.registerHelper("ayDate", function (timestamp) { Handlebars.registerHelper("ayDate", function (ayValue) {
return utcDateToShortDateLocalized(timestamp); return utcDateToShortDateLocalized(ayValue);
}); });
Handlebars.registerHelper("ayTime", function (timestamp) { Handlebars.registerHelper("ayTime", function (ayValue) {
return utcDateToShortTimeLocalized(timestamp); return utcDateToShortTimeLocalized(ayValue);
}); });
Handlebars.registerHelper("ayDecimal", function (value) { Handlebars.registerHelper("ayDecimal", function (ayValue) {
return decimalLocalized(value); return decimalLocalized(ayValue);
}); });
Handlebars.registerHelper("ayCurrency", function (value) { Handlebars.registerHelper("ayCurrency", function (ayValue) {
return currencyLocalized(value); return currencyLocalized(ayValue);
}); });
Handlebars.registerHelper("ayWiki", function (astring) { Handlebars.registerHelper("ayWiki", function (ayValue) {
if(ayValue==null){
return "";
}
return new Handlebars.SafeString( return new Handlebars.SafeString(
DOMPurify.sanitize(marked(astring, { breaks: true })) DOMPurify.sanitize(marked(ayValue, { breaks: true }))
); );
}); });
@@ -122,13 +125,13 @@ function ayRegisterHelpers() {
// short date and time // short date and time
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
// //
function utcDateToShortDateAndTimeLocalized(value) { function utcDateToShortDateAndTimeLocalized(ayValue) {
if (!value) { if (!ayValue) {
return ""; return "";
} }
//parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z")
let parsedDate = new Date(value); let parsedDate = new Date(ayValue);
//is it a valid date? //is it a valid date?
if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { if (!(parsedDate instanceof Date && !isNaN(parsedDate))) {
@@ -149,13 +152,13 @@ function utcDateToShortDateAndTimeLocalized(value) {
// Turn a utc date into a displayable // Turn a utc date into a displayable
// short date // short date
// //
function utcDateToShortDateLocalized(value) { function utcDateToShortDateLocalized(ayValue) {
if (!value) { if (!ayValue) {
return ""; return "";
} }
//parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z")
let parsedDate = new Date(value); let parsedDate = new Date(ayValue);
//is it a valid date? //is it a valid date?
if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { if (!(parsedDate instanceof Date && !isNaN(parsedDate))) {
@@ -174,13 +177,13 @@ function utcDateToShortDateLocalized(value) {
// Turn a utc date into a displayable // Turn a utc date into a displayable
// short time // short time
// //
function utcDateToShortTimeLocalized(value) { function utcDateToShortTimeLocalized(ayValue) {
if (!value) { if (!ayValue) {
return ""; return "";
} }
//parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z")
let parsedDate = new Date(value); let parsedDate = new Date(ayValue);
//is it a valid date? //is it a valid date?
if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { if (!(parsedDate instanceof Date && !isNaN(parsedDate))) {
@@ -201,8 +204,8 @@ function utcDateToShortTimeLocalized(value) {
// CURRENCY LOCALIZATION // CURRENCY LOCALIZATION
// //
// //
function currencyLocalized(value) { function currencyLocalized(ayValue) {
if (!value) { if (!ayValue) {
return ""; return "";
} }
return new Intl.NumberFormat( return new Intl.NumberFormat(
@@ -211,20 +214,20 @@ function currencyLocalized(value) {
style: "currency", style: "currency",
currency: AYMETA.ayClientMetaData.CurrencyName || "USD" currency: AYMETA.ayClientMetaData.CurrencyName || "USD"
} }
).format(value); ).format(ayValue);
} }
/////////////////////////////////////////// ///////////////////////////////////////////
// DECIMAL LOCALIZATION // DECIMAL LOCALIZATION
// //
// //
function decimalLocalized(value) { function decimalLocalized(ayValue) {
if (!value) { if (!ayValue) {
return ""; return "";
} }
return new Intl.NumberFormat( return new Intl.NumberFormat(
AYMETA.ayClientMetaData.LanguageName || "en-US" AYMETA.ayClientMetaData.LanguageName || "en-US"
).format(value); ).format(ayValue);
} }
////////////////////////////////// //////////////////////////////////