Skip to content

Commit

Permalink
fix(core/reports): fix repeat function
Browse files Browse the repository at this point in the history
  • Loading branch information
robzan8 committed Mar 17, 2023
1 parent 25e08b1 commit 1ed9ad4
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions projects/core/models/src/utils/expression-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1346,16 +1346,24 @@ export function buildWidgetDatasetWithDialog(
export function REPEAT(
forms: MainForm[],
array: string[],
fn: AjfValidationFn,
field: string,
filter: Func|string = 'true',
fn: any,
a: string,
b: string = 'true',
): any[] {
if (typeof(filter) === 'string') {
filter = createFunction(filter);
let funcA: Func;
const isFuncA = fn === COUNT_FORMS || fn === COUNT_REPS || fn === FILTER_BY || fn === FROM_REPS;
if (isFuncA) {
funcA = createFunction(a);
}
let funcB: Func;
const isFuncB = fn !== FIRST && fn !== LAST && fn !== APPLY_LABELS;
if (isFuncB) {
funcB = createFunction(b);
}
return array.map(current => {
const currentFilter = (ctx?: AjfContext) => (filter as Func)({...ctx, current});
return (fn as any)(forms, field, currentFilter);
const currentA = isFuncA ? (ctx?: AjfContext) => funcA({...ctx, current}) : a;
const currentB = isFuncB ? (ctx?: AjfContext) => funcB({...ctx, current}) : b;
return (fn as any)(forms, currentA, currentB);
});
}

Expand Down

0 comments on commit 1ed9ad4

Please sign in to comment.