Commit 0f3656aa5d4e21c7de1241e73ab1a1deb1068e61
1 parent
a2da28e6e5
Exists in
develop
Creo modalInfo para el modal de informacion
Showing
4 changed files
with
46 additions
and
0 deletions
Show diff stats
package.json
1 | { | 1 | { |
2 | "name": "foca-modal", | 2 | "name": "foca-modal", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "Modales de foca", | 4 | "description": "Modales de foca", |
5 | "main": "index.js", | 5 | "main": "index.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "refresh": "gulp uglify && cp tmp/foca-modal.js ../wrapper-demo/node_modules/foca-modal/dist/foca-modal.min.js", | ||
7 | "test": "echo \"Error: no test specified\" && exit 1", | 8 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", |
9 | "compile": "gulp uglify", | 10 | "compile": "gulp uglify", |
10 | "postinstall": "npm run compile && gulp clean-post-install", | 11 | "postinstall": "npm run compile && gulp clean-post-install", |
11 | "install-dev": "npm install -D angular gulp gulp-angular-templatecache gulp-clean gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git" | 12 | "install-dev": "npm install -D angular gulp gulp-angular-templatecache gulp-clean gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git" |
12 | }, | 13 | }, |
13 | "pre-commit": [ | 14 | "pre-commit": [ |
14 | "gulp-pre-commit" | 15 | "gulp-pre-commit" |
15 | ], | 16 | ], |
16 | "repository": { | 17 | "repository": { |
17 | "type": "git", | 18 | "type": "git", |
18 | "url": "http://git.focasoftware.com/npm/foca-modal.git" | 19 | "url": "http://git.focasoftware.com/npm/foca-modal.git" |
19 | }, | 20 | }, |
20 | "author": "Foca Software", | 21 | "author": "Foca Software", |
21 | "license": "ISC", | 22 | "license": "ISC", |
22 | "peerDependencies": { | 23 | "peerDependencies": { |
23 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" | 24 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" |
24 | }, | 25 | }, |
25 | "devDependencies": { | 26 | "devDependencies": { |
26 | "angular": "^1.7.5", | 27 | "angular": "^1.7.5", |
27 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 28 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
28 | "gulp": "^3.9.1", | 29 | "gulp": "^3.9.1", |
29 | "gulp-angular-templatecache": "^2.2.5", | 30 | "gulp-angular-templatecache": "^2.2.5", |
30 | "gulp-clean": "^0.4.0", | 31 | "gulp-clean": "^0.4.0", |
31 | "gulp-connect": "^5.7.0", | 32 | "gulp-connect": "^5.7.0", |
32 | "gulp-htmlmin": "^5.0.1", | 33 | "gulp-htmlmin": "^5.0.1", |
33 | "gulp-jshint": "^2.1.0", | 34 | "gulp-jshint": "^2.1.0", |
34 | "gulp-rename": "^1.4.0", | 35 | "gulp-rename": "^1.4.0", |
35 | "gulp-replace": "^1.0.0", | 36 | "gulp-replace": "^1.0.0", |
36 | "gulp-uglify": "^3.0.1", | 37 | "gulp-uglify": "^3.0.1", |
37 | "jshint": "^2.9.7", | 38 | "jshint": "^2.9.7", |
38 | "pump": "^3.0.0" | 39 | "pump": "^3.0.0" |
39 | } | 40 | } |
40 | } | 41 | } |
41 | 42 |
src/js/controller.js
1 | angular.module('focaModal') | 1 | angular.module('focaModal') |
2 | .controller('focaModalConfirmController', [ | 2 | .controller('focaModalConfirmController', [ |
3 | '$uibModalInstance', '$scope', 'textoModal', | 3 | '$uibModalInstance', '$scope', 'textoModal', |
4 | function($uibModalInstance, $scope, textoModal) { | 4 | function($uibModalInstance, $scope, textoModal) { |
5 | $scope.textoModal = textoModal; | 5 | $scope.textoModal = textoModal; |
6 | $scope.cancelar = function() { | 6 | $scope.cancelar = function() { |
7 | $uibModalInstance.dismiss(false); | 7 | $uibModalInstance.dismiss(false); |
8 | }; | 8 | }; |
9 | $scope.aceptar = function() { | 9 | $scope.aceptar = function() { |
10 | $uibModalInstance.close(true); | 10 | $uibModalInstance.close(true); |
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 | .controller('focaModalAlertController', [ | 23 | .controller('focaModalAlertController', [ |
15 | '$uibModalInstance', '$scope', 'textoModal', | 24 | '$uibModalInstance', '$scope', 'textoModal', |
16 | function($uibModalInstance, $scope, textoModal) { | 25 | function($uibModalInstance, $scope, textoModal) { |
17 | $scope.textoModal = textoModal; | 26 | $scope.textoModal = textoModal; |
18 | $scope.aceptar = function() { | 27 | $scope.aceptar = function() { |
19 | $uibModalInstance.close(true); | 28 | $uibModalInstance.close(true); |
20 | }; | 29 | }; |
21 | } | 30 | } |
22 | ]) | 31 | ]) |
23 | .controller('focaModalFechaController', [ | 32 | .controller('focaModalFechaController', [ |
24 | '$uibModalInstance', '$scope', 'parametros', | 33 | '$uibModalInstance', '$scope', 'parametros', |
25 | function($uibModalInstance, $scope, parametros) { | 34 | function($uibModalInstance, $scope, parametros) { |
26 | $scope.parametros = parametros; | 35 | $scope.parametros = parametros; |
27 | $scope.fecha = new Date(); | 36 | $scope.fecha = new Date(); |
28 | $scope.options = {}; | 37 | $scope.options = {}; |
29 | 38 | ||
30 | if (parametros.minDate) $scope.options.minDate = parametros.minDate; | 39 | if (parametros.minDate) $scope.options.minDate = parametros.minDate; |
31 | 40 | ||
32 | $scope.cancelar = function() { | 41 | $scope.cancelar = function() { |
33 | $uibModalInstance.dismiss(); | 42 | $uibModalInstance.dismiss(); |
34 | }; | 43 | }; |
35 | $scope.aceptar = function() { | 44 | $scope.aceptar = function() { |
36 | $uibModalInstance.close($scope.fecha); | 45 | $uibModalInstance.close($scope.fecha); |
37 | }; | 46 | }; |
38 | } | 47 | } |
39 | ]) | 48 | ]) |
40 | .controller('focaModalPromptController', [ | 49 | .controller('focaModalPromptController', [ |
41 | '$uibModalInstance', '$scope', 'options', 'focaModalService', | 50 | '$uibModalInstance', '$scope', 'options', 'focaModalService', |
42 | function($uibModalInstance, $scope, options, focaModalService) { | 51 | function($uibModalInstance, $scope, options, focaModalService) { |
43 | 52 | ||
44 | $scope.options = options; | 53 | $scope.options = options; |
45 | 54 | ||
46 | if (!$scope.options.tipo) { | 55 | if (!$scope.options.tipo) { |
47 | $scope.options.tipo = 'text' | 56 | $scope.options.tipo = 'text' |
48 | } | 57 | } |
49 | $scope.cancelar = function() { | 58 | $scope.cancelar = function() { |
50 | $uibModalInstance.dismiss(); | 59 | $uibModalInstance.dismiss(); |
51 | }; | 60 | }; |
52 | $scope.aceptar = function(key) { | 61 | $scope.aceptar = function(key) { |
53 | if (key === 13) { | 62 | if (key === 13) { |
54 | if (options.email && !validateEmails($scope.options.value)) { | 63 | if (options.email && !validateEmails($scope.options.value)) { |
55 | focaModalService.alert('Ingrese email/s válido/s'); | 64 | focaModalService.alert('Ingrese email/s válido/s'); |
56 | return; | 65 | return; |
57 | } | 66 | } |
58 | $uibModalInstance.close($scope.options.value); | 67 | $uibModalInstance.close($scope.options.value); |
59 | } | 68 | } |
60 | }; | 69 | }; |
61 | 70 | ||
62 | function validateEmails(emails) { | 71 | function validateEmails(emails) { |
63 | var re = /^(([^<>()\[\]\\.,;:\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,}))$/; | 72 | var re = /^(([^<>()\[\]\\.,;:\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,}))$/; |
64 | var arr = emails.split(','); | 73 | var arr = emails.split(','); |
65 | var result = true; | 74 | var result = true; |
66 | 75 | ||
67 | arr.forEach(function(email) { | 76 | arr.forEach(function(email) { |
68 | var val = String(email).trim().toLowerCase(); | 77 | var val = String(email).trim().toLowerCase(); |
69 | 78 | ||
70 | if (!re.test(val)) result = false; | 79 | if (!re.test(val)) result = false; |
71 | }); | 80 | }); |
72 | 81 | ||
73 | return result; | 82 | return result; |
74 | } | 83 | } |
75 | } | 84 | } |
76 | ]); | 85 | ]); |
77 | 86 |
src/js/service.js
1 | angular.module('focaModal') | 1 | angular.module('focaModal') |
2 | .factory('focaModalService', [ | 2 | .factory('focaModalService', [ |
3 | '$uibModal', 'API_ENDPOINT', '$http', | 3 | '$uibModal', 'API_ENDPOINT', '$http', |
4 | function($uibModal, API_ENDPOINT, $http) { | 4 | function($uibModal, API_ENDPOINT, $http) { |
5 | return { | 5 | return { |
6 | confirm: function(textoModal) { | 6 | confirm: function(textoModal) { |
7 | return $uibModal.open({ | 7 | return $uibModal.open({ |
8 | templateUrl: 'modal-confirm.html', | 8 | templateUrl: 'modal-confirm.html', |
9 | controller: 'focaModalConfirmController', | 9 | controller: 'focaModalConfirmController', |
10 | animation: false, | 10 | animation: false, |
11 | backdrop: false, | 11 | backdrop: false, |
12 | resolve: { textoModal: function() { return textoModal; } } | 12 | resolve: { textoModal: function() { return textoModal; } } |
13 | }) | 13 | }) |
14 | .result.then( | 14 | .result.then( |
15 | function(resultado) { | 15 | function(resultado) { |
16 | return resultado; | 16 | return resultado; |
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 | alert: function(textoModal) { | 34 | alert: function(textoModal) { |
21 | return $uibModal.open({ | 35 | return $uibModal.open({ |
22 | templateUrl: 'modal-alert.html', | 36 | templateUrl: 'modal-alert.html', |
23 | controller: 'focaModalAlertController', | 37 | controller: 'focaModalAlertController', |
24 | animation: false, | 38 | animation: false, |
25 | backdrop: false, | 39 | backdrop: false, |
26 | resolve: { textoModal: function() { return textoModal; } } | 40 | resolve: { textoModal: function() { return textoModal; } } |
27 | }) | 41 | }) |
28 | .result.then( | 42 | .result.then( |
29 | function(resultado) { | 43 | function(resultado) { |
30 | return resultado; | 44 | return resultado; |
31 | } | 45 | } |
32 | ); | 46 | ); |
33 | }, | 47 | }, |
34 | modal: function(parametrosModal) { | 48 | modal: function(parametrosModal) { |
35 | parametrosModal.size = (typeof parametrosModal.size === 'undefined') ? | 49 | parametrosModal.size = (typeof parametrosModal.size === 'undefined') ? |
36 | 'lg' : parametrosModal.size; | 50 | 'lg' : parametrosModal.size; |
37 | 51 | ||
38 | return $uibModal.open({ | 52 | return $uibModal.open({ |
39 | templateUrl: 'foca-modal.html', | 53 | templateUrl: 'foca-modal.html', |
40 | controller: 'focaModalController', | 54 | controller: 'focaModalController', |
41 | size: parametrosModal.size, | 55 | size: parametrosModal.size, |
42 | resolve: { | 56 | resolve: { |
43 | parametrosModal: function() { return parametrosModal; } | 57 | parametrosModal: function() { return parametrosModal; } |
44 | } | 58 | } |
45 | }) | 59 | }) |
46 | .result.then( | 60 | .result.then( |
47 | function(resultado) { | 61 | function(resultado) { |
48 | return resultado; | 62 | return resultado; |
49 | } | 63 | } |
50 | ); | 64 | ); |
51 | }, | 65 | }, |
52 | getEntidad: function(filters, query, tipo, json) { | 66 | getEntidad: function(filters, query, tipo, json) { |
53 | if (tipo === 'POST') { | 67 | if (tipo === 'POST') { |
54 | return $http.post(API_ENDPOINT.URL + query, json); | 68 | return $http.post(API_ENDPOINT.URL + query, json); |
55 | } else { | 69 | } else { |
56 | return $http.get(API_ENDPOINT.URL + query, {nombre: filters}); | 70 | return $http.get(API_ENDPOINT.URL + query, {nombre: filters}); |
57 | } | 71 | } |
58 | }, | 72 | }, |
59 | modalFecha: function(parametros) { | 73 | modalFecha: function(parametros) { |
60 | return $uibModal.open({ | 74 | return $uibModal.open({ |
61 | templateUrl: 'foca-fecha.html', | 75 | templateUrl: 'foca-fecha.html', |
62 | controller: 'focaModalFechaController', | 76 | controller: 'focaModalFechaController', |
63 | size: 'md', | 77 | size: 'md', |
64 | resolve: { | 78 | resolve: { |
65 | parametros: function() { return parametros; } | 79 | parametros: function() { return parametros; } |
66 | } | 80 | } |
67 | }) | 81 | }) |
68 | .result.then( | 82 | .result.then( |
69 | function(resultado) { | 83 | function(resultado) { |
70 | return resultado; | 84 | return resultado; |
71 | } | 85 | } |
72 | ); | 86 | ); |
73 | }, | 87 | }, |
74 | prompt: function(options) { | 88 | prompt: function(options) { |
75 | return $uibModal.open({ | 89 | return $uibModal.open({ |
76 | templateUrl: 'modal-prompt.html', | 90 | templateUrl: 'modal-prompt.html', |
77 | controller: 'focaModalPromptController', | 91 | controller: 'focaModalPromptController', |
78 | size: 'md', | 92 | size: 'md', |
79 | resolve: { | 93 | resolve: { |
80 | options: function() {return options;}, | 94 | options: function() {return options;}, |
81 | } | 95 | } |
82 | }) | 96 | }) |
83 | .result.then( | 97 | .result.then( |
84 | function(resultado) { | 98 | function(resultado) { |
85 | return resultado; | 99 | return resultado; |
86 | } | 100 | } |
87 | ); | 101 | ); |
88 | }, | 102 | }, |
89 | mail: function(options) { | 103 | mail: function(options) { |
90 | return $uibModal.open({ | 104 | return $uibModal.open({ |
91 | templateUrl: 'modal-mail.html', | 105 | templateUrl: 'modal-mail.html', |
92 | controller: 'focaModalMailController', | 106 | controller: 'focaModalMailController', |
93 | size: 'md', | 107 | size: 'md', |
94 | resolve: { | 108 | resolve: { |
95 | options: function() {return options;}, | 109 | options: function() {return options;}, |
96 | } | 110 | } |
97 | }) | 111 | }) |
98 | .result.then( | 112 | .result.then( |
99 | function(resultado) { | 113 | function(resultado) { |
100 | return resultado; | 114 | return resultado; |
101 | } | 115 | } |
102 | ); | 116 | ); |
103 | }, | 117 | }, |
104 | imprimirComprobante: function(url, options) { | 118 | imprimirComprobante: function(url, options) { |
105 | return $http.post( | 119 | return $http.post( |
106 | API_ENDPOINT.URL + url, | 120 | API_ENDPOINT.URL + url, |
107 | options, | 121 | options, |
108 | {responseType: 'arraybuffer'} | 122 | {responseType: 'arraybuffer'} |
109 | ); | 123 | ); |
110 | }, | 124 | }, |
111 | enviarCorreo: function(url, options) { | 125 | enviarCorreo: function(url, options) { |
112 | return $http.post(API_ENDPOINT.URL + url, options); | 126 | return $http.post(API_ENDPOINT.URL + url, options); |
113 | } | 127 | } |
114 | }; | 128 | }; |
115 | } | 129 | } |
116 | ]); | 130 | ]); |
117 | 131 |
src/views/modal-info.html
File was created | 1 | <div> | |
2 | |||
3 | <div class="modal-header"> | ||
4 | <h4>Información</h4> | ||
5 | </div> | ||
6 | |||
7 | <div class="modal-body"> | ||
8 | <p ng-bind="textoModal" class="line-break"> | ||
9 | </p> | ||
10 | <!-- La versión está tipeada, después habria que hacer que se haga una consulta y devuelva la versión --> | ||
11 | <p class="mt-1">Debo Distribuidores: Versión 2.0</p> | ||
12 | <p class="mt-1">Ante un inconveniente con el sistema,</br> | ||
13 | comuniquese con nuestra <a href="http://focasoftware.com" target="__blank">mesa de ayuda</a></p> | ||
14 | <a href="http://focasoftware.com" target="__blank"> | ||
15 | <img src="img/logo-foca.png" class="w-25 rounded mx-auto d-block mt-4"> | ||
16 | </a> | ||
17 | </div> | ||
18 | <div class="modal-footer"> | ||
19 | <button class="btn btn-primary" ng-click="aceptar()" foca-focus="true">Aceptar</button> | ||
20 | </div> | ||
21 | </div> | ||
22 | |||
23 |