[CORD-1856] Correctly parsing boolena default values

Change-Id: Id3ea018b95855105b60198231afcf8c2725c8eb6
diff --git a/src/app/core/field/field.html b/src/app/core/field/field.html
index b3597fd..a91665d 100644
--- a/src/app/core/field/field.html
+++ b/src/app/core/field/field.html
@@ -15,7 +15,6 @@
 limitations under the License.
 -->
 
-
 <label ng-if="vm.field.type !== 'object' && vm.field.type !== 'array'">
     {{vm.field.label}}
     <span class="required" ng-if="vm.field.validators.required">*</span>
diff --git a/src/app/core/field/field.ts b/src/app/core/field/field.ts
index 89fdd76..ab5f1d2 100644
--- a/src/app/core/field/field.ts
+++ b/src/app/core/field/field.ts
@@ -57,7 +57,7 @@
     }
 
     // NOTE set default value (if any)
-    if (this.field.default && !angular.isDefined(this.ngModel)) {
+    if (angular.isDefined(this.field.default) && angular.isUndefined(this.ngModel)) {
       if (this.field.type === 'number') {
         this.ngModel = parseInt(this.field.default, 10);
       }
diff --git a/src/app/core/form/form.html b/src/app/core/form/form.html
index 072039d..d619fc7 100644
--- a/src/app/core/form/form.html
+++ b/src/app/core/form/form.html
@@ -15,8 +15,6 @@
 limitations under the License.
 -->
 
-
-<!--<pre>{{vm.config.inputs | json}}</pre>-->
 <form name="vm.{{vm.config.formName || 'form'}}" novalidate>
     <!--<div class="form-group" ng-repeat="(name, field) in vm.formField">-->
         <!--<xos-field name="name" field="field" ng-model="vm.ngModel[name]"></xos-field>-->
diff --git a/src/app/core/services/helpers/config.helpers.spec.ts b/src/app/core/services/helpers/config.helpers.spec.ts
index f06fc4f..7718a44 100644
--- a/src/app/core/services/helpers/config.helpers.spec.ts
+++ b/src/app/core/services/helpers/config.helpers.spec.ts
@@ -211,6 +211,7 @@
 
       expect(cols[4]).not.toBeDefined();
     });
+
   });
 
   describe('the modelToTableCfg method', () => {
@@ -245,6 +246,26 @@
       expect(inputs[2].validators.min).toBe(20);
       expect(inputs[2].validators.max).toBe(40);
     });
+
+    it('should convert boolean defaults to real booleans', () => {
+      const fields: IXosModelDefsField[] = [
+        {
+          type: 'boolean',
+          name: 'active',
+          default: '"True"',
+          validators: []
+        },
+        {
+          type: 'boolean',
+          name: 'disabled',
+          default: '"False"',
+          validators: []
+        },
+      ];
+      const form_fields = service.modelFieldToInputCfg(fields);
+      expect(form_fields[0].default).toBe(true);
+      expect(form_fields[1].default).toBe(false);
+    });
   });
 
   describe('the modelToFormCfg method', () => {
diff --git a/src/app/core/services/helpers/config.helpers.ts b/src/app/core/services/helpers/config.helpers.ts
index c177568..e4a0a70 100644
--- a/src/app/core/services/helpers/config.helpers.ts
+++ b/src/app/core/services/helpers/config.helpers.ts
@@ -257,7 +257,7 @@
         type: f.type,
         validators: this.formatValidators(f.validators),
         hint: f.hint,
-        default: f.default || null
+        default: this.formatDefaultValues(f.default)
       };
 
       // NOTE populate drop-downs based on relation
@@ -277,6 +277,7 @@
   }
 
   public modelToFormCfg(model: IXosModeldef): IXosFormCfg {
+
     const formCfg: IXosFormCfg = {
       formName: `${model.name}Form`,
       exclude: this.form_excluded_fields,
@@ -338,6 +339,21 @@
     return formCfg;
   }
 
+  private formatDefaultValues(val: any): any {
+
+    if (angular.isString(val)) {
+      const unquoted = val.split('"').join('').toLowerCase();
+      if (unquoted === 'true') {
+        return true;
+      }
+      else if (unquoted === 'false') {
+        return false;
+      }
+    }
+
+    return val || undefined;
+  }
+
   private formatValidators(validators: IXosModelDefsFieldValidators[]): IXosFormInputValidator {
     // convert validators as expressed from modelDefs,
     // to the object required by xosForm