Commit 059223077a11ffd4c893cf4c33fc18403e7e8256

Authored by Eric Fernandez
1 parent 13e5962cda
Exists in master

quito modal proveedor

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: 'focaAbmChofer', 27 module: 'focaAbmChofer',
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-abm-chofer.js'), 42 concat('foca-abm-chofer.js'),
43 replace("['ngRoute', 'focaModal', 'ui.bootstrap']", '[]'),
44 replace("src/views/", ''), 43 replace("src/views/", ''),
45 gulp.dest(paths.tmp), 44 gulp.dest(paths.tmp),
46 rename('foca-abm-chofer.min.js'), 45 rename('foca-abm-chofer.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 { 1 {
2 "name": "foca-abm-chofer", 2 "name": "foca-abm-chofer",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "Abm de chofer", 4 "description": "Abm de chofer",
5 "main": "index.html", 5 "main": "index.html",
6 "scripts": { 6 "scripts": {
7 "test": "echo \"Error: no test specified\" && exit 1", 7 "test": "echo \"Error: no test specified\" && exit 1",
8 "compile": "gulp uglify", 8 "compile": "gulp uglify",
9 "gulp-pre-commit": "gulp pre-commit", 9 "gulp-pre-commit": "gulp pre-commit",
10 "postinstall": "npm run compile && gulp clean-post-install", 10 "postinstall": "npm run compile && gulp clean-post-install",
11 "install-dev": "npm install -D angular bootstrap ui-bootstrap4 font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-uglify gulp-clean jshint pump git+http://git.focasoftware.com/npm/foca-modal.git" 11 "install-dev": "npm install -D angular bootstrap ui-bootstrap4 font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-uglify gulp-clean jshint pump git+http://git.focasoftware.com/npm/foca-modal.git"
12 }, 12 },
13 "pre-commit": [ 13 "pre-commit": [
14 "gulp-pre-commit" 14 "gulp-pre-commit"
15 ], 15 ],
16 "repository": { 16 "repository": {
17 "type": "git", 17 "type": "git",
18 "url": "http://git.focasoftware.com/npm/foca-abm-chofer.git" 18 "url": "http://git.focasoftware.com/npm/foca-abm-chofer.git"
19 }, 19 },
20 "author": "Foca Software", 20 "author": "Foca Software",
21 "license": "ISC", 21 "license": "ISC",
22 "peerDependencies": { 22 "peerDependencies": {
23 "angular": "^1.7.x", 23 "angular": "^1.7.x",
24 "angular-route": "^1.7.x", 24 "angular-route": "^1.7.x",
25 "bootstrap": "^4.1.x", 25 "bootstrap": "^4.1.x",
26 "jquery": "^3.3.x", 26 "jquery": "^3.3.x",
27 "font-awesome": "^4.7.x", 27 "font-awesome": "^4.7.x",
28 "gulp": "^3.9.x", 28 "gulp": "^3.9.x",
29 "gulp-concat": "2.6.x", 29 "gulp-concat": "2.6.x",
30 "gulp-jshint": "^2.1.x", 30 "gulp-jshint": "^2.1.x",
31 "gulp-rename": "^1.4.x", 31 "gulp-rename": "^1.4.x",
32 "gulp-replace": "^1.0.x", 32 "gulp-replace": "^1.0.x",
33 "gulp-uglify-es": "^1.0.x", 33 "gulp-uglify-es": "^1.0.x",
34 "jshint": "^2.9.x", 34 "jshint": "^2.9.x",
35 "pump": "^3.0.x" 35 "pump": "^3.0.x"
36 }, 36 },
37 "devDependencies": { 37 "devDependencies": {
38 "angular": "^1.7.5", 38 "angular": "^1.7.7",
39 "angular-route": "^1.7.5", 39 "angular-route": "^1.7.5",
40 "bootstrap": "^4.1.3", 40 "bootstrap": "^4.2.1",
41 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", 41 "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git",
42 "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", 42 "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git",
43 "font-awesome": "^4.7.0", 43 "font-awesome": "^4.7.0",
44 "gulp": "^3.9.1", 44 "gulp": "^3.9.1",
45 "gulp-angular-templatecache": "^2.2.5", 45 "gulp-angular-templatecache": "^2.2.6",
46 "gulp-clean": "^0.4.0", 46 "gulp-clean": "^0.4.0",
47 "gulp-connect": "^5.6.1", 47 "gulp-connect": "^5.7.0",
48 "gulp-htmlmin": "^5.0.1", 48 "gulp-htmlmin": "^5.0.1",
49 "gulp-jshint": "^2.1.0", 49 "gulp-jshint": "^2.1.0",
50 "gulp-rename": "^1.4.0", 50 "gulp-rename": "^1.4.0",
51 "gulp-replace": "^1.0.0", 51 "gulp-replace": "^1.0.0",
52 "gulp-uglify": "^3.0.1", 52 "gulp-uglify": "^3.0.1",
53 "gulp-uglify-es": "^1.0.4", 53 "gulp-uglify-es": "^1.0.4",
54 "jasmine-core": "^3.3.0", 54 "jasmine-core": "^3.3.0",
55 "jquery": "^3.3.1", 55 "jquery": "^3.3.1",
56 "jshint": "^2.9.6", 56 "jshint": "^2.10.0",
57 "pre-commit": "^1.2.2", 57 "pre-commit": "^1.2.2",
58 "pump": "^3.0.0", 58 "pump": "^3.0.0",
59 "ui-bootstrap4": "^3.0.5" 59 "ui-bootstrap4": "^3.0.6"
60 } 60 }
61 } 61 }
62 62
1 angular.module('focaAbmChofer', [ 1 angular.module('focaAbmChofer', []);
2 'ngRoute',
3 'focaModal',
4 'ui.bootstrap',
5 'focaBotoneraLateral'
6 ]);
7 2
src/js/controller.js
1 angular.module('focaAbmChofer') 1 angular.module('focaAbmChofer')
2 .controller('focaAbmChoferesController', [ 2 .controller('focaAbmChoferesController', [
3 '$scope', 'focaAbmChoferService', '$location', '$uibModal', 3 '$scope', 'focaAbmChoferService', '$location', '$uibModal',
4 'focaModalService', 'focaBotoneraLateralService', '$timeout', 4 'focaModalService', 'focaBotoneraLateralService', '$timeout',
5 function($scope, focaAbmChoferService, $location, $uibModal, focaModalService, 5 function($scope, focaAbmChoferService, $location, $uibModal, focaModalService,
6 focaBotoneraLateralService, $timeout) { 6 focaBotoneraLateralService, $timeout) {
7 7
8 $scope.now = new Date(); 8 $scope.now = new Date();
9 $scope.filters = ''; 9 $scope.filters = '';
10 $scope.choferes = []; 10 $scope.choferes = [];
11 $scope.botonera = [{ 11 $scope.botonera = [{
12 label: 'Transportista', 12 label: 'Transportista',
13 image: 'cliente.png' 13 image: 'cliente.png'
14 }]; 14 }];
15 15
16 //SETEO BOTONERA LATERAL 16 //SETEO BOTONERA LATERAL
17 $timeout(function() { 17 $timeout(function() {
18 focaBotoneraLateralService.showSalir(false); 18 focaBotoneraLateralService.showSalir(false);
19 focaBotoneraLateralService.showPausar(false); 19 focaBotoneraLateralService.showPausar(false);
20 focaBotoneraLateralService.showCancelar(false); 20 focaBotoneraLateralService.showCancelar(false);
21 focaBotoneraLateralService.showGuardar(false); 21 focaBotoneraLateralService.showGuardar(false);
22 focaBotoneraLateralService.addCustomButton('Salir', salir); 22 focaBotoneraLateralService.addCustomButton('Salir', salir);
23 }); 23 });
24 24
25 if(focaAbmChoferService.transportistaSeleccionado.COD) { 25 if(focaAbmChoferService.transportistaSeleccionado.COD) {
26 elegirTransportista(focaAbmChoferService.transportistaSeleccionado); 26 elegirTransportista(focaAbmChoferService.transportistaSeleccionado);
27 } 27 }
28 28
29 $scope.editar = function(id) { 29 $scope.editar = function(id) {
30 $location.path('/chofer/' + id + '/' + $scope.idTransportista); 30 $location.path('/chofer/' + id + '/' + $scope.idTransportista);
31 }; 31 };
32 32
33 $scope.solicitarConfirmacion = function(chofer) { 33 $scope.solicitarConfirmacion = function(chofer) {
34 focaModalService.confirm('¿Está seguro que desea borrar el chofer ' + 34 focaModalService.confirm('¿Está seguro que desea borrar el chofer ' +
35 chofer.nombre + ' ?').then(function(confirmed) { 35 chofer.nombre + ' ?').then(function(confirmed) {
36 if(confirmed) { 36 if(confirmed) {
37 focaAbmChoferService.deleteChofer(chofer.id); 37 focaAbmChoferService.deleteChofer(chofer.id);
38 $scope.choferes.splice($scope.choferes.indexOf(chofer), 1); 38 $scope.choferes.splice($scope.choferes.indexOf(chofer), 1);
39 } 39 }
40 }); 40 });
41 }; 41 };
42 42
43 $scope.seleccionarTransportista = function() { 43 $scope.seleccionarTransportista = function() {
44 var modalInstance = $uibModal.open( 44 var parametrosModal = {
45 { 45 titulo: 'Búsqueda de transportista',
46 ariaLabelledBy: 'Busqueda de Transportista', 46 query: '/transportista',
47 templateUrl: 'modal-proveedor.html', 47 columnas: [
48 controller: 'focaModalProveedorCtrl', 48 {
49 size: 'lg', 49 nombre: 'Código',
50 resolve: { 50 propiedad: 'COD'
51 transportista: function() { 51 },
52 return true; 52 {
53 } 53 nombre: 'Nombre',
54 propiedad: 'NOM'
55 },
56 {
57 nombre: 'CUIT',
58 propiedad: 'CUIT'
54 } 59 }
55 } 60 ]
56 ); 61 }
57 modalInstance.result.then( 62 focaModalService.modal(parametrosModal).then(
58 function(transportista) { 63 function(transportista) {
59 elegirTransportista(transportista); 64 elegirTransportista(transportista);
60 focaAbmChoferService.transportistaSeleccionado = transportista; 65 focaAbmChoferService.transportistaSeleccionado = transportista;
61 }, function() {} 66 }, function() {}
62 ); 67 );
63 }; 68 };
64 69
65 function elegirTransportista(transportista) { 70 function elegirTransportista(transportista) {
66 buscar(transportista.COD); 71 buscar(transportista.COD);
67 var codigo = ('00000' + transportista.COD).slice(-5); 72 var codigo = ('00000' + transportista.COD).slice(-5);
68 $scope.idTransportista = transportista.COD; 73 $scope.idTransportista = transportista.COD;
69 $timeout(function() { 74 $timeout(function() {
70 $scope.$broadcast('addCabecera', { 75 $scope.$broadcast('addCabecera', {
71 label: 'Transportista:', 76 label: 'Transportista:',
72 valor: codigo + ' - ' + transportista.NOM 77 valor: codigo + ' - ' + transportista.NOM
73 }); 78 });
74 }); 79 });
75 } 80 }
76 81
77 function buscar(id) { 82 function buscar(id) {
78 focaAbmChoferService.getChoferPorTransportista(id).then(function(res) { 83 focaAbmChoferService.getChoferPorTransportista(id).then(function(res) {
79 $scope.choferes = res.data; 84 $scope.choferes = res.data;
80 }); 85 });
81 } 86 }
82 87
83 function salir() { 88 function salir() {
84 focaAbmChoferService.transportistaSeleccionado = {}; 89 focaAbmChoferService.transportistaSeleccionado = {};
85 $location.path('/'); 90 $location.path('/');
86 } 91 }
87 } 92 }
88 ]) 93 ])
89 .controller('focaAbmChoferController', [ 94 .controller('focaAbmChoferController', [
90 '$scope', 'focaAbmChoferService', '$routeParams', 95 '$scope', 'focaAbmChoferService', '$routeParams',
91 '$location', 'focaBotoneraLateralService', '$timeout', 'focaModalService', 96 '$location', 'focaBotoneraLateralService', '$timeout', 'focaModalService',
92 function($scope, focaAbmChoferService, $routeParams, 97 function($scope, focaAbmChoferService, $routeParams,
93 $location, focaBotoneraLateralService, $timeout, focaModalService) { 98 $location, focaBotoneraLateralService, $timeout, focaModalService) {
94 99
95 $scope.focused = 1; 100 $scope.focused = 1;
96 $scope.nuevo = $routeParams.id === '0'; 101 $scope.nuevo = $routeParams.id === '0';
97 $scope.chofer = {}; 102 $scope.chofer = {};
98 $scope.transportistas = []; 103 $scope.transportistas = [];
99 $scope.now = new Date(); 104 $scope.now = new Date();
100 $scope.next = function(key) { 105 $scope.next = function(key) {
101 if (key === 13) $scope.focused++; 106 if (key === 13) $scope.focused++;
102 }; 107 };
103 108
104 focaAbmChoferService.getTiposDocumento().then(function(res) { 109 focaAbmChoferService.getTiposDocumento().then(function(res) {
105 $scope.tiposDocumento = res.data; 110 $scope.tiposDocumento = res.data;
106 }); 111 });
107 112
108 //SETEO BOTONERA LATERAL 113 //SETEO BOTONERA LATERAL
109 $timeout(function() { 114 $timeout(function() {
110 focaBotoneraLateralService.showSalir(false); 115 focaBotoneraLateralService.showSalir(false);
111 focaBotoneraLateralService.showPausar(true); 116 focaBotoneraLateralService.showPausar(true);
112 focaBotoneraLateralService.showCancelar(true); 117 focaBotoneraLateralService.showCancelar(true);
113 focaBotoneraLateralService.showGuardar(true, $scope.guardar); 118 focaBotoneraLateralService.showGuardar(true, $scope.guardar);
114 }); 119 });
115 120
116 if($scope.nuevo) { 121 if($scope.nuevo) {
117 focaAbmChoferService 122 focaAbmChoferService
118 .getTransportistaPorId($routeParams.idTransportista) 123 .getTransportistaPorId($routeParams.idTransportista)
119 .then(function(res) { 124 .then(function(res) {
120 var codigo = ('00000' + res.data.COD).slice(-5); 125 var codigo = ('00000' + res.data.COD).slice(-5);
121 $scope.chofer.idTransportista = res.data.COD; 126 $scope.chofer.idTransportista = res.data.COD;
122 $scope.chofer.transportista = res.data; 127 $scope.chofer.transportista = res.data;
123 $scope.$broadcast('addCabecera', { 128 $scope.$broadcast('addCabecera', {
124 label: 'Transportista:', 129 label: 'Transportista:',
125 valor: codigo + ' - ' + res.data.NOM 130 valor: codigo + ' - ' + res.data.NOM
126 }); 131 });
127 }); 132 });
128 } 133 }
129 134
130 focaAbmChoferService.getChofer($routeParams.id).then(function(res) { 135 focaAbmChoferService.getChofer($routeParams.id).then(function(res) {
131 if(res.data) { 136 if(res.data) {
132 var codigo = ('00000' + res.data.transportista.COD).slice(-5); 137 var codigo = ('00000' + res.data.transportista.COD).slice(-5);
133 $scope.chofer = res.data; 138 $scope.chofer = res.data;
134 $scope.$broadcast('addCabecera', { 139 $scope.$broadcast('addCabecera', {
135 label: 'Transportista:', 140 label: 'Transportista:',
136 valor: codigo + ' - ' + res.data.transportista.NOM 141 valor: codigo + ' - ' + res.data.transportista.NOM
137 }); 142 });
138 } 143 }
139 }); 144 });
140 145
141 focaAbmChoferService.getTransportistas().then(function(res) { 146 focaAbmChoferService.getTransportistas().then(function(res) {
142 $scope.transportistas = res.data; 147 $scope.transportistas = res.data;
143 }); 148 });
144 149
145 $scope.cancelar = function() { 150 $scope.cancelar = function() {
146 $location.path('/chofer'); 151 $location.path('/chofer');
147 }; 152 };
148 153
149 $scope.guardar = function(key) { 154 $scope.guardar = function(key) {
150 key = (typeof key === 'undefined') ? 13 : key; 155 key = (typeof key === 'undefined') ? 13 : key;
151 if(key === 13) { 156 if(key === 13) {
152 validaDni().then(function() { 157 validaDni().then(function() {
153 $scope.chofer.idTransportista = $routeParams.idTransportista; 158 $scope.chofer.idTransportista = $routeParams.idTransportista;
154 delete $scope.chofer.transportista; 159 delete $scope.chofer.transportista;
155 focaAbmChoferService.guardarChofer($scope.chofer).then(function() { 160 focaAbmChoferService.guardarChofer($scope.chofer).then(function() {
156 $location.path('/chofer'); 161 $location.path('/chofer');
157 }); 162 });
158 }, function() { 163 }, function() {
159 focaModalService.alert('Dni existente'); 164 focaModalService.alert('Dni existente');
160 }); 165 });
161 } 166 }
162 }; 167 };
163 168
164 function validaDni() { 169 function validaDni() {
165 return new Promise(function(resolve, reject) { 170 return new Promise(function(resolve, reject) {
166 focaAbmChoferService 171 focaAbmChoferService
167 .getChoferPorDni($scope.chofer.dni) 172 .getChoferPorDni($scope.chofer.dni)
168 .then(function(res) { 173 .then(function(res) {
169 if(res.data.id && 174 if(res.data.id &&
170 $scope.chofer.id !== res.data.id) { 175 $scope.chofer.id !== res.data.id) {
171 reject(res.data); 176 reject(res.data);
172 }else { 177 }else {
173 resolve(); 178 resolve();
174 } 179 }
175 }); 180 });
176 }); 181 });
177 } 182 }
178 } 183 }
179 ]); 184 ]);
180 185