Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/core/models/src/utils/expression-utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Evaluates the expression in the last form by date.
`FILTER_BY(forms, expression)`
Returns a copy of forms and its repetitions, keeping only the ones for which expression evaluates to true.

`FLATTEN_REPS(forms, slideName)`
Returns a copy of forms, modified as follows: if a form has n repeating slides, it is duplicated as n forms,
in which the fields of the repeating slides appear as regular fields.

`JOIN_FORMS(formsA, formsB, $fieldA, $fieldB?)`
Performs a left join of formsA and formsB.
For example, `JOIN_FORMS(anagraphic, medical, $personId)` returns a copy the anagraphic data forms,
Expand Down
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 @@ -152,6 +152,7 @@ export class AjfExpressionUtils {
EVALUATE: {fn: EVALUATE},
FILTER_BY_VARS: {fn: FILTER_BY_VARS},
FILTER_BY: {fn: FILTER_BY},
FLATTEN_REPS: {fn: FLATTEN_REPS},
FIRST: {fn: FIRST},
FROM_REPS: {fn: FROM_REPS},
GET_AGE: {fn: GET_AGE},
Expand Down Expand Up @@ -1877,6 +1878,30 @@ export function FILTER_BY(forms: MainForm[], expression: Func | string): MainFor
return res;
}

/**
* Returns a copy of forms, modified as follows: if a form has n repeating slides,
* it is duplicated as n forms, in which the fields of the repeating slides appear as regular fields.
*/
export function FLATTEN_REPS(forms: MainForm[], slideName: string): MainForm[] {
const res: MainForm[] = [];
for (const form of forms) {
if (form == null) {
continue;
}
const reps = {...form.reps};
const slides = reps[slideName];
delete reps[slideName];
if (slides == null || slides.length === 0) {
res.push({...form, reps});
continue;
}
for (const slide of slides) {
res.push({...form, ...slide, reps});
}
}
return res;
}

/**
* Returns today's date.
*
Expand Down
11 changes: 6 additions & 5 deletions projects/core/reports/src/xls-report/hindikit-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ const functionArgs: {[name: string]: string[]} = {
APPLY_LABELS: ["arg", "arg", "arg"],
APPLY: ["arg", "field", "func(form)"],
BUILD_DATASET: ["arg", "arg?"],
CHART_TO_DATA: ["arg", "arg"],
COMPARE_DATE: ["arg", "arg", "arg", "arg?"],
CONCAT: ["arg", "arg"],
CONSOLE_LOG: ["arg"],
Expand All @@ -404,10 +405,13 @@ const functionArgs: {[name: string]: string[]} = {
DAYS_DIFF: ["arg", "arg"],
FILTER_BY: ["arg", "func(form)"],
FIRST: ["arg", "func(form)", "field?"],
FLATTEN_REPS: ["arg", "arg"],
FORMAT_TABLE_ROWS: ["arg"],
FORMAT_TABLE_COLS: ["arg"],
FORMAT_TABLE_FIELDS: ["arg", "arg"],
FROM_REPS: ["arg", "func(form)"],
GET_AGE: ["arg", "arg?"],
GET_LABELS: ["arg", "arg"],
PROMPT_RESULT: ["arg", "arg"],
INCLUDES: ["arg", "arg"],
IS_AFTER: ["arg", "arg"],
IS_BEFORE: ["arg", "arg"],
Expand All @@ -425,12 +429,9 @@ const functionArgs: {[name: string]: string[]} = {
OP: ["arg", "arg", "func(elemA, elemB)"],
PERCENT: ["arg", "arg"],
PERCENTAGE_CHANGE: ["arg", "arg"],
PROMPT_RESULT: ["arg", "arg"],
REMOVE_DUPLICATES: ["arg"],
ROUND: ["arg", "arg?"],
SUM: ["arg", "field", "func(form)?"],
TODAY: [],
CHART_TO_DATA: ["arg", "arg"],
FORMAT_TABLE_ROWS: ["arg"],
FORMAT_TABLE_COLS: ["arg"],
FORMAT_TABLE_FIELDS: ["arg", "arg"],
};
2 changes: 2 additions & 0 deletions projects/material/forms/src/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ <h2>
(centeredFieldsContent ? ' ajf-centered-field' : '')"
class="ajf-field-entry"
*ngIf="fieldInstance.visible"
[ngStyle]="fieldStyle(fieldInstance|ajfAsFieldInstance)"
>
<i
[class]="(fieldInstance|ajfAsFieldInstance).node.fieldType | ajfFieldIcon"
Expand Down Expand Up @@ -231,6 +232,7 @@ <h2>
(centeredFieldsContent ? ' ajf-centered-field' : '')"
class="ajf-field-entry"
*ngIf="fieldInstance.visible"
[ngStyle]="fieldStyle(fieldInstance|ajfAsFieldInstance)"
>
<i
[class]="(fieldInstance|ajfAsFieldInstance).node.fieldType | ajfFieldIcon"
Expand Down
14 changes: 13 additions & 1 deletion projects/material/forms/src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
*
*/

import {AjfFormRenderer as CoreFormRenderer, AjfFormRendererService} from '@ajf/core/forms';
import {
AjfFormRenderer as CoreFormRenderer,
AjfFormRendererService,
AjfFieldInstance,
AjfFieldType,
} from '@ajf/core/forms';
import {BooleanInput} from '@angular/cdk/coercion';
import {
ChangeDetectionStrategy,
Expand All @@ -46,6 +51,13 @@ export class AjfFormRenderer extends CoreFormRenderer {
super(rendererService, changeDetectorRef);
}

fieldStyle(field: AjfFieldInstance): any {
if (field.node.fieldType === AjfFieldType.Formula && field.node.label === '') {
return {display: 'none'};
}
return {};
}

static ngAcceptInputType_fixedOrientation: BooleanInput;
static ngAcceptInputType_hasEndMessage: BooleanInput;
static ngAcceptInputType_hasStartMessage: BooleanInput;
Expand Down