Reloading broser when helpers change
diff --git a/views/ngXosLib/.gitignore b/views/ngXosLib/.gitignore
index 9b2df09..34bf3a1 100644
--- a/views/ngXosLib/.gitignore
+++ b/views/ngXosLib/.gitignore
@@ -1,3 +1,4 @@
node_modules
bower_components
-docs
\ No newline at end of file
+docs
+xosHelpers/.tmp
\ No newline at end of file
diff --git a/views/ngXosLib/gulp/ngXosHelpers.js b/views/ngXosLib/gulp/ngXosHelpers.js
index f833fb8..7424218 100644
--- a/views/ngXosLib/gulp/ngXosHelpers.js
+++ b/views/ngXosLib/gulp/ngXosHelpers.js
@@ -5,10 +5,33 @@
var angularFilesort = require('gulp-angular-filesort');
var gulpDocs = require('gulp-ngdocs');
var del = require('del');
+var babel = require('gulp-babel');
+const sourcemaps = require('gulp-sourcemaps');
module.exports = function(options){
- gulp.task('helpers', function(){
- return gulp.src([options.xosHelperSource + '**/*.js'])
+
+ // transpile js with sourceMaps
+ gulp.task('babel', function(){
+ return gulp.src(options.xosHelperSource + '**/*.js')
+ .pipe(babel({
+ presets: ['es2015']
+ }))
+ .pipe(gulp.dest(options.xosHelperTmp));
+ });
+
+ gulp.task('babelDev', function(){
+ return gulp.src(options.xosHelperSource + '**/*.js')
+ .pipe(sourcemaps.init())
+ .pipe(babel({
+ presets: ['es2015']
+ }))
+ .pipe(sourcemaps.write('./maps'))
+ .pipe(gulp.dest(options.xosHelperTmp));
+ });
+
+ // build
+ gulp.task('helpers', ['babel'], function(){
+ return gulp.src([options.xosHelperTmp + '**/*.js'])
.pipe(angularFilesort())
.pipe(concat('ngXosHelpers.js'))
.pipe(ngAnnotate())
@@ -16,6 +39,15 @@
.pipe(gulp.dest(options.ngXosVendor));
});
+ // build Dev (no minify, sourcemaps)
+ gulp.task('helpersDev', ['babelDev'], function(){
+ return gulp.src([options.xosHelperTmp + '**/*.js'])
+ .pipe(angularFilesort())
+ .pipe(concat('ngXosHelpers.js'))
+ .pipe(ngAnnotate())
+ .pipe(gulp.dest(options.ngXosVendor));
+ });
+
gulp.task('cleanDocs', function(){
console.log(options);
return del([options.docs + '**/*']);
@@ -49,4 +81,8 @@
}
}).pipe(gulpDocs.process(ngOptions)).pipe(gulp.dest('./docs'));
});
+
+ gulp.task('dev', function(){
+ gulp.watch(options.xosHelperSource + '**/*.js', ['helpersDev']);
+ });
};
\ No newline at end of file
diff --git a/views/ngXosLib/gulpfile.js b/views/ngXosLib/gulpfile.js
index bb6bc5e..77a5c07 100644
--- a/views/ngXosLib/gulpfile.js
+++ b/views/ngXosLib/gulpfile.js
@@ -6,6 +6,7 @@
var options = {
ngXosVendor: '../../xos/core/xoslib/static/js/vendor/', //save here the minfied vendor file, this is automatically loaded in the django page
xosHelperSource: './xosHelpers/src/',
+ xosHelperTmp: './xosHelpers/.tmp/',
docs: './docs'
};
diff --git a/views/ngXosLib/package.json b/views/ngXosLib/package.json
index 486db22..c25c24a 100644
--- a/views/ngXosLib/package.json
+++ b/views/ngXosLib/package.json
@@ -28,9 +28,11 @@
"del": "^2.2.0",
"gulp": "^3.9.0",
"gulp-angular-filesort": "^1.1.1",
+ "gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.0",
"gulp-ng-annotate": "^1.1.0",
"gulp-ngdocs": "^0.2.13",
+ "gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.4.2",
"http-server": "^0.9.0",
"jasmine-core": "^2.4.1",
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 faeaa26..692b49d 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
@@ -9,6 +9,7 @@
(function () {
'use strict';
+
angular.module('xos.uiComponents.table', [])
.directive('xosTable', function(){
return {
@@ -17,25 +18,26 @@
data: '=',
columns: '='
},
- template: [
- '<!--<pre>{{vm.data | json}}</pre>-->',
- '<table class="table table-striped" ng-show="vm.data.length > 0">',
- '<thead>',
- '<tr>',
- '<th ng-repeat="col in vm.columns">{{col}}</th>',
- '</tr>',
- '</thead>',
- '<tbody>',
- '<tr ng-repeat="item in vm.data">',
- '<td ng-repeat="col in vm.columns">{{item[col]}}</td>',
- '</tr>',
- '</tbody>',
- '</table>'
- ].join(),
+ template: `
+ <!--<pre>{{vm.data | json}}</pre>-->
+ <table class="table table-striped" ng-show="vm.data.length > 0">
+ <thead>
+ <tr>
+ <th ng-repeat="col in vm.columns">{{col}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat="item in vm.data">
+ <td ng-repeat="col in vm.columns">{{item[col]}}</td>
+ </tr>
+ </tbody>
+ </table>
+ `,
bindToController: true,
controllerAs: 'vm',
controller: function(){
console.log(this.data, this.columns);
+ console.log('Bella dello zio, RELOAD');
}
}
})