Commit 604e89ec8a035d27d6baac2660a7bd10b8ad72b4
1 parent
fbe64cc5fb
Exists in
master
selecciona texto cuando abre modal
Showing
2 changed files
with
6 additions
and
1 deletions
Show diff stats
src/js/controller.js
| 1 | angular.module('focaModalEfectivo') | 1 | angular.module('focaModalEfectivo') |
| 2 | .controller('focaModalEfectivoController', | 2 | .controller('focaModalEfectivoController', |
| 3 | [ | 3 | [ |
| 4 | '$scope', | 4 | '$scope', |
| 5 | '$uibModalInstance', | 5 | '$uibModalInstance', |
| 6 | 'sugerido', | 6 | 'sugerido', |
| 7 | function($scope, $uibModalInstance, sugerido) { | 7 | '$timeout', |
| 8 | function($scope, $uibModalInstance, sugerido, $timeout) { | ||
| 8 | if(sugerido && sugerido < 0) { | 9 | if(sugerido && sugerido < 0) { |
| 9 | $scope.efectivo = Math.abs(sugerido); | 10 | $scope.efectivo = Math.abs(sugerido); |
| 11 | $timeout(function() { | ||
| 12 | angular.element('#importe')[0].select(); | ||
| 13 | }); | ||
| 10 | } | 14 | } |
| 11 | $scope.aceptar = function(key) { | 15 | $scope.aceptar = function(key) { |
| 12 | if(key === 13 && parseFloat($scope.efectivo)) { | 16 | if(key === 13 && parseFloat($scope.efectivo)) { |
| 13 | var efectivo = parseFloat($scope.efectivo); | 17 | var efectivo = parseFloat($scope.efectivo); |
| 14 | $uibModalInstance.close(efectivo); | 18 | $uibModalInstance.close(efectivo); |
| 15 | } | 19 | } |
| 16 | }; | 20 | }; |
| 17 | 21 | ||
| 18 | $scope.cancel = function() { | 22 | $scope.cancel = function() { |
| 19 | $uibModalInstance.dismiss('cancel'); | 23 | $uibModalInstance.dismiss('cancel'); |
| 20 | }; | 24 | }; |
| 21 | } | 25 | } |
| 22 | ] | 26 | ] |
| 23 | ); | 27 | ); |
| 24 | 28 |
src/views/modal-efectivo.html
| 1 | <div class="modal-header"> | 1 | <div class="modal-header"> |
| 2 | <h3 class="modal-title">Ingrese Efectivo</h3> | 2 | <h3 class="modal-title">Ingrese Efectivo</h3> |
| 3 | </div> | 3 | </div> |
| 4 | <div class="modal-body" id="modal-body"> | 4 | <div class="modal-body" id="modal-body"> |
| 5 | <form name="formEfectivo"> | 5 | <form name="formEfectivo"> |
| 6 | <div class="input-group"> | 6 | <div class="input-group"> |
| 7 | <div class="input-group-prepend"> | 7 | <div class="input-group-prepend"> |
| 8 | <div class="input-group-text form-control form-control-sm">$</div> | 8 | <div class="input-group-text form-control form-control-sm">$</div> |
| 9 | </div> | 9 | </div> |
| 10 | <input | 10 | <input |
| 11 | teclado-virtual | 11 | teclado-virtual |
| 12 | foca-tipo-input | 12 | foca-tipo-input |
| 13 | id="importe" | ||
| 13 | ng-model="efectivo" | 14 | ng-model="efectivo" |
| 14 | foca-focus="true" | 15 | foca-focus="true" |
| 15 | class="form-control form-control-sm" | 16 | class="form-control form-control-sm" |
| 16 | placeholder="Ingrese monto" | 17 | placeholder="Ingrese monto" |
| 17 | ng-keypress="aceptar($event.keyCode)" | 18 | ng-keypress="aceptar($event.keyCode)" |
| 18 | > | 19 | > |
| 19 | </div> | 20 | </div> |
| 20 | <br> | 21 | <br> |
| 21 | <div class="alert alert-warning"> | 22 | <div class="alert alert-warning"> |
| 22 | Si ya ha ingresado efectivo, el monto que ingrese se sumará o restará al ya ingresado. | 23 | Si ya ha ingresado efectivo, el monto que ingrese se sumará o restará al ya ingresado. |
| 23 | </div> | 24 | </div> |
| 24 | </form> | 25 | </form> |
| 25 | </div> | 26 | </div> |
| 26 | <div class="modal-footer"> | 27 | <div class="modal-footer"> |
| 27 | <button | 28 | <button |
| 28 | class="btn btn-primary" | 29 | class="btn btn-primary" |
| 29 | type="button" | 30 | type="button" |
| 30 | ng-click="aceptar(13)" | 31 | ng-click="aceptar(13)" |
| 31 | ng-disabled="!formEfectivo.$valid" | 32 | ng-disabled="!formEfectivo.$valid" |
| 32 | >Aceptar</button> | 33 | >Aceptar</button> |
| 33 | <button class="btn btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | 34 | <button class="btn btn-secondary" type="button" ng-click="cancel()">Cancelar</button> |
| 34 | </div> | 35 | </div> |
| 35 | 36 |