Started table component
diff --git a/views/ngXosLib/README.md b/views/ngXosLib/README.md
index 3da0271..2eb73cb 100644
--- a/views/ngXosLib/README.md
+++ b/views/ngXosLib/README.md
@@ -49,6 +49,8 @@
>_NOTE: for the API related service, check documentation in [Apigen](#apigen) section._
+To develop components inside this folder there is a particular command: `npm run dev`, this will watch the helpers file and rebuild them with sourcemaps. For this reason remember to build them when done developing.
+
When some changes are applied to this common library it should be rebuilt with: `npm run build`
### Yo Xos
diff --git a/views/ngXosLib/generator-xos/app/templates/src/templates/users-list.tpl.html b/views/ngXosLib/generator-xos/app/templates/src/templates/users-list.tpl.html
index 03be487..fd8d208 100644
--- a/views/ngXosLib/generator-xos/app/templates/src/templates/users-list.tpl.html
+++ b/views/ngXosLib/generator-xos/app/templates/src/templates/users-list.tpl.html
@@ -1,6 +1,8 @@
<div class="row">
- <h1>Users List</h1>
- <p>This is only an example view.</p>
+ <div class="col-xs-12">
+ <h1>Users List</h1>
+ <p>This is only an example view.</p>
+ </div>
</div>
<div class="row">
<div class="col-xs-4">Email</div>
diff --git a/views/ngXosLib/package.json b/views/ngXosLib/package.json
index c25c24a..6f1060a 100644
--- a/views/ngXosLib/package.json
+++ b/views/ngXosLib/package.json
@@ -8,7 +8,8 @@
"apigen": "node apigen/blueprintToNgResource.js",
"swagger": "node xos-swagger-def.js",
"doc": "gulp docs; cd ./docs; http-server -o -c-1",
- "build": "gulp vendor && gulp helpers"
+ "build": "gulp vendor && gulp helpers",
+ "dev": "gulp dev"
},
"author": "Matteo Scandolo",
"license": "ISC",
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js b/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
index 692b49d..0a81475 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
@@ -16,19 +16,19 @@
restrict: 'E',
scope: {
data: '=',
- columns: '='
+ config: '='
},
template: `
- <!--<pre>{{vm.data | json}}</pre>-->
- <table class="table table-striped" ng-show="vm.data.length > 0">
+ <!-- <pre>{{vm.data | json}}</pre> -->
+ <table ng-class="vm.classes" ng-show="vm.data.length > 0">
<thead>
<tr>
- <th ng-repeat="col in vm.columns">{{col}}</th>
+ <th ng-repeat="col in vm.columns">{{col.label}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in vm.data">
- <td ng-repeat="col in vm.columns">{{item[col]}}</td>
+ <td ng-repeat="col in vm.columns">{{item[col.prop]}}</td>
</tr>
</tbody>
</table>
@@ -36,7 +36,18 @@
bindToController: true,
controllerAs: 'vm',
controller: function(){
- console.log(this.data, this.columns);
+
+ if(!this.config){
+ throw new Error('[xosTable] Please provide a configuration via the "config" attribute');
+ }
+
+ if(!this.config.columns){
+ throw new Error('[xosTable] Please provide a columns list in the configuration');
+ }
+
+ this.columns = this.config.columns;
+ this.classes = this.config.classes || 'table table-striped table-bordered';
+
console.log('Bella dello zio, RELOAD');
}
}
diff --git a/views/ngXosViews/sampleView/src/js/main.js b/views/ngXosViews/sampleView/src/js/main.js
index 896ab77..51f3282 100644
--- a/views/ngXosViews/sampleView/src/js/main.js
+++ b/views/ngXosViews/sampleView/src/js/main.js
@@ -25,6 +25,25 @@
controllerAs: 'vm',
templateUrl: 'templates/users-list.tpl.html',
controller: function(Users){
+
+ this.tableConfig = {
+ columns: [
+ {
+ label: 'E-Mail',
+ prop: 'email'
+ },
+ {
+ label: 'E-Mail',
+ prop: 'firstname'
+ },
+ {
+ label: 'E-Mail',
+ prop: 'lastname'
+ }
+ ],
+ classes: 'table table-striped table-condensed'
+ };
+
// retrieving user list
Users.query().$promise
.then((users) => {
diff --git a/views/ngXosViews/sampleView/src/templates/users-list.tpl.html b/views/ngXosViews/sampleView/src/templates/users-list.tpl.html
index edb214a..4cb8d5a 100644
--- a/views/ngXosViews/sampleView/src/templates/users-list.tpl.html
+++ b/views/ngXosViews/sampleView/src/templates/users-list.tpl.html
@@ -1,6 +1,8 @@
<div class="row">
- <h1>Users List</h1>
- <p>This is only an example view.</p>
+ <div class="col-xs-12">
+ <h1>Users List</h1>
+ <p>This is only an example view.</p>
+ </div>
</div>
<div class="row">
<div class="col-xs-4">Email</div>
@@ -14,5 +16,7 @@
</div>
<div class="row">
- <xos-table></xos-table>
+ <div class="col-xs-12">
+ <xos-table data="vm.users" config="vm.tableConfig"></xos-table>
+ </div>
</div>
\ No newline at end of file