From db2d3811998eab3780cbb3a73bc363a1829f481a Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Thu, 4 Apr 2019 16:10:57 -0400 Subject: [PATCH] Checkbox property control handle strings and numbers --- src/lib/shared/flo-properties.ts | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/lib/shared/flo-properties.ts b/src/lib/shared/flo-properties.ts index c2cafaf..43a1881 100644 --- a/src/lib/shared/flo-properties.ts +++ b/src/lib/shared/flo-properties.ts @@ -109,10 +109,32 @@ export namespace Properties { protected getValue() { const res = super.getValue(); - if (typeof res !== 'boolean') { - return this.property.defaultValue; + const type = typeof res; + switch (type) { + case 'boolean': + return res; + case 'string': + switch ((res).trim().toLowerCase()) { + case 'true': + case '1': + return true; + case 'false': + case '0': + return false; + default: + return this.property.defaultValue + } + case 'number': + const num = res; + if (num === 0) { + return false; + } else if (num === 1) { + return true; + } else { + return this.property.defaultValue + } } - return res; + return this.property.defaultValue; } }