Commit c0a5e54576f8d7fa64618a69ede51d2b3568c765
Exists in
master
and in
1 other branch
Merge branch 'master' into 'develop'
Master(efernandez) See merge request !39
Showing
3 changed files
Show diff stats
gulpfile.js
| ... | ... | @@ -21,7 +21,9 @@ var paths = { |
| 21 | 21 | dist: 'dist/' |
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | -gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); | |
| 24 | +gulp.task('uglify', function(callback) { | |
| 25 | + gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')(callback); | |
| 26 | +}); | |
| 25 | 27 | |
| 26 | 28 | gulp.task('templates', function() { |
| 27 | 29 | return pump( |
spec/controllerSpec.js
| ... | ... | @@ -587,20 +587,20 @@ describe('Controladores módulo crear hoja de ruta', function() { |
| 587 | 587 | |
| 588 | 588 | }); |
| 589 | 589 | |
| 590 | - it('seleccionarTarifario levanta modal y setea datos', function(done) { | |
| 590 | + it('seleccionarTarifario levanta prompt', function(done) { | |
| 591 | 591 | |
| 592 | 592 | //arrange |
| 593 | 593 | var scope = { |
| 594 | 594 | $broadcast: function() { }, |
| 595 | 595 | $watch: function() {} |
| 596 | 596 | }; |
| 597 | - var uibModal = { | |
| 598 | - open: function() { } | |
| 597 | + var focaModalService = { | |
| 598 | + prompt: function() { } | |
| 599 | 599 | }; |
| 600 | 600 | |
| 601 | 601 | $controller('hojaRutaCtrl', { |
| 602 | 602 | $scope: scope, |
| 603 | - $uibModal: uibModal, | |
| 603 | + $uibModal: {}, | |
| 604 | 604 | $location: {}, |
| 605 | 605 | $filter: $filter, |
| 606 | 606 | $timeout: $timeout, |
| ... | ... | @@ -612,26 +612,26 @@ describe('Controladores módulo crear hoja de ruta', function() { |
| 612 | 612 | }; |
| 613 | 613 | } |
| 614 | 614 | }, |
| 615 | - focaModalService: {}, | |
| 615 | + focaModalService: focaModalService, | |
| 616 | 616 | focaBotoneraLateralService: {}, |
| 617 | 617 | focaLoginService: {}, |
| 618 | 618 | $localStorage: function() {} |
| 619 | 619 | }); |
| 620 | 620 | |
| 621 | 621 | var respuesta = 1; |
| 622 | - var promesa = { result: Promise.resolve(respuesta) }; | |
| 622 | + var promesa = Promise.resolve(respuesta); | |
| 623 | 623 | |
| 624 | 624 | //act |
| 625 | - spyOn(uibModal, 'open').and.returnValue(promesa); | |
| 625 | + spyOn(focaModalService, 'prompt').and.returnValue(promesa); | |
| 626 | 626 | spyOn(scope, '$broadcast'); |
| 627 | 627 | |
| 628 | 628 | scope.seleccionarTarifario(); |
| 629 | 629 | |
| 630 | 630 | //assert |
| 631 | - promesa.result.then(function() { | |
| 632 | - expect(uibModal.open).toHaveBeenCalled(); | |
| 631 | + promesa.then(function() { | |
| 632 | + expect(focaModalService.prompt).toHaveBeenCalled(); | |
| 633 | 633 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 634 | - expect(scope.hojaRuta.tarifario).toEqual(respuesta); | |
| 634 | + expect(scope.hojaRuta.tarifario.costo).toEqual(respuesta); | |
| 635 | 635 | done(); |
| 636 | 636 | }); |
| 637 | 637 | |
| ... | ... | @@ -733,7 +733,7 @@ describe('Controladores módulo crear hoja de ruta', function() { |
| 733 | 733 | scope.eligioPreConfirmado = false; |
| 734 | 734 | scope.hojaRuta = { |
| 735 | 735 | fechaReparto: new Date() |
| 736 | - } | |
| 736 | + }; | |
| 737 | 737 | |
| 738 | 738 | var respuesta = { transportista: { } }; |
| 739 | 739 | var promesa = Promise.resolve(respuesta); |
src/js/controller.js
| ... | ... | @@ -111,7 +111,8 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 111 | 111 | idChofer: $scope.hojaRuta.chofer.id, |
| 112 | 112 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
| 113 | 113 | tarifaFlete: $scope.hojaRuta.tarifario.costo, |
| 114 | - fechaReparto: new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | |
| 114 | + fechaReparto: | |
| 115 | + new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | |
| 115 | 116 | estado: 0 |
| 116 | 117 | }, |
| 117 | 118 | remitos: $scope.hojaRuta.remitosTabla |
| ... | ... | @@ -283,11 +284,23 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 283 | 284 | |
| 284 | 285 | // remito.litros = litros; |
| 285 | 286 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
| 286 | - $scope.cargarCisterna(remito.id).then(function(response) { | |
| 287 | + $scope.cargarCisterna(remito.id).then(function() { | |
| 287 | 288 | $scope.hojaRuta.remitosTabla.push(remito); |
| 288 | - if (!response) $scope.seleccionarRemitos(); | |
| 289 | - }, function() { | |
| 290 | - $scope.seleccionarRemitos(); | |
| 289 | + }, function(error) { | |
| 290 | + | |
| 291 | + if (error && error !== 'backdrop click') { | |
| 292 | + | |
| 293 | + focaModalService | |
| 294 | + .alert(error || 'Ha ocurrido un error') | |
| 295 | + .then(function() { | |
| 296 | + $scope.seleccionarRemitos(); | |
| 297 | + }); | |
| 298 | + | |
| 299 | + } else { | |
| 300 | + | |
| 301 | + $scope.seleccionarRemitos(); | |
| 302 | + | |
| 303 | + } | |
| 291 | 304 | }); |
| 292 | 305 | }, function() { |
| 293 | 306 | // funcion ejecutada cuando se cancela el modal |