Commit 5a5cb94b5aed26f66c7e296e6803190335b60a76

Authored by Mauricio Cattafi
Exists in develop

Merge branch 'develop' into 'master'

Develop

See merge request !43
... ... @@ -4,6 +4,7 @@
4 4 "description": "Modales de foca",
5 5 "main": "index.js",
6 6 "scripts": {
  7 + "refresh": "gulp uglify && cp tmp/foca-modal.js ../wrapper-demo/node_modules/foca-modal/dist/foca-modal.min.js",
7 8 "test": "echo \"Error: no test specified\" && exit 1",
8 9 "gulp-pre-commit": "gulp pre-commit",
9 10 "compile": "gulp uglify",
src/js/controller.js
... ... @@ -11,6 +11,15 @@ angular.module('focaModal')
11 11 };
12 12 }
13 13 ])
  14 +.controller('focaModalInfoController', [
  15 + '$uibModalInstance', '$scope', 'textoModal',
  16 + function($uibModalInstance, $scope, textoModal) {
  17 + $scope.textoModal = textoModal;
  18 + $scope.aceptar = function() {
  19 + $uibModalInstance.close(true);
  20 + };
  21 + }
  22 +])
14 23 .controller('focaModalAlertController', [
15 24 '$uibModalInstance', '$scope', 'textoModal',
16 25 function($uibModalInstance, $scope, textoModal) {
... ... @@ -26,9 +35,9 @@ angular.module('focaModal')
26 35 $scope.parametros = parametros;
27 36 $scope.fecha = new Date();
28 37 $scope.options = {};
29   -
  38 +
30 39 if (parametros.minDate) $scope.options.minDate = parametros.minDate;
31   -
  40 +
32 41 $scope.cancelar = function() {
33 42 $uibModalInstance.dismiss();
34 43 };
... ... @@ -42,6 +51,10 @@ angular.module('focaModal')
42 51 function($uibModalInstance, $scope, options, focaModalService) {
43 52  
44 53 $scope.options = options;
  54 +
  55 + if (!$scope.options.tipo) {
  56 + $scope.options.tipo = 'text'
  57 + }
45 58 $scope.cancelar = function() {
46 59 $uibModalInstance.dismiss();
47 60 };
src/js/controllerMail.js
... ... @@ -6,7 +6,7 @@ angular.module('focaModal')
6 6 'Blob',
7 7 'focaModalService',
8 8 'options',
9   - function($scope, $uibModalInstance, FileSaver, Blob,
  9 + function ($scope, $uibModalInstance, FileSaver, Blob,
10 10 focaModalService, options) {
11 11  
12 12 var regexMail = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
... ... @@ -15,30 +15,40 @@ angular.module(&#39;focaModal&#39;)
15 15 $scope.correoNoEnviado = false;
16 16 $scope.esperando = false;
17 17 $scope.titulo = options.titulo;
18   - $scope.mailCliente = options.envio.mailCliente;
  18 + $scope.checkboxVar = false;
19 19  
20   - $scope.aceptar = function() {
  20 + $scope.aceptar = function () {
21 21 $uibModalInstance.close();
22 22 };
23   - $scope.salir = function() {
  23 + $scope.salir = function () {
24 24 $uibModalInstance.close($scope.descargado);
25 25 };
26   - $scope.imprimir = function () {
  26 + $scope.validarImpresion = function () {
  27 + var rutaComprobante;
  28 + rutaComprobante = $scope.checkboxVar === true ? options.descargaSinValorizar : options.descarga;
  29 + imprimir(rutaComprobante);
  30 + }
  31 + imprimir = function (rutaComprobante) {
27 32 $scope.descargado = true;
28 33 $scope.esperando = true;
29 34 focaModalService
30   - .imprimirComprobante(options.descarga.url, options.options)
31   - .then(function(res) {
32   - var data = new Blob([res.data], {type: 'application/pdf'});
  35 + .imprimirComprobante(rutaComprobante.url, options.options)
  36 + .then(function (res) {
  37 + var data = new Blob([res.data], { type: 'application/pdf' });
33 38  
34 39 FileSaver.saveAs(
35 40 data,
36   - options.descarga.nombre
  41 + rutaComprobante.nombre
37 42 );
38 43 $scope.esperando = false;
39 44 });
40 45 };
41   - $scope.enviarCorreo = function(key) {
  46 + $scope.enviarComprobante = function () {
  47 + var rutaEnvioComprobante;
  48 + rutaEnvioComprobante = $scope.checkboxVar === true ? options.envioSinValorizar : options.envio;
  49 + enviarCorreo(rutaEnvioComprobante, 13);
  50 + }
  51 + enviarCorreo = function (rutaEnvioComprobante, key) {
42 52 if (key === 13) {
43 53 if (!validarMail()) {
44 54 focaModalService.alert('Ingrese email/s vรกlido/s');
... ... @@ -46,14 +56,15 @@ angular.module(&#39;focaModal&#39;)
46 56 }
47 57 $scope.descargado = true;
48 58 $scope.esperando = true;
49   - Object.assign(options.options, {receiver: $scope.mailCliente});
  59 + rutaEnvioComprobante.mailCliente = $scope.mailCliente;
  60 + Object.assign(options.options, { receiver: $scope.mailCliente });
50 61  
51 62 focaModalService
52   - .enviarCorreo(options.envio.url, options.options)
53   - .then(function() {
  63 + .enviarCorreo(rutaEnvioComprobante.url, options.options)
  64 + .then(function () {
54 65 $scope.correoEnviado = true;
55 66 $scope.esperando = false;
56   - }, function() {
  67 + }, function () {
57 68 $scope.esperando = false;
58 69 $scope.correoNoEnviado = true;
59 70 });
... ... @@ -62,7 +73,7 @@ angular.module(&#39;focaModal&#39;)
62 73 function validarMail() {
63 74 var emails = $scope.mailCliente.split(',');
64 75 var result = true;
65   - emails.forEach(function(email) {
  76 + emails.forEach(function (email) {
66 77 if (!regexMail.test(email.trim())) result = false;
67 78 });
68 79 return result;
src/js/controllerModal.js
... ... @@ -198,7 +198,7 @@ angular.module(&#39;focaModal&#39;)
198 198 }
199 199 $scope.busquedaPress(13);
200 200  
201   - $scope.clearInput = function(){
  201 + $scope.clearInput = function() {
202 202 $scope.filters = '';
203 203 };
204 204 }]
... ... @@ -17,6 +17,20 @@ angular.module(&#39;focaModal&#39;)
17 17 }
18 18 );
19 19 },
  20 + info: function(textoModal) {
  21 + return $uibModal.open({
  22 + templateUrl: 'modal-info.html',
  23 + controller: 'focaModalInfoController',
  24 + animation: false,
  25 + backdrop: false,
  26 + resolve: { textoModal: function() { return textoModal; } }
  27 + })
  28 + .result.then(
  29 + function(resultado) {
  30 + return resultado;
  31 + }
  32 + );
  33 + },
20 34 alert: function(textoModal) {
21 35 return $uibModal.open({
22 36 templateUrl: 'modal-alert.html',
... ... @@ -91,6 +105,7 @@ angular.module(&#39;focaModal&#39;)
91 105 templateUrl: 'modal-mail.html',
92 106 controller: 'focaModalMailController',
93 107 size: 'md',
  108 + backdrop: false,
94 109 resolve: {
95 110 options: function() {return options;},
96 111 }
src/views/modal-alert.html
... ... @@ -2,7 +2,7 @@
2 2 <h4>Atenciรณn</h4>
3 3 </div>
4 4 <div class="modal-body">
5   - <p ng-bind="textoModal" class="alert">
  5 + <p ng-bind="textoModal" class="line-break">
6 6  
7 7 </p>
8 8 </div>
src/views/modal-confirm.html
... ... @@ -2,7 +2,7 @@
2 2 <h4>Confirmar</h4>
3 3 </div>
4 4 <div class="modal-body">
5   - <p ng-bind="textoModal" class="alert">
  5 + <p ng-bind="textoModal" class="line-break">
6 6  
7 7 </p>
8 8 </div>
src/views/modal-info.html
... ... @@ -0,0 +1,21 @@
  1 +<div class="focus-in">
  2 + <div class="modal-header">
  3 + <h4>Informaciรณn</h4>
  4 + </div>
  5 + <div class="modal-body">
  6 + <p ng-bind="textoModal" class="line-break m-0 pb-2"></p>
  7 + <!-- La versiรณn estรก tipeada, despuรฉs habria que hacer que se haga una consulta y devuelva la versiรณn -->
  8 + <p class="m-0 border-bottom border-top pt-2 pb-2">DEBOยฎ Distribuidores: Versiรณn 2.0</p>
  9 + <p class="mt-1">Ante un inconveniente con el sistema,</br>
  10 + comuniquese con nuestra <a href="http://focasoftware.com" target="__blank">mesa de ayuda</a></p>
  11 + <a href="http://focasoftware.com" target="__blank">
  12 + <img src="img/logo-foca.png" class="w-25 rounded mx-auto d-block mt-4">
  13 + </a>
  14 + </div>
  15 + <div class="modal-footer">
  16 + <button class="btn btn-primary" ng-click="aceptar()" foca-focus="true">Aceptar</button>
  17 + </div>
  18 +</div>
  19 +
  20 +
  21 +
src/views/modal-mail.html
... ... @@ -12,29 +12,42 @@
12 12 <label>Enviar correo a</label>
13 13 <div class="d-flex">
14 14 <input
  15 + type="email"
15 16 class="form-control col-9"
16 17 ng-model="mailCliente"
17   - ng-keypress="enviarCorreo($event.keyCode)"
  18 + ng-keypress="enviarComprobante($event.keyCode)"
18 19 teclado-virtual/>
19 20 <button
20 21 type="button"
21 22 class="btn btn-enviar ml-auto"
22   - ng-click="enviarCorreo(13)"
  23 + ng-click="enviarComprobante(13)"
23 24 ladda="esperando"
24 25 >Enviar</button>
25 26 </div>
26 27 </div>
27 28 <hr>
28 29 <div>
29   - <label>Descargar comprobante en este dispositivo</label>
30   - <button
31   - class="btn btn-enviar float-right"
32   - ng-click="imprimir()"
33   - ladda="esperando"
34   - >Descargar</button>
  30 + <label>Descargar comprobante</label>
  31 + <div class="col my-1 d-flex justify-content-end">
  32 + <button
  33 + class="btn btn-enviar float-right"
  34 + ng-click="validarImpresion()"
  35 + ladda="esperando"
  36 + >Descargar</button>
  37 + </div>
35 38 </div>
36 39 </div>
37 40 <div class="modal-footer">
  41 + <div class="custom-control custom-checkbox my-auto mr-5">
  42 + <input
  43 + type="checkbox"
  44 + class="custom-control-input mr-5"
  45 + id="check"
  46 + ng-click="checkboxVar = !checkboxVar">
  47 + <label class="custom-control-label disable-selection" for="check">
  48 + Combrobante sin valorizar
  49 + </label>
  50 + </div>
38 51 <button
39 52 type="button"
40 53 class="btn btn-secondary"
src/views/modal-prompt.html
... ... @@ -3,7 +3,7 @@
3 3 </div>
4 4 <div class="modal-body">
5 5 <input
6   - type="text"
  6 + type="{{options.tipo}}"
7 7 class="form-control"
8 8 ng-model="options.value"
9 9 ng-show="!options.textarea"