Commit f4dd9c46478bcec17261a04b00b5995ad85cc0af

Authored by Jose Pinto
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !8
... ... @@ -43,7 +43,6 @@ gulp.task('uglify', ['templates'], function() {
43 43 gulp.dest(paths.tmp),
44 44 rename('foca-modal-detalle-cisternas.min.js'),
45 45 uglify(),
46   - replace('"ui.bootstrap"', ''),
47 46 gulp.dest(paths.dist)
48 47 ]
49 48 );
1   -angular.module('focaModalDetalleCisternas', ['ui.bootstrap']);
  1 +angular.module('focaModalDetalleCisternas', []);
src/js/controller.js
... ... @@ -181,17 +181,28 @@ angular.module('focaModalDetalleCisternas')
181 181 }
182 182 };
183 183 $scope.autoCompletar = function() {
184   - $scope.aCargar = [];
185   - var disponible = $filter('filter')($scope.cisternas, {disabled: false});
186   - var index = $scope.cisternas.indexOf(disponible[0]);
187   - $scope.aCargar[index] = $scope.articuloSeleccionado.cantidad;
188   - };
189   - $scope.cisternaDisponible = function() {
190 184 for(var i = 0; i < $scope.cisternas.length; i++) {
191   - if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) {
192   - $scope.cisternas[i].disabled = true;
  185 + if($scope.cisternas[i].disabled) {
193 186 continue;
194 187 }
  188 + var aCargar = $scope.articuloSeleccionado.cantidad -
  189 + ($scope.articuloSeleccionado.cantidadCargada || 0);
  190 + if(aCargar > $scope.cisternas[i].disponible) {
  191 + aCargar = $scope.cisternas[i].disponible;
  192 + }
  193 + if(aCargar) {
  194 + $scope.aCargar[i] = aCargar;
  195 + $scope.actualizarArticulo();
  196 + }
  197 + }
  198 + };
  199 + $scope.cisternaDisponible = function() {
  200 + for(var i = 0; i < $scope.cisternas.length; i++) {
  201 + //Puede meter un porcentaje del total
  202 + // if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) {
  203 + // $scope.cisternas[i].disabled = true;
  204 + // continue;
  205 + // }
195 206 if($scope.cisternas[i].cisternaCarga &&
196 207 $scope.cisternas[i].cisternaCarga.idProducto &&
197 208 $scope.articuloSeleccionado.idArticulo !==
... ... @@ -203,7 +214,7 @@ angular.module(&#39;focaModalDetalleCisternas&#39;)
203 214 $scope.cisternas[i].disabled = false;
204 215 }
205 216 };
206   - $scope.rellenarInput = function(input) {
  217 + $scope.rellenarInput = function(input, cisterna) {
207 218 if(!$scope.articuloSeleccionado) return;
208 219 if($scope.articuloSeleccionado.cantidad -
209 220 $scope.articuloSeleccionado.cantidadCargada === 0) {
... ... @@ -213,6 +224,9 @@ angular.module(&#39;focaModalDetalleCisternas&#39;)
213 224 input = parseFloat(input);
214 225 input += parseFloat($scope.articuloSeleccionado.cantidad -
215 226 $scope.articuloSeleccionado.cantidadCargada);
  227 + if(input > cisterna.disponible) {
  228 + input = cisterna.disponible;
  229 + }
216 230 return input;
217 231 };
218 232 $scope.distribucionDisponible = function() {
... ... @@ -221,6 +235,11 @@ angular.module(&#39;focaModalDetalleCisternas&#39;)
221 235 !$scope.tieneArticulosPendientes()) {
222 236 return false;
223 237 }
  238 + for(var i = 0; i < $scope.cisternas.length; i++) {
  239 + if($scope.aCargar[i] > $scope.cisternas[i].disponible) {
  240 + return false;
  241 + }
  242 + }
224 243 return true;
225 244 };
226 245 $scope.tieneArticulosPendientes = function() {
src/views/foca-detalle-vehiculo.html
... ... @@ -69,7 +69,7 @@
69 69 placeholder="A cargar..."
70 70 ng-model="aCargar[key]"
71 71 ng-disabled="cisterna.disabled || !tieneArticulosPendientes()"
72   - ng-focus="aCargar[key] = rellenarInput(aCargar[key]); actualizarArticulo()"
  72 + ng-focus="aCargar[key] = rellenarInput(aCargar[key], cisterna); actualizarArticulo()"
73 73 ng-change="actualizarArticulo()"
74 74 >
75 75 </td>