Commit b985fb75db619d1556fc7c4b330a025bd1c8f137

Authored by Pablo Marco del Pont
1 parent bbdcd67f27
Exists in master

Refactor de nombre de módulo.

1 const templateCache = require('gulp-angular-templatecache'); 1 const templateCache = require('gulp-angular-templatecache');
2 const clean = require('gulp-clean'); 2 const clean = require('gulp-clean');
3 const concat = require('gulp-concat'); 3 const concat = require('gulp-concat');
4 const htmlmin = require('gulp-htmlmin'); 4 const htmlmin = require('gulp-htmlmin');
5 const rename = require('gulp-rename'); 5 const rename = require('gulp-rename');
6 const uglify = require('gulp-uglify'); 6 const uglify = require('gulp-uglify');
7 const gulp = require('gulp'); 7 const gulp = require('gulp');
8 const pump = require('pump'); 8 const pump = require('pump');
9 const jshint = require('gulp-jshint'); 9 const jshint = require('gulp-jshint');
10 const replace = require('gulp-replace'); 10 const replace = require('gulp-replace');
11 const connect = require('gulp-connect'); 11 const connect = require('gulp-connect');
12 12
13 var paths = { 13 var paths = {
14 srcJS: 'src/js/*.js', 14 srcJS: 'src/js/*.js',
15 srcViews: 'src/views/*.html', 15 srcViews: 'src/views/*.html',
16 tmp: 'tmp', 16 tmp: 'tmp',
17 dist: 'dist/' 17 dist: 'dist/'
18 }; 18 };
19 19
20 gulp.task('templates', ['clean'], function() { 20 gulp.task('templates', ['clean'], function() {
21 return pump( 21 return pump(
22 [ 22 [
23 gulp.src(paths.srcViews), 23 gulp.src(paths.srcViews),
24 htmlmin(), 24 htmlmin(),
25 templateCache('views.js', { 25 templateCache('views.js', {
26 module: 'focaListaHojaRuta', 26 module: 'focaHojaRuta',
27 root: '' 27 root: ''
28 }), 28 }),
29 gulp.dest(paths.tmp) 29 gulp.dest(paths.tmp)
30 ] 30 ]
31 ); 31 );
32 }); 32 });
33 33
34 gulp.task('uglify', ['templates'], function() { 34 gulp.task('uglify', ['templates'], function() {
35 return pump( 35 return pump(
36 [ 36 [
37 gulp.src([ 37 gulp.src([
38 paths.srcJS, 38 paths.srcJS,
39 'tmp/views.js' 39 'tmp/views.js'
40 ]), 40 ]),
41 concat('foca-hoja-ruta.js'), 41 concat('foca-hoja-ruta.js'),
42 replace('src/views/', ''), 42 replace('src/views/', ''),
43 replace("'ngRoute'", ''), 43 replace("'ngRoute'", ''),
44 gulp.dest(paths.tmp), 44 gulp.dest(paths.tmp),
45 rename('foca-hoja-ruta.min.js'), 45 rename('foca-hoja-ruta.min.js'),
46 uglify(), 46 uglify(),
47 /*replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+ 47 /*replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+
48 '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ 48 '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+
49 '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ 49 '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+
50 '"focaModalMoneda","focaModalCotizacion","focaSeguimiento","angular-ladda",'+ 50 '"focaModalMoneda","focaModalCotizacion","focaSeguimiento","angular-ladda",'+
51 '"cordovaGeolocationModule"', ''),*/ 51 '"cordovaGeolocationModule"', ''),*/
52 gulp.dest(paths.dist) 52 gulp.dest(paths.dist)
53 ] 53 ]
54 ); 54 );
55 }); 55 });
56 56
57 gulp.task('clean', function() { 57 gulp.task('clean', function() {
58 return gulp.src(['tmp', 'dist'], {read: false}) 58 return gulp.src(['tmp', 'dist'], {read: false})
59 .pipe(clean()); 59 .pipe(clean());
60 }); 60 });
61 61
62 gulp.task('pre-commit', function() { 62 gulp.task('pre-commit', function() {
63 return pump( 63 return pump(
64 [ 64 [
65 gulp.src(paths.srcJS), 65 gulp.src(paths.srcJS),
66 jshint('.jshintrc'), 66 jshint('.jshintrc'),
67 jshint.reporter('default'), 67 jshint.reporter('default'),
68 jshint.reporter('fail') 68 jshint.reporter('fail')
69 ] 69 ]
70 ); 70 );
71 71
72 gulp.start('uglify'); 72 gulp.start('uglify');
73 }); 73 });
74 74
75 gulp.task('webserver', function() { 75 gulp.task('webserver', function() {
76 pump [ 76 pump [
77 connect.server({port: 3300, host: '0.0.0.0'}) 77 connect.server({port: 3300, host: '0.0.0.0'})
78 ] 78 ]
79 }); 79 });
80 80
81 gulp.task('clean-post-install', function() { 81 gulp.task('clean-post-install', function() {
82 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', 82 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
83 'index.html'], {read: false}) 83 'index.html'], {read: false})
84 .pipe(clean()); 84 .pipe(clean());
85 }); 85 });
86 86
87 gulp.task('default', ['webserver']); 87 gulp.task('default', ['webserver']);
88 88
89 gulp.task('watch', function() { 89 gulp.task('watch', function() {
90 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); 90 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']);
91 }); 91 });
92 92
1 angular.module('focaListaHojaRuta', [ 1 angular.module('focaHojaRuta', [
2 'ngRoute' 2 'ngRoute'
3 /*'focaBusquedaProductos', 3 /*'focaBusquedaProductos',
4 'focaModalProveedor', 4 'focaModalProveedor',
5 'focaBusquedaCliente', 5 'focaBusquedaCliente',
6 'focaModalPrecioCondicion', 6 'focaModalPrecioCondicion',
7 'focaModalFlete', 7 'focaModalFlete',
8 'focaDirectivas', 8 'focaDirectivas',
9 'focaModal', 9 'focaModal',
10 'focaModalDomicilio', 10 'focaModalDomicilio',
11 'focaModalMoneda', 11 'focaModalMoneda',
12 'focaModalCotizacion', 12 'focaModalCotizacion',
13 'focaSeguimiento', 13 'focaSeguimiento',
14 'angular-ladda', 14 'angular-ladda',
15 'cordovaGeolocationModule'*/ 15 'cordovaGeolocationModule'*/
16 ]); 16 ]);
17 17
src/js/controller.js
1 angular.module('focaListaHojaRuta') 1 angular.module('focaHojaRuta')
2 .controller('listaHojaRutaCtrl', 2 .controller('listaHojaRutaCtrl',
3 [ 3 [
4 '$scope', '$filter', '$uibModal', 'hojaRutaService', 4 '$scope', '$filter', '$uibModal', 'hojaRutaService',
5 function($scope, $filter, $uibModal, hojaRutaService) { 5 function($scope, $filter, $uibModal, hojaRutaService) {
6 hojaRutaService.getHojasRuta().then(function(res) { 6 hojaRutaService.getHojasRuta().then(function(res) {
7 $scope.hojasRuta = res.data; 7 $scope.hojasRuta = res.data;
8 }); 8 });
9 $scope.cabecera = []; 9 $scope.cabecera = [];
10 $scope.showCabecera = true; 10 $scope.showCabecera = true;
11 addCabecera('Transportista:', 'Andesmar'); 11 addCabecera('Transportista:', 'Andesmar');
12 addCabecera('Chofer:', 'Carlos'); 12 addCabecera('Chofer:', 'Carlos');
13 addCabecera('Vehículo:', 'SCANIA'); 13 addCabecera('Vehículo:', 'SCANIA');
14 $scope.now = new Date(); 14 $scope.now = new Date();
15 $scope.puntoVenta = '0000'; 15 $scope.puntoVenta = '0000';
16 $scope.comprobante = '00000000'; 16 $scope.comprobante = '00000000';
17 17
18 $scope.verDetalle = function(hojaRuta) { 18 $scope.verDetalle = function(hojaRuta) {
19 var modalInstance = $uibModal.open( 19 var modalInstance = $uibModal.open(
20 { 20 {
21 ariaLabelledBy: 'Detalle hoja ruta', 21 ariaLabelledBy: 'Detalle hoja ruta',
22 templateUrl: 'modal-detalle-hoja-ruta.html', 22 templateUrl: 'modal-detalle-hoja-ruta.html',
23 controller: 'focaModalDetalleHojaRutaController', 23 controller: 'focaModalDetalleHojaRutaController',
24 resolve: { 24 resolve: {
25 parametrosDetalleHojaRuta: function(){ 25 parametrosDetalleHojaRuta: function(){
26 return { 26 return {
27 remito: '00001-00000001', 27 remito: '00001-00000001',
28 cliente: 'Rubén Gomez', 28 cliente: 'Rubén Gomez',
29 domicilio: 'Patricias Mendocinas 5050', 29 domicilio: 'Patricias Mendocinas 5050',
30 producto: 'Super', 30 producto: 'Super',
31 litros: 20 31 litros: 20
32 }; 32 };
33 } 33 }
34 }, 34 },
35 size: 'lg' 35 size: 'lg'
36 } 36 }
37 ); 37 );
38 modalInstance.result.then(function() { 38 modalInstance.result.then(function() {
39 39
40 }) 40 })
41 }; 41 };
42 42
43 function addCabecera(label, valor) { 43 function addCabecera(label, valor) {
44 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 44 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
45 if(propiedad.length === 1) { 45 if(propiedad.length === 1) {
46 propiedad[0].valor = valor; 46 propiedad[0].valor = valor;
47 } else { 47 } else {
48 $scope.cabecera.push({label: label, valor: valor}); 48 $scope.cabecera.push({label: label, valor: valor});
49 } 49 }
50 } 50 }
51 51
52 function removeCabecera(label) { 52 function removeCabecera(label) {
53 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 53 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
54 if(propiedad.length === 1) { 54 if(propiedad.length === 1) {
55 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 55 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
56 } 56 }
57 } 57 }
58 58
59 function rellenar(relleno, longitud) { 59 function rellenar(relleno, longitud) {
60 relleno = '' + relleno; 60 relleno = '' + relleno;
61 while (relleno.length < longitud) { 61 while (relleno.length < longitud) {
62 relleno = '0' + relleno; 62 relleno = '0' + relleno;
63 } 63 }
64 64
65 return relleno; 65 return relleno;
66 } 66 }
67 } 67 }
68 ]); 68 ]);
69 69
70 70
1 angular.module('focaListaHojaRuta') 1 angular.module('focaHojaRuta')
2 .config(['$routeProvider', function($routeProvider) { 2 .config(['$routeProvider', function($routeProvider) {
3 $routeProvider.when('/venta-hoja-ruta/lista', { 3 $routeProvider.when('/venta-hoja-ruta/lista', {
4 controller: 'listaHojaRutaCtrl', 4 controller: 'listaHojaRutaCtrl',
5 templateUrl: 'src/views/lista-hoja-ruta.html' 5 templateUrl: 'src/views/lista-hoja-ruta.html'
6 }); 6 });
7 }]); 7 }]);
8 8
1 angular.module('focaListaHojaRuta') 1 angular.module('focaHojaRuta')
2 .service('hojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { 2 .service('hojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 var route = API_ENDPOINT.URL; 3 var route = API_ENDPOINT.URL;
4 return { 4 return {
5 getHojasRuta: function() { 5 getHojasRuta: function() {
6 return $http.get(route + '/hoja-ruta'); 6 return $http.get(route + '/hoja-ruta');
7 } 7 }
8 }; 8 };
9 }]); 9 }]);
10 10