Skip to content

Commit

Permalink
feat(core/reports): xlsreport: new array functions
Browse files Browse the repository at this point in the history
  • Loading branch information
robzan8 authored and sara-gnucoop committed Sep 12, 2022
1 parent 970d426 commit 33b4420
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions projects/core/models/src/utils/expression-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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
*
Expand Down
2 changes: 2 additions & 0 deletions projects/core/reports/src/xls-report/hindikit-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 33b4420

Please sign in to comment.