Basic form

Change-Id: I7ee858b208730b110b355d3f72037f0975aaa356
diff --git a/src/app/views/crud/crud.ts b/src/app/views/crud/crud.ts
index d1e4d0e..d19a942 100644
--- a/src/app/views/crud/crud.ts
+++ b/src/app/views/crud/crud.ts
@@ -1,22 +1,31 @@
 import {IXosTableCfg} from '../../core/table/table';
 import {IModelStoreService} from '../../datasources/stores/model.store';
 import {IXosConfigHelpersService} from '../../core/services/helpers/config.helpers';
+import * as _ from 'lodash';
 export interface IXosCrudData {
   model: string;
+  related: string[];
   xosTableCfg: IXosTableCfg;
 }
 
 class CrudController {
-  static $inject = ['$state', '$scope', 'ModelStore', 'ConfigHelpers'];
+  static $inject = ['$scope', '$state', '$stateParams', 'ModelStore', 'ConfigHelpers'];
 
   public data: IXosCrudData;
   public tableCfg: IXosTableCfg;
+  public formCfg: any;
+  public stateName: string;
+  public baseUrl: string;
+  public list: boolean;
   public title: string;
   public tableData: any[];
+  public model: any;
+  public related: string[];
 
   constructor(
-    private $state: angular.ui.IStateService,
     private $scope: angular.IScope,
+    private $state: angular.ui.IStateService,
+    private $stateParams: ng.ui.IStateParamsService,
     private store: IModelStoreService,
     private ConfigHelpers: IXosConfigHelpersService
   ) {
@@ -24,6 +33,26 @@
     this.tableCfg = this.data.xosTableCfg;
     this.title = this.ConfigHelpers.pluralize(this.data.model);
 
+    this.list = true;
+    this.stateName = $state.current.name;
+    this.baseUrl = '#/core' + $state.current.url.toString().replace(':id?', '');
+
+    this.related = $state.current.data.related;
+
+    this.formCfg = {
+      formName: 'sampleForm',
+      actions: [
+        {
+          label: 'Save',
+          icon: 'ok', // refers to bootstraps glyphicon
+          cb: (item) => { // receive the model
+            console.log(item);
+          },
+          class: 'success'
+        }
+      ]
+    };
+
     this.store.query(this.data.model)
       .subscribe(
         (event) => {
@@ -31,9 +60,19 @@
           $scope.$evalAsync(() => {
             this.title = this.ConfigHelpers.pluralize(this.data.model, event.length);
             this.tableData = event;
+
+            // if it is a detail page
+            if ($stateParams['id']) {
+              this.model = _.find(this.tableData, {id: parseInt($stateParams['id'], 10)});
+            }
           });
         }
       );
+
+    // if it is a detail page
+    if ($stateParams['id']) {
+      this.list = false;
+    }
   }
 }