Commit 61c9443742af87e2d091bb9a3c957257b415c649

Authored by Eric Fernandez
Exists in master

Merge branch 'master' of https://debo.suite.repo/modulos-npm/foca-hoja-ruta

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 { 1 {
2 "name": "foca-hoja-ruta", 2 "name": "foca-hoja-ruta",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "foca-hoja-ruta", 4 "description": "foca-hoja-ruta",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {
7 "test": "echo \"Error: no test specified\" && exit 1" 7 "test": "echo \"Error: no test specified\" && exit 1",
8 }, 8 "compile": "gulp uglify",
9 "repository": { 9 "gulp-pre-commit": "gulp pre-commit",
10 "type": "git", 10 "postinstall": "npm run compile && gulp clean-post-install",
11 "url": "https://debo.suite.repo/modulos-npm/foca-hoja-ruta.git" 11 "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-remito.git"
12 }, 12 },
13 "author": "Foca Software", 13 "pre-commit": [
14 "license": "ISC", 14 "gulp-pre-commit"
15 "devDependencies": { 15 ],
16 "angular": "^1.7.5", 16 "repository": {
17 "angular-ladda": "^0.4.3", 17 "type": "git",
18 "angular-route": "^1.7.5", 18 "url": "https://debo.suite.repo/modulos-npm/foca-hoja-ruta.git"
19 "bootstrap": "^4.1.3", 19 },
20 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", 20 "author": "Foca Software",
21 "foca-modal-remito": "git+https://debo.suite.repo/modulos-npm/foca-modal-remito.git", 21 "license": "ISC",
22 "font-awesome": "^4.7.0", 22 "devDependencies": {
23 "gulp": "^3.9.1", 23 "angular": "^1.7.5",
24 "gulp-angular-templatecache": "^2.2.5", 24 "angular-ladda": "^0.4.3",
25 "gulp-clean": "^0.4.0", 25 "angular-route": "^1.7.5",
26 "gulp-concat": "^2.6.1", 26 "bootstrap": "^4.1.3",
27 "gulp-connect": "^5.6.1", 27 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git",
28 "gulp-htmlmin": "^5.0.1", 28 "foca-modal-remito": "git+https://debo.suite.repo/modulos-npm/foca-modal-remito.git",
29 "gulp-jshint": "^2.1.0", 29 "font-awesome": "^4.7.0",
30 "gulp-rename": "^1.4.0", 30 "gulp": "^3.9.1",
31 "gulp-replace": "^1.0.0", 31 "gulp-angular-templatecache": "2.2.5",
32 "gulp-sequence": "^1.0.0", 32 "gulp-clean": "^0.4.0",
33 "gulp-uglify": "^3.0.1", 33 "gulp-concat": "^2.6.1",
34 "jasmine-core": "^3.3.0", 34 "gulp-connect": "^5.6.1",
35 "jquery": "^3.3.1", 35 "gulp-htmlmin": "5.0.1",
36 "jshint": "^2.9.6", 36 "gulp-jshint": "2.1.0",
37 "ladda": "1.0.6", 37 "gulp-rename": "1.4.0",
38 "pre-commit": "^1.2.2", 38 "gulp-replace": "1.0.0",
39 "pump": "^3.0.0", 39 "gulp-sequence": "^1.0.0",
40 "ui-bootstrap4": "^3.0.5" 40 "gulp-uglify": "3.0.1",
41 } 41 "jasmine-core": "^3.3.0",
42 "jquery": "^3.3.1",
43 "jshint": "2.9.6",
44 "ladda": "1.0.6",
45 "pre-commit": "^1.2.2",
46 "pump": "3.0.0",
47 "ui-bootstrap4": "^3.0.5"
48 }
42 } 49 }
43 50
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 $scope.puntoVenta = rellenar(res.data[0].sucursal, 4); 8 $scope.puntoVenta = rellenar(res.data[0].sucursal, 4);
9 $scope.comprobante = rellenar(res.data[0].numeroHojaRuta, 8); 9 $scope.comprobante = rellenar(res.data[0].numeroHojaRuta, 8);
10 }); 10 });
11 $scope.cabecera = []; 11 $scope.cabecera = [];
12 $scope.showCabecera = true; 12 $scope.showCabecera = true;
13 addCabecera('Transportista:', 'Andesmar'); 13 addCabecera('Transportista:', 'Andesmar');
14 addCabecera('Chofer:', 'Carlos'); 14 addCabecera('Chofer:', 'Carlos');
15 addCabecera('Vehículo:', 'SCANIA'); 15 addCabecera('Vehículo:', 'SCANIA');
16 $scope.now = new Date(); 16 $scope.now = new Date();
17 $scope.puntoVenta = '0000'; 17 $scope.puntoVenta = '0000';
18 $scope.comprobante = '00000000'; 18 $scope.comprobante = '00000000';
19 $scope.verDetalle = function(hojaRuta) { 19 $scope.verDetalle = function(hojaRuta) {
20 var modalInstance = $uibModal.open( 20 var modalInstance = $uibModal.open(
21 { 21 {
22 ariaLabelledBy: 'Detalle hoja ruta', 22 ariaLabelledBy: 'Detalle hoja ruta',
23 templateUrl: 'modal-detalle-hoja-ruta.html', 23 templateUrl: 'modal-detalle-hoja-ruta.html',
24 controller: 'focaModalDetalleHojaRutaController', 24 controller: 'focaModalDetalleHojaRutaController',
25 resolve: { 25 resolve: {
26 parametrosDetalleHojaRuta: function(){ 26 parametrosDetalleHojaRuta: function(){
27 return { 27 return {
28 remito: '00001-00000001', 28 remito: '00001-00000001',
29 cliente: 'Rubén Gomez', 29 cliente: 'Rubén Gomez',
30 domicilio: 'Patricias Mendocinas 5050', 30 domicilio: 'Patricias Mendocinas 5050',
31 producto: 'Super', 31 producto: 'Super',
32 litros: 20 32 litros: 20
33 }; 33 };
34 } 34 }
35 }, 35 },
36 size: 'lg' 36 size: 'lg'
37 } 37 }
38 ); 38 );
39 modalInstance.result.then(function() { 39 modalInstance.result.then(function() {
40 40
41 }) 41 })
42 }; 42 };
43 43
44 function addCabecera(label, valor) { 44 function addCabecera(label, valor) {
45 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 45 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
46 if(propiedad.length === 1) { 46 if(propiedad.length === 1) {
47 propiedad[0].valor = valor; 47 propiedad[0].valor = valor;
48 } else { 48 } else {
49 $scope.cabecera.push({label: label, valor: valor}); 49 $scope.cabecera.push({label: label, valor: valor});
50 } 50 }
51 } 51 }
52 52
53 function removeCabecera(label) { 53 function removeCabecera(label) {
54 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 54 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
55 if(propiedad.length === 1) { 55 if(propiedad.length === 1) {
56 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 56 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
57 } 57 }
58 } 58 }
59 59
60 function rellenar(relleno, longitud) { 60 function rellenar(relleno, longitud) {
61 relleno = '' + relleno; 61 relleno = '' + relleno;
62 while (relleno.length < longitud) { 62 while (relleno.length < longitud) {
63 relleno = '0' + relleno; 63 relleno = '0' + relleno;
64 } 64 }
65 65
66 return relleno; 66 return relleno;
67 } 67 }
68 } 68 }
69 ]); 69 ]);
70 70
71 71
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