Skip to content

Commit

Permalink
Merge pull request #885 from IDEMSInternational/fix/hidden-overrides
Browse files Browse the repository at this point in the history
fix hidden overrides
  • Loading branch information
smborio authored Jul 2, 2021
2 parents f66a377 + 12695e5 commit 41c56ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FlowTypes } from "src/app/shared/model";
import { booleanStringToBoolean } from "src/app/shared/utils";
import { TemplateContainerComponent } from "../template-container.component";
import { mergeTemplateRows } from "../utils/template-utils";

Expand Down Expand Up @@ -223,10 +224,12 @@ export class TemplateRowService {
const translatedRow = this.container.templateTranslateService.translateRow(parsedRow);

const row = translatedRow;
const { name, value, hidden, type, _dynamicFields } = row;
const { name, value, type, _dynamicFields } = row;

// Make type assigned to hidden consistent
row.hidden = ["true", true, "TRUE"].includes(hidden) ? true : false;
if (row.hasOwnProperty("hidden")) {
row.hidden = booleanStringToBoolean(row.hidden);
}

if (type === "template") isNestedTemplate = true;

Expand Down
10 changes: 5 additions & 5 deletions src/app/shared/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ export type IFunctionHashmap = { [function_name: string]: (...args: any) => any
* convert strings containing "TRUE", "true", "FALSE" or "false" to booleans
* TODO - combine with script util
*/
export function booleanStringToBoolean(str: string) {
if (typeof str === "string") {
if (str.match(/^true$/gi)) return true;
if (str.match(/^false$/gi)) return false;
export function booleanStringToBoolean(val: any) {
if (typeof val === "string") {
if (val.match(/^true$/gi)) return true;
if (val.match(/^false$/gi)) return false;
}
return str;
return val;
}

/**
Expand Down

0 comments on commit 41c56ec

Please sign in to comment.