Commit 1b737409d15df983b44b4d6d39179fd7d26b9aad
1 parent
16fec94665
Exists in
master
refactor ahora paso objeto a modal
Showing
3 changed files
with
16 additions
and
23 deletions
Show diff stats
src/js/controllerModal.js
| ... | ... | @@ -5,17 +5,11 @@ angular.module('focaModal') |
| 5 | 5 | '$scope', |
| 6 | 6 | '$uibModalInstance', |
| 7 | 7 | 'focaModalService', |
| 8 | - 'columnas', | |
| 9 | - 'query', | |
| 10 | - 'titulo', | |
| 11 | - 'size', | |
| 12 | - function($timeout, $filter, $scope, $uibModalInstance, focaModalService, | |
| 13 | - columnas, query, titulo, size) { | |
| 14 | - | |
| 15 | - $scope.size = size; | |
| 8 | + 'parametrosModal', | |
| 9 | + function($timeout, $filter, $scope, $uibModalInstance, focaModalService, parametrosModal) { | |
| 10 | + | |
| 11 | + $scope.parametrosModal = parametrosModal; | |
| 16 | 12 | $scope.filters = ''; |
| 17 | - $scope.columnas = columnas; | |
| 18 | - $scope.titulo = titulo; | |
| 19 | 13 | $scope.entidades = []; |
| 20 | 14 | $scope.primerBusqueda = false; |
| 21 | 15 | $scope.searchLoading = false; |
| ... | ... | @@ -29,7 +23,7 @@ angular.module('focaModal') |
| 29 | 23 | $scope.busquedaPress = function(key) { |
| 30 | 24 | if(key === 13) { |
| 31 | 25 | $scope.searchLoading = true; |
| 32 | - focaModalService.getEntidad($scope.filters, query).then( | |
| 26 | + focaModalService.getEntidad($scope.filters, parametrosModal.query).then( | |
| 33 | 27 | function(res) { |
| 34 | 28 | $scope.searchLoading = false; |
| 35 | 29 | $scope.primerBusqueda = true; |
src/js/service.js
| ... | ... | @@ -31,18 +31,16 @@ angular.module('focaModal') |
| 31 | 31 | } |
| 32 | 32 | ); |
| 33 | 33 | }, |
| 34 | - modal: function(columnas, query, titulo, size) { | |
| 35 | - size = (typeof size === 'undefined') ? 'lg' : size; | |
| 34 | + modal: function(parametrosModal) { | |
| 35 | + parametrosModal.size = (typeof parametrosModal.size === 'undefined') ? | |
| 36 | + 'lg' : parametrosModal.size; | |
| 36 | 37 | |
| 37 | 38 | return $uibModal.open({ |
| 38 | 39 | templateUrl: 'foca-modal.html', |
| 39 | 40 | controller: 'focaModalController', |
| 40 | - size: size, | |
| 41 | + size: parametrosModal.size, | |
| 41 | 42 | resolve: { |
| 42 | - columnas: function() { return columnas; }, | |
| 43 | - query: function() { return query; }, | |
| 44 | - titulo: function() { return titulo; }, | |
| 45 | - size: function() { return size; } | |
| 43 | + parametrosModal: function() { return parametrosModal; } | |
| 46 | 44 | } |
| 47 | 45 | }) |
| 48 | 46 | .result.then( |
src/views/foca-modal.html
| 1 | 1 | <div class="modal-header py-1"> |
| 2 | 2 | <div class="row w-100"> |
| 3 | - <div ng-class="(size == 'md') ? 'col-lg-12' : 'col-lg-6'"> | |
| 4 | - <h5 class="modal-title my-1">{{titulo}}</h5> | |
| 3 | + <div ng-class="(parametrosModal.size == 'md') ? 'col-lg-12' : 'col-lg-6'"> | |
| 4 | + <h5 class="modal-title my-1">{{parametrosModal.titulo}}</h5> | |
| 5 | + <h6 ng-if="parametrosModal.subTitulo">{{parametrosModal.subTitulo}}</h6> | |
| 5 | 6 | </div> |
| 6 | - <div class="input-group pr-0 my-2" ng-class="(size == 'md') ? 'col-lg-12' : 'col-lg-6'"> | |
| 7 | + <div class="input-group pr-0 my-2" ng-class="(parametrosModal.size == 'md') ? 'col-lg-12' : 'col-lg-6'"> | |
| 7 | 8 | <input |
| 8 | 9 | ladda="searchLoading" |
| 9 | 10 | type="text" |
| ... | ... | @@ -41,7 +42,7 @@ |
| 41 | 42 | <table ng-show="primerBusqueda" class="table table-striped table-sm col-12"> |
| 42 | 43 | <thead> |
| 43 | 44 | <tr> |
| 44 | - <th ng-repeat="nombre in columnas.nombre" ng-bind="nombre"></th> | |
| 45 | + <th ng-repeat="nombre in parametrosModal.columnas.nombre" ng-bind="nombre"></th> | |
| 45 | 46 | <th></th> |
| 46 | 47 | </tr> |
| 47 | 48 | </thead> |
| ... | ... | @@ -56,7 +57,7 @@ |
| 56 | 57 | ng-click="select(entidad)" |
| 57 | 58 | > |
| 58 | 59 | <td |
| 59 | - ng-repeat="propiedad in columnas.propiedad" | |
| 60 | + ng-repeat="propiedad in parametrosModal.columnas.propiedad" | |
| 60 | 61 | ng-bind="entidad[propiedad]"></td> |
| 61 | 62 | <td class="d-md-none text-primary"> |
| 62 | 63 | <i class="fa fa-circle-thin" aria-hidden="true"></i> |