From 33b4420a5b77ff18a3ac49580d9e83d9455934a1 Mon Sep 17 00:00:00 2001 From: Roberto Zanotto Date: Mon, 12 Sep 2022 14:59:55 +0200 Subject: [PATCH] feat(core/reports): xlsreport: new array functions --- .../core/models/src/utils/expression-utils.ts | 25 +++++++++++++++++++ .../reports/src/xls-report/hindikit-parser.ts | 2 ++ 2 files changed, 27 insertions(+) diff --git a/projects/core/models/src/utils/expression-utils.ts b/projects/core/models/src/utils/expression-utils.ts index 9a40ff84c..02be78be5 100644 --- a/projects/core/models/src/utils/expression-utils.ts +++ b/projects/core/models/src/utils/expression-utils.ts @@ -146,6 +146,8 @@ export class AjfExpressionUtils { BUILD_DATASET: {fn: BUILD_DATASET}, JOIN_FORMS: {fn: JOIN_FORMS}, LEN: {fn: LEN}, + CONCAT: {fn: CONCAT}, + REMOVE_DUPLICATES: {fn: REMOVE_DUPLICATES}, JOIN_REPEATING_SLIDES: {fn: JOIN_REPEATING_SLIDES}, FROM_REPS: {fn: FROM_REPS}, ISIN: {fn: ISIN}, @@ -1847,6 +1849,29 @@ export function LEN(dataset: MainForm | any[]): number { return (dataset as any[]).length || 0; } +/** + * Array concatenation. + * + * @export + * @param {any[]} a + * @param {any[]} b + * @return {*} {any[]} + */ +export function CONCAT(a: any[], b: any[]): any[] { + return a.concat(b); +} + +/** + * Removes duplicate elements from an array. + * + * @export + * @param {any[]} arr + * @return {*} {any[]} + */ +export function REMOVE_DUPLICATES(arr: any[]): any[] { + return [...(new Map(arr.map(v => [JSON.stringify(v), v]))).values()]; +} + /** * return true if date is before then dateToCompare * diff --git a/projects/core/reports/src/xls-report/hindikit-parser.ts b/projects/core/reports/src/xls-report/hindikit-parser.ts index b3efd3cfe..fbf559d67 100644 --- a/projects/core/reports/src/xls-report/hindikit-parser.ts +++ b/projects/core/reports/src/xls-report/hindikit-parser.ts @@ -416,6 +416,8 @@ const functionParams: {[name: string]: boolean[]} = { APPLY: [false, true, true], GET_AGE: [false, false], LEN: [false, false], + CONCAT: [false, false], + REMOVE_DUPLICATES: [false, false], CONSOLE_LOG: [false, false], JOIN_FORMS: [false, false, true, true], JOIN_REPEATING_SLIDES: [false, false, true, true, true, true],