Commit 3b82dc345e94449265115bc8a1d303838a522505
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !14
Showing
3 changed files
 
Show diff stats
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('focaModalAlertController', [ | 14 | .controller('focaModalAlertController', [ | 
| 15 | '$uibModalInstance', '$scope', 'textoModal', | 15 | '$uibModalInstance', '$scope', 'textoModal', | 
| 16 | function($uibModalInstance, $scope, textoModal) { | 16 | function($uibModalInstance, $scope, textoModal) { | 
| 17 | $scope.textoModal = textoModal; | 17 | $scope.textoModal = textoModal; | 
| 18 | $scope.aceptar = function() { | 18 | $scope.aceptar = function() { | 
| 19 | $uibModalInstance.close(true); | 19 | $uibModalInstance.close(true); | 
| 20 | }; | 20 | }; | 
| 21 | } | 21 | } | 
| 22 | ]) | 22 | ]) | 
| 23 | .controller('focaModalFechaController', [ | 23 | .controller('focaModalFechaController', [ | 
| 24 | '$uibModalInstance', '$scope', 'titulo', | 24 | '$uibModalInstance', '$scope', 'titulo', | 
| 25 | function($uibModalInstance, $scope, titulo) { | 25 | function($uibModalInstance, $scope, titulo) { | 
| 26 | $scope.titulo = titulo; | 26 | $scope.titulo = titulo; | 
| 27 | $scope.fecha = new Date(); | 27 | $scope.fecha = new Date(); | 
| 28 | $scope.cancelar = function() { | 28 | $scope.cancelar = function() { | 
| 29 | $uibModalInstance.dismiss(); | 29 | $uibModalInstance.dismiss(); | 
| 30 | }; | 30 | }; | 
| 31 | $scope.aceptar = function() { | 31 | $scope.aceptar = function() { | 
| 32 | $uibModalInstance.close($scope.fecha); | 32 | $uibModalInstance.close($scope.fecha); | 
| 33 | }; | 33 | }; | 
| 34 | } | 34 | } | 
| 35 | ]) | 35 | ]) | 
| 36 | .controller('focaModalPromptController', [ | 36 | .controller('focaModalPromptController', [ | 
| 37 | '$uibModalInstance', '$scope', 'titulo', 'initValue', | 37 | '$uibModalInstance', '$scope', 'titulo', 'initValue', 'textarea', | 
| 38 | function($uibModalInstance, $scope, titulo, initValue) { | 38 | function($uibModalInstance, $scope, titulo, initValue, textarea) { | 
| 39 | $scope.textarea = textarea; | ||
| 39 | $scope.titulo = titulo; | 40 | $scope.titulo = titulo; | 
| 40 | $scope.value = initValue; | 41 | $scope.value = initValue; | 
| 41 | $scope.cancelar = function() { | 42 | $scope.cancelar = function() { | 
| 42 | $uibModalInstance.dismiss(); | 43 | $uibModalInstance.dismiss(); | 
| 43 | }; | 44 | }; | 
| 44 | $scope.aceptar = function() { | 45 | $scope.aceptar = function() { | 
| 45 | $uibModalInstance.close($scope.value); | 46 | $uibModalInstance.close($scope.value); | 
| 46 | }; | 47 | }; | 
| 47 | } | 48 | } | 
| 48 | ]); | 49 | ]); | 
| 49 | 50 | 
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 | alert: function(textoModal) { | 20 | alert: function(textoModal) { | 
| 21 | return $uibModal.open({ | 21 | return $uibModal.open({ | 
| 22 | templateUrl: 'modal-alert.html', | 22 | templateUrl: 'modal-alert.html', | 
| 23 | controller: 'focaModalAlertController', | 23 | controller: 'focaModalAlertController', | 
| 24 | animation: false, | 24 | animation: false, | 
| 25 | backdrop: false, | 25 | backdrop: false, | 
| 26 | resolve: { textoModal: function() { return textoModal; } } | 26 | resolve: { textoModal: function() { return textoModal; } } | 
| 27 | }) | 27 | }) | 
| 28 | .result.then( | 28 | .result.then( | 
| 29 | function(resultado) { | 29 | function(resultado) { | 
| 30 | return resultado; | 30 | return resultado; | 
| 31 | } | 31 | } | 
| 32 | ); | 32 | ); | 
| 33 | }, | 33 | }, | 
| 34 | modal: function(parametrosModal) { | 34 | modal: function(parametrosModal) { | 
| 35 | parametrosModal.size = (typeof parametrosModal.size === 'undefined') ? | 35 | parametrosModal.size = (typeof parametrosModal.size === 'undefined') ? | 
| 36 | 'lg' : parametrosModal.size; | 36 | 'lg' : parametrosModal.size; | 
| 37 | 37 | ||
| 38 | return $uibModal.open({ | 38 | return $uibModal.open({ | 
| 39 | templateUrl: 'foca-modal.html', | 39 | templateUrl: 'foca-modal.html', | 
| 40 | controller: 'focaModalController', | 40 | controller: 'focaModalController', | 
| 41 | size: parametrosModal.size, | 41 | size: parametrosModal.size, | 
| 42 | resolve: { | 42 | resolve: { | 
| 43 | parametrosModal: function() { return parametrosModal; } | 43 | parametrosModal: function() { return parametrosModal; } | 
| 44 | } | 44 | } | 
| 45 | }) | 45 | }) | 
| 46 | .result.then( | 46 | .result.then( | 
| 47 | function(resultado) { | 47 | function(resultado) { | 
| 48 | return resultado; | 48 | return resultado; | 
| 49 | } | 49 | } | 
| 50 | ); | 50 | ); | 
| 51 | }, | 51 | }, | 
| 52 | getEntidad: function(filters, query, tipo, json) { | 52 | getEntidad: function(filters, query, tipo, json) { | 
| 53 | if (tipo === 'POST') { | 53 | if (tipo === 'POST') { | 
| 54 | return $http.post(API_ENDPOINT.URL + query, json); | 54 | return $http.post(API_ENDPOINT.URL + query, json); | 
| 55 | } else { | 55 | } else { | 
| 56 | return $http.get(API_ENDPOINT.URL + query, {nombre: filters}); | 56 | return $http.get(API_ENDPOINT.URL + query, {nombre: filters}); | 
| 57 | } | 57 | } | 
| 58 | }, | 58 | }, | 
| 59 | modalFecha: function(titulo) { | 59 | modalFecha: function(titulo) { | 
| 60 | return $uibModal.open({ | 60 | return $uibModal.open({ | 
| 61 | templateUrl: 'foca-fecha.html', | 61 | templateUrl: 'foca-fecha.html', | 
| 62 | controller: 'focaModalFechaController', | 62 | controller: 'focaModalFechaController', | 
| 63 | size: 'md', | 63 | size: 'md', | 
| 64 | resolve: { | 64 | resolve: { | 
| 65 | titulo: function() {return titulo;} | 65 | titulo: function() {return titulo;} | 
| 66 | } | 66 | } | 
| 67 | }) | 67 | }) | 
| 68 | .result.then( | 68 | .result.then( | 
| 69 | function(resultado) { | 69 | function(resultado) { | 
| 70 | return resultado; | 70 | return resultado; | 
| 71 | } | 71 | } | 
| 72 | ); | 72 | ); | 
| 73 | }, | 73 | }, | 
| 74 | prompt: function(titulo, initValue){ | 74 | prompt: function(titulo, initValue, textarea){ | 
| 75 | textarea = textarea ? true : false; | ||
| 75 | return $uibModal.open({ | 76 | return $uibModal.open({ | 
| 76 | templateUrl: 'modal-prompt.html', | 77 | templateUrl: 'modal-prompt.html', | 
| 77 | controller: 'focaModalPromptController', | 78 | controller: 'focaModalPromptController', | 
| 78 | size: 'md', | 79 | size: 'md', | 
| 79 | resolve: { | 80 | resolve: { | 
| 80 | titulo: function() {return titulo;}, | 81 | titulo: function() {return titulo;}, | 
| 81 | initValue: function() {return initValue;} | 82 | initValue: function() {return initValue;}, | 
| 83 | textarea: function() {return textarea;} | ||
| 82 | } | 84 | } | 
| 83 | }) | 85 | }) | 
| 84 | .result.then( | 86 | .result.then( | 
| 85 | function(resultado) { | 87 | function(resultado) { | 
| 86 | return resultado; | 88 | return resultado; | 
| 87 | } | 89 | } | 
| 88 | ); | 90 | ); | 
| 89 | } | 91 | } | 
| 90 | }; | 92 | }; | 
| 91 | } | 93 | } | 
| 92 | ]); | 94 | ]); | 
| 93 | 95 | 
src/views/modal-prompt.html
| 1 | <div class="modal-header"> | 1 | <div class="modal-header"> | 
| 2 | <h4 ng-bind="titulo"></h4> | 2 | <h4 ng-bind="titulo"></h4> | 
| 3 | </div> | 3 | </div> | 
| 4 | <div class="modal-body"> | 4 | <div class="modal-body"> | 
| 5 | <input | 5 | <input | 
| 6 | type="text" | 6 | type="text" | 
| 7 | class="form-control" | 7 | class="form-control" | 
| 8 | ng-model="value"> | 8 | ng-model="value" | 
| 9 | ng-show="!textarea"> | ||
| 10 | |||
| 11 | <textarea | ||
| 12 | rows="5" | ||
| 13 | class="form-control text-uppercase" | ||
| 14 | ng-model="value" | ||
| 15 | ng-show="textarea"></textarea> | ||
| 9 | </div> | 16 | </div> | 
| 10 | <div class="modal-footer"> | 17 | <div class="modal-footer"> | 
| 11 | <button class="btn btn-primary" ng-click="aceptar()" foca-focus="true">Aceptar</button> | 18 | <button class="btn btn-primary" ng-click="aceptar()" foca-focus="true">Aceptar</button> | 
| 12 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | 19 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | 
| 13 | </div> | 20 | </div> | 
| 14 | 21 |