Commit a814fff2f43ccba83413615def2285b7891f53ea

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

agrego opcion readonly a modal prompt

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', 'textarea', 37 '$uibModalInstance', '$scope', 'titulo', 'initValue', 'textarea', 'readonly',
38 function($uibModalInstance, $scope, titulo, initValue, textarea) { 38 function($uibModalInstance, $scope, titulo, initValue, textarea, readonly) {
39 $scope.readonly = readonly;
39 $scope.textarea = textarea; 40 $scope.textarea = textarea;
40 $scope.titulo = titulo; 41 $scope.titulo = titulo;
41 $scope.value = initValue; 42 $scope.value = initValue;
42 $scope.cancelar = function() { 43 $scope.cancelar = function() {
43 $uibModalInstance.dismiss(); 44 $uibModalInstance.dismiss();
44 }; 45 };
45 $scope.aceptar = function() { 46 $scope.aceptar = function() {
46 $uibModalInstance.close($scope.value); 47 $uibModalInstance.close($scope.value);
47 }; 48 };
48 } 49 }
49 ]); 50 ]);
50 51
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, textarea){ 74 prompt: function(titulo, initValue, textarea, readonly){
75 textarea = textarea ? true : false; 75 textarea = textarea ? true : false;
76 readonly = readonly ? true : false;
76 return $uibModal.open({ 77 return $uibModal.open({
77 templateUrl: 'modal-prompt.html', 78 templateUrl: 'modal-prompt.html',
78 controller: 'focaModalPromptController', 79 controller: 'focaModalPromptController',
79 size: 'md', 80 size: 'md',
80 resolve: { 81 resolve: {
81 titulo: function() {return titulo;}, 82 titulo: function() {return titulo;},
82 initValue: function() {return initValue;}, 83 initValue: function() {return initValue;},
83 textarea: function() {return textarea;} 84 textarea: function() {return textarea;},
85 readonly: function() {return readonly;}
84 } 86 }
85 }) 87 })
86 .result.then( 88 .result.then(
87 function(resultado) { 89 function(resultado) {
88 return resultado; 90 return resultado;
89 } 91 }
90 ); 92 );
91 } 93 }
92 }; 94 };
93 } 95 }
94 ]); 96 ]);
95 97
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"> 9 ng-show="!textarea"
10 ng-readonly="readonly">
10 11
11 <textarea 12 <textarea
12 rows="5" 13 rows="5"
13 class="form-control text-uppercase" 14 class="form-control text-uppercase"
14 ng-model="value" 15 ng-model="value"
15 ng-show="textarea"></textarea> 16 ng-show="textarea"
17 ng-readonly="readonly"></textarea>
16 </div> 18 </div>
17 <div class="modal-footer"> 19 <div class="modal-footer">
18 <button class="btn btn-primary" ng-click="aceptar()" foca-focus="true">Aceptar</button> 20 <button class="btn btn-primary" ng-click="aceptar()" foca-focus="true">Aceptar</button>
19 <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> 21 <button class="btn btn-default" ng-click="cancelar()">Cancelar</button>
20 </div> 22 </div>
21 23