Commit af4cb4c17a6e5de9d5faed94659ffd93f3c32897

Authored by Jose Pinto
Exists in master

Merge remote-tracking branch 'upstream/master'

1 const templateCache = require('gulp-angular-templatecache'); 1 const templateCache = require('gulp-angular-templatecache');
2 const concat = require('gulp-concat'); 2 const concat = require('gulp-concat');
3 const htmlmin = require('gulp-htmlmin'); 3 const htmlmin = require('gulp-htmlmin');
4 const rename = require('gulp-rename'); 4 const rename = require('gulp-rename');
5 const uglify = require('gulp-uglify-es').default; 5 const uglify = require('gulp-uglify-es').default;
6 const gulp = require('gulp'); 6 const gulp = require('gulp');
7 const pump = require('pump'); 7 const pump = require('pump');
8 const jshint = require('gulp-jshint'); 8 const jshint = require('gulp-jshint');
9 const replace = require('gulp-replace'); 9 const replace = require('gulp-replace');
10 const connect = require('gulp-connect'); 10 const connect = require('gulp-connect');
11 const clean = require('gulp-clean'); 11 const clean = require('gulp-clean');
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', function() { 20 gulp.task('templates', function() {
21 return pump( 21 return pump(
22 [ 22 [
23 gulp.src(paths.srcViews), 23 gulp.src(paths.srcViews),
24 replace('views/', ''), 24 replace('views/', ''),
25 htmlmin(), 25 htmlmin(),
26 templateCache('views.js', { 26 templateCache('views.js', {
27 module: 'focaEstadoCisternas', 27 module: 'focaEstadoCisternas',
28 root: '' 28 root: ''
29 }), 29 }),
30 gulp.dest(paths.tmp) 30 gulp.dest(paths.tmp)
31 ] 31 ]
32 ); 32 );
33 }); 33 });
34 34
35 gulp.task('uglify', ['templates'], function() { 35 gulp.task('uglify', ['templates'], function() {
36 return pump( 36 return pump(
37 [ 37 [
38 gulp.src([ 38 gulp.src([
39 paths.srcJS, 39 paths.srcJS,
40 'tmp/views.js' 40 'tmp/views.js'
41 ]), 41 ]),
42 concat('foca-estado-cisternas.js'), 42 concat('foca-estado-cisternas.js'),
43 replace("['ngRoute', 'focaModal', 'ui.bootstrap', 'focaBotoneraLateral']", '[]'),
44 replace("src/views/", ''), 43 replace("src/views/", ''),
45 gulp.dest(paths.tmp), 44 gulp.dest(paths.tmp),
46 rename('foca-estado-cisternas.min.js'), 45 rename('foca-estado-cisternas.min.js'),
47 uglify(), 46 uglify(),
48 gulp.dest(paths.dist) 47 gulp.dest(paths.dist)
49 ] 48 ]
50 ); 49 );
51 }); 50 });
52 51
53 gulp.task('clean', function() { 52 gulp.task('clean', function() {
54 return gulp.src(['tmp', 'dist'], {read: false}) 53 return gulp.src(['tmp', 'dist'], {read: false})
55 .pipe(clean()); 54 .pipe(clean());
56 }); 55 });
57 56
58 gulp.task('pre-commit', function() { 57 gulp.task('pre-commit', function() {
59 pump( 58 pump(
60 [ 59 [
61 gulp.src(paths.srcJS), 60 gulp.src(paths.srcJS),
62 jshint('.jshintrc'), 61 jshint('.jshintrc'),
63 jshint.reporter('default'), 62 jshint.reporter('default'),
64 jshint.reporter('fail') 63 jshint.reporter('fail')
65 ] 64 ]
66 ); 65 );
67 66
68 gulp.start('uglify'); 67 gulp.start('uglify');
69 }); 68 });
70 69
71 gulp.task('clean-post-install', function() { 70 gulp.task('clean-post-install', function() {
72 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', 71 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
73 'index.html'], {read: false}) 72 'index.html'], {read: false})
74 .pipe(clean()); 73 .pipe(clean());
75 }); 74 });
76 75
77 gulp.task('compile', ['templates', 'uglify']); 76 gulp.task('compile', ['templates', 'uglify']);
78 77
79 gulp.task('watch', function() { 78 gulp.task('watch', function() {
80 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); 79 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']);
81 }); 80 });
82 81
83 gulp.task('webserver', function() { 82 gulp.task('webserver', function() {
84 pump [ 83 pump [
85 connect.server({port: 3000}) 84 connect.server({port: 3000})
86 ] 85 ]
87 }); 86 });
88 87
89 gulp.task('default', ['webserver']); 88 gulp.task('default', ['webserver']);
90 89
1 angular.module('focaEstadoCisternas', [ 1 angular.module('focaEstadoCisternas', []);
2 'ngRoute',
3 'focaModal',
4 'ui.bootstrap',
5 'focaBotoneraLateral'
6 ]);
7 2
src/js/controller.js
1 angular.module('focaEstadoCisternas') 1 angular.module('focaEstadoCisternas')
2 .controller('focaEstadoCisternasController', [ 2 .controller('focaEstadoCisternasController', [
3 '$scope', 'focaEstadoCisternasService', 'focaModalService', 3 '$scope', 'focaEstadoCisternasService', 'focaModalService',
4 '$uibModal', 'focaBotoneraLateralService', '$timeout', 4 '$uibModal', 'focaBotoneraLateralService', '$timeout',
5 function($scope, focaEstadoCisternasService, focaModalService, 5 function($scope, focaEstadoCisternasService, focaModalService,
6 $uibModal, focaBotoneraLateralService, $timeout) { 6 $uibModal, focaBotoneraLateralService, $timeout) {
7 7
8 $scope.now = new Date(); 8 $scope.now = new Date();
9 $scope.fecha = new Date(); 9 $scope.fecha = new Date();
10 $scope.cisternas = []; 10 $scope.cisternas = [];
11 $scope.botonera = focaEstadoCisternasService.getBotonera(); 11 $scope.botonera = focaEstadoCisternasService.getBotonera();
12 12
13 //SETEO BOTONERA LATERAL 13 //SETEO BOTONERA LATERAL
14 focaBotoneraLateralService.showSalir(true); 14 focaBotoneraLateralService.showSalir(true);
15 focaBotoneraLateralService.showPausar(false); 15 focaBotoneraLateralService.showPausar(false);
16 focaBotoneraLateralService.showCancelar(false); 16 focaBotoneraLateralService.showCancelar(false);
17 focaBotoneraLateralService.showGuardar(false); 17 focaBotoneraLateralService.showGuardar(false);
18 18
19 $timeout(function() { 19 $timeout(function() {
20 $scope.$broadcast('addCabecera', { 20 $scope.$broadcast('addCabecera', {
21 label: 'Fecha:', 21 label: 'Fecha:',
22 valor: $scope.fecha.toLocaleDateString() 22 valor: $scope.fecha.toLocaleDateString()
23 }); 23 });
24 }); 24 });
25 25
26 $scope.seleccionarTransportista = function() { 26 $scope.seleccionarTransportista = function() {
27 var modalInstance = $uibModal.open( 27 var parametrosModal = {
28 { 28 titulo: 'Búsqueda de Transportista',
29 ariaLabelledBy: 'Busqueda de Transportista', 29 query: '/transportista',
30 templateUrl: 'modal-proveedor.html', 30 columnas: [
31 controller: 'focaModalProveedorCtrl', 31 {
32 size: 'lg', 32 nombre: 'Código',
33 resolve: { 33 propiedad: 'COD'
34 transportista: function() { 34 },
35 return true; 35 {
36 } 36 nombre: 'Nombre',
37 propiedad: 'NOM'
38 },
39 {
40 nombre: 'CUIT',
41 propiedad: 'CUIT'
37 } 42 }
38 } 43 ]
39 ); 44 };
40 return modalInstance.result; 45 return focaModalService.modal(parametrosModal);
41 }; 46 };
42 47
43 $scope.seleccionarVehiculo = function() { 48 $scope.seleccionarVehiculo = function() {
44 $scope.seleccionarTransportista().then( 49 $scope.seleccionarTransportista().then(
45 function(transportista) { 50 function(transportista) {
46 elegirTransportista(transportista); 51 elegirTransportista(transportista);
47 52
48 var query = '/vehiculo/transportista/' + $scope.idTransportista; 53 var parametrosModal = {
49 var columnas = { 54 columnas: [
50 nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], 55 {
51 propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] 56 propiedad: 'codigo',
57 nombre: 'Código'
58 },
59 {
60 propiedad: 'tractor',
61 nombre: 'tractor'
62 },
63 {
64 propiedad: 'semi',
65 nombre: 'Semi'
66 },
67 {
68 propiedad: 'capacidadTotalCisternas',
69 nombre: 'Capacidad'
70 }
71 ],
72 query: '/vehiculo/transportista/' + transportista.COD,
73 titulo: 'Búsqueda de vehiculos',
74 subTitulo: transportista.COD + '-' + transportista.NOM
52 }; 75 };
53 var titulo = 'Búsqueda de vehículos';
54 76
55 focaModalService.modal(columnas, query, titulo).then( 77 focaModalService.modal(parametrosModal).then(
56 function(vehiculo) { 78 function(vehiculo) {
57 $scope.$broadcast('addCabecera', { 79 $scope.$broadcast('addCabecera', {
58 label: 'Vehículo:', 80 label: 'Vehículo:',
59 valor: vehiculo.codigo 81 valor: vehiculo.codigo
60 }); 82 });
61 $scope.cisternas = vehiculo.cisternas; 83 $scope.cisternas = vehiculo.cisternas;
62 getEstadosCisternas($scope.cisternas); 84 getEstadosCisternas($scope.cisternas);
63 }, function() { 85 }, function() {
64 $scope.seleccionarVehiculo(); 86 $scope.seleccionarVehiculo();
65 }); 87 });
66 }); 88 });
67 }; 89 };
68 90
69 $scope.seleccionarFechaEntrega = function() { 91 $scope.seleccionarFechaEntrega = function() {
70 focaModalService.modalFecha('Fecha').then(function(fecha) { 92 focaModalService.modalFecha('Fecha').then(function(fecha) {
71 $scope.$broadcast('addCabecera', { 93 $scope.$broadcast('addCabecera', {
72 label: 'Fecha:', 94 label: 'Fecha:',
73 valor: fecha.toLocaleDateString() 95 valor: fecha.toLocaleDateString()
74 }); 96 });
75 $scope.fecha = fecha; 97 $scope.fecha = fecha;
76 if($scope.cisternas) 98 if($scope.cisternas)
77 getEstadosCisternas($scope.cisternas); 99 getEstadosCisternas($scope.cisternas);
78 }); 100 });
79 }; 101 };
80 102
81 $scope.seleccionarGrafico = function() { 103 $scope.seleccionarGrafico = function() {
82 if(!$scope.cisternas.length){ 104 if(!$scope.cisternas.length){
83 focaModalService.alert('Primero seleccione un vehículo con cisternas'); 105 focaModalService.alert('Primero seleccione un vehículo con cisternas');
84 return; 106 return;
85 } 107 }
86 $uibModal.open( 108 $uibModal.open(
87 { 109 {
88 ariaLabelledBy: 'Grafico de cisternas', 110 ariaLabelledBy: 'Grafico de cisternas',
89 templateUrl: 'modal-grafico-cisternas.html', 111 templateUrl: 'modal-grafico-cisternas.html',
90 controller: 'focaModalGraficoCisternasController', 112 controller: 'focaModalGraficoCisternasController',
91 size: 'md', 113 size: 'md',
92 resolve:{ 114 resolve:{
93 filters: { 115 filters: {
94 cisternas: $scope.cisternas 116 cisternas: $scope.cisternas
95 } 117 }
96 } 118 }
97 } 119 }
98 ); 120 );
99 }; 121 };
100 122
101 function elegirTransportista(transportista) { 123 function elegirTransportista(transportista) {
102 var codigo = ('00000' + transportista.COD).slice(-5); 124 var codigo = ('00000' + transportista.COD).slice(-5);
103 $scope.idTransportista = transportista.COD; 125 $scope.idTransportista = transportista.COD;
104 $scope.filtros = transportista.NOM.trim(); 126 $scope.filtros = transportista.NOM.trim();
105 $scope.$broadcast('addCabecera', { 127 $scope.$broadcast('addCabecera', {
106 label: 'Transportista:', 128 label: 'Transportista:',
107 valor: codigo + ' - ' + transportista.NOM 129 valor: codigo + ' - ' + transportista.NOM
108 }); 130 });
109 } 131 }
110 132
111 function getEstadosCisternas(cisternas) { 133 function getEstadosCisternas(cisternas) {
112 cisternas.forEach(function(cisterna) { 134 cisternas.forEach(function(cisterna) {
113 focaEstadoCisternasService 135 focaEstadoCisternasService
114 .getEstadoCisterna(cisterna.id, $scope.fecha) 136 .getEstadoCisterna(cisterna.id, $scope.fecha)
115 .then(function(res) { 137 .then(function(res) {
116 cisterna.estado = res.data; 138 cisterna.estado = res.data;
117 }); 139 });
118 }); 140 });
119 } 141 }
120 } 142 }
121 ]); 143 ]);