Properly mocked resources and promises
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
index d9fa9cc..b339f89 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
@@ -28,7 +28,13 @@
config: '='
},
template: `
- <pre>{{vm.responseErr}}</pre>
+ <div class="row" ng-show="vm.data.length > 0">
+ <div class="col-xs-12 text-right">
+ <a href="" class="btn btn-success" ng-click="vm.createItem()">
+ Add
+ </a>
+ </div>
+ </div>
<xos-table config="vm.tableConfig" data="vm.data"></xos-table>
<div class="panel panel-default" ng-show="vm.detailedItem">
<div class="panel-heading">
@@ -54,6 +60,10 @@
controllerAs: 'vm',
controller: function($injector, LabelFormatter, _){
+ // NOTE
+ // Corner case
+ // - if response is empty, how can we generate a form ?
+
this.responseMsg = false;
this.responseErr = false;
@@ -67,7 +77,6 @@
cb: (item) => {
this.Resource.delete({id: item.id}).$promise
.then(() => {
- console.log(this.config.resource);
this.responseMsg = `${this.config.resource} with id ${item.id} successfully deleted`;
})
.catch(err => {
@@ -115,7 +124,12 @@
this.cleanForm = () => {
delete this.detailedItem;
- }
+ };
+
+ this.createItem = () => {
+ this.detailedItem = new this.Resource();
+ console.log(this.detailedItem);
+ };
this.Resource = $injector.get(this.config.resource);
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.scss b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.scss
new file mode 100644
index 0000000..03342f1
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.scss
@@ -0,0 +1,5 @@
+xos-smart-table{
+ .row + xos-table {
+ margin-top: 15px;
+ }
+}
\ No newline at end of file