[CORD-1539] Support for static choices and default values

Change-Id: I988b1863221a0678aff1bd151fb2d26e1a33fe92
diff --git a/src/app/core/field/field.html b/src/app/core/field/field.html
index 9baa1d5..5dad952 100644
--- a/src/app/core/field/field.html
+++ b/src/app/core/field/field.html
@@ -12,7 +12,7 @@
         ng-minlength="vm.field.validators.minlength || 0"
         ng-maxlength="vm.field.validators.maxlength || 2000"
         ng-required="vm.field.validators.required || false" />
-<select class="form-control" ng-if ="vm.field.type === 'select'"
+<select class="form-control" ng-if="vm.field.type === 'select'"
         name = "{{vm.name}}"
         ng-options="item.id as item.label for item in vm.field.options"
         ng-model="vm.ngModel"
diff --git a/src/app/core/field/field.ts b/src/app/core/field/field.ts
index 5c5b48a..f05a8e4 100644
--- a/src/app/core/field/field.ts
+++ b/src/app/core/field/field.ts
@@ -38,6 +38,16 @@
       throw new Error('[xosField] Please provide an ng-model');
     }
 
+    // NOTE set default value (if any)
+    if (this.field.default && !angular.isDefined(this.ngModel)) {
+      if (this.field.type === 'number') {
+        this.ngModel = parseInt(this.field.default, 10);
+      }
+      else {
+        this.ngModel = this.field.default;
+      }
+    }
+
 
     if (this.field.type === 'array') {
       this.$scope.$watch(() => this.ngModel.length, () => {
diff --git a/src/app/core/form/form.ts b/src/app/core/form/form.ts
index 1c01e31..273e9b1 100644
--- a/src/app/core/form/form.ts
+++ b/src/app/core/form/form.ts
@@ -41,6 +41,7 @@
   hint?: string;
   validators: IXosFormInputValidator;
   options?: IXosFormInputOptions[];
+  default?: any | null;
 }
 
 export interface IXosFormCfg {
diff --git a/src/app/core/services/helpers/config.helpers.ts b/src/app/core/services/helpers/config.helpers.ts
index b49b27c..88b4c06 100644
--- a/src/app/core/services/helpers/config.helpers.ts
+++ b/src/app/core/services/helpers/config.helpers.ts
@@ -2,7 +2,7 @@
 import * as pluralize from 'pluralize';
 import {IXosTableColumn, IXosTableCfg} from '../../table/table';
 import {IXosModeldef} from '../../../datasources/rest/modeldefs.rest';
-import {IXosFormCfg, IXosFormInput, IXosFormInputValidator} from '../../form/form';
+import {IXosFormCfg, IXosFormInput, IXosFormInputValidator, IXosFormInputOptions} from '../../form/form';
 import {IXosModelStoreService} from '../../../datasources/stores/model.store';
 import {IXosState} from '../runtime-states';
 
@@ -21,6 +21,8 @@
     model: string;
     type: string;
   };
+  options?: IXosFormInputOptions[];
+  default?: any | null;
 }
 
 export interface IXosConfigHelpersService {
@@ -217,12 +219,20 @@
         label: this.toLabel(f.name),
         type: f.type,
         validators: this.formatValidators(f.validators),
-        hint: f.hint
+        hint: f.hint,
+        default: f.default || null
       };
+
+      // NOTE populate drop-downs based on relation
       if (f.relation) {
         input.type = 'select';
         this.populateSelectField(f, input);
-        return input;
+      }
+      // NOTE if static options are defined in modeldefs
+      // the f.options field is already populated,
+      // we just need to move it to the input
+      else if (f.options && f.options.length > 0) {
+        input.options = f.options;
       }
       return input;
     })