Commit 48700476ddec74b8e23235acca19227304cdc963
1 parent
ca66287c
Exists in
master
Redmine #4451
Showing
4 changed files
with
33 additions
and
11 deletions
Show diff stats
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/TermoReferenciaServiceImpl.java
| ... | ... | @@ -29,6 +29,7 @@ import br.com.centralit.api.model.TermoReferenciaObservacao; |
| 29 | 29 | import br.com.centralit.api.model.TermoReferenciaPenalidade; |
| 30 | 30 | import br.com.centralit.api.model.TermoReferenciaSancao; |
| 31 | 31 | import br.com.centralit.api.service.ConfiguracaoParametroSistemaService; |
| 32 | +import br.com.centralit.api.service.ContratoService; | |
| 32 | 33 | import br.com.centralit.api.service.DominioService; |
| 33 | 34 | import br.com.centralit.api.service.InternacionalizacaoService; |
| 34 | 35 | import br.com.centralit.api.service.ParceiroService; |
| ... | ... | @@ -39,6 +40,7 @@ import br.com.centralit.api.service.TermoReferenciaService; |
| 39 | 40 | import br.com.centralit.api.service.UsuarioService; |
| 40 | 41 | import br.com.centralit.framework.controller.ReportController; |
| 41 | 42 | import br.com.centralit.framework.exception.BusinessException; |
| 43 | +import br.com.centralit.framework.exception.CodigoErro; | |
| 42 | 44 | import br.com.centralit.framework.model.Dominio; |
| 43 | 45 | import br.com.centralit.framework.model.Usuario; |
| 44 | 46 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
| ... | ... | @@ -121,6 +123,9 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc |
| 121 | 123 | //TODO - Ciro 21/01/2016- Substituir esta dependencia por chamada rest |
| 122 | 124 | @Autowired |
| 123 | 125 | private InternacionalizacaoService internacionalizacaoService; |
| 126 | + | |
| 127 | + @Autowired | |
| 128 | + private ContratoService contratoService; | |
| 124 | 129 | |
| 125 | 130 | private Dominio idioma; |
| 126 | 131 | |
| ... | ... | @@ -157,7 +162,8 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc |
| 157 | 162 | |
| 158 | 163 | @Override |
| 159 | 164 | public boolean removeById(Long id) { |
| 160 | - | |
| 165 | + validarExclusao(id); | |
| 166 | + | |
| 161 | 167 | TermoReferencia termoReferencia = find(id); |
| 162 | 168 | if (CollectionUtils.isNotEmpty(termoReferencia.getPenalidades())){ |
| 163 | 169 | penalidadeService.removeList((List<TermoReferenciaPenalidade>) termoReferencia.getPenalidades()); |
| ... | ... | @@ -170,6 +176,11 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc |
| 170 | 176 | } |
| 171 | 177 | return termoReferenciaDao.removeById(id); |
| 172 | 178 | } |
| 179 | + | |
| 180 | + private void validarExclusao(Long id) { | |
| 181 | + Boolean isVinculado = contratoService.existeVinculo("termoReferencia.id", id); | |
| 182 | + lancarBusinessException("VALIDACAO.REMOCAO_COM_VINCULO", CodigoErro.REGRA_NEGOCIO.getValue(), isVinculado); | |
| 183 | + } | |
| 173 | 184 | |
| 174 | 185 | private void montarObjetoTermoReferencia(TermoReferencia termoReferencia) { |
| 175 | 186 | ... | ... |
cit-contratos-web/src/main/webapp/assets/js/angular/custom/controller/TermoReferenciaController.js
| ... | ... | @@ -689,19 +689,20 @@ citApp.controller('TermoReferenciaController', ['$scope', |
| 689 | 689 | }; |
| 690 | 690 | |
| 691 | 691 | // MODAL QUE CONFIRMA REMOVER TERMO |
| 692 | - $scope.remove = function(termo){ | |
| 692 | + $scope.remover = function(termo){ | |
| 693 | 693 | $scope.$openModalConfirm({ |
| 694 | 694 | message: $translate.instant('MSG.CONFIRMA_EXCLUIR_TERMO_REFERENCIA'), |
| 695 | 695 | callback: function () { |
| 696 | 696 | TermoReferenciaRepository.remove(termo).then(function() { |
| 697 | 697 | $scope.termoReferencia = {}; |
| 698 | 698 | |
| 699 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
| 700 | 699 | $scope.showAlert("success", $translate.instant('MSG.SUCESSO_EXCLUSAO_TERMO_REFERENCIA')); |
| 701 | 700 | angular.element('#searchTermoReferencia').scope().fetchResult(); |
| 702 | 701 | |
| 703 | - $scope.resetForm(); | |
| 704 | 702 | }); |
| 703 | + | |
| 704 | + $scope.$modalConfirmInstance.dismiss('cancel'); | |
| 705 | + $scope.resetForm(); | |
| 705 | 706 | } |
| 706 | 707 | }); |
| 707 | 708 | }; | ... | ... |
cit-contratos-web/src/main/webapp/assets/js/angular/custom/controller/TermoReferenciaListController.js
| ... | ... | @@ -81,17 +81,13 @@ citApp.controller('TermoReferenciaListController', ['$scope', 'TermoReferenciaRe |
| 81 | 81 | $scope.showAlert('warning', $translate.instant('MSG.SELECIONE_UM_ITEM_PARA_VISUALIZACAO')); |
| 82 | 82 | $scope.setLoadingGet(false); |
| 83 | 83 | return; |
| 84 | - } else if (edit && $scope.termoReferenciaChecked.dataTermoGerado){ | |
| 85 | - $scope.showAlert('warning', $translate.instant('MSG.TERMO_REFERENCIA_JA_GERADO')); | |
| 86 | - $scope.setLoadingGet(false); | |
| 87 | - return; | |
| 88 | 84 | } |
| 89 | 85 | angular.element('#editTermoReferencia').scope().getTermo(termo.id, edit); |
| 90 | 86 | $scope.$showPageEditWorkspace($scope.workspace); |
| 91 | 87 | }; |
| 92 | 88 | |
| 93 | 89 | // MODAL QUE CONFIRMA REMOVER Do termo |
| 94 | - $scope.remove = function(){ | |
| 90 | + $scope.remover = function(){ | |
| 95 | 91 | var termo = $scope.termoReferenciaChecked; |
| 96 | 92 | |
| 97 | 93 | if(termo === null) { |
| ... | ... | @@ -99,7 +95,21 @@ citApp.controller('TermoReferenciaListController', ['$scope', 'TermoReferenciaRe |
| 99 | 95 | return ; |
| 100 | 96 | } |
| 101 | 97 | |
| 102 | - angular.element('#editTermoReferencia').scope().remove(termo); | |
| 98 | + $scope.$openModalConfirm({ | |
| 99 | + message: $translate.instant('MSG.CONFIRMA_EXCLUIR_TERMO_REFERENCIA'), | |
| 100 | + callback: function () { | |
| 101 | + TermoReferenciaRepository.remove(termo).then(function() { | |
| 102 | + $scope.termoReferencia = {}; | |
| 103 | + | |
| 104 | + $scope.showAlert("success", $translate.instant('MSG.SUCESSO_EXCLUSAO_TERMO_REFERENCIA')); | |
| 105 | + angular.element('#searchTermoReferencia').scope().fetchResult(); | |
| 106 | + | |
| 107 | + }); | |
| 108 | + | |
| 109 | + $scope.$modalConfirmInstance.dismiss('cancel'); | |
| 110 | + $scope.resetForm(); | |
| 111 | + } | |
| 112 | + }); | |
| 103 | 113 | }; |
| 104 | 114 | |
| 105 | 115 | $scope.gerarRelatorioTermoReferencia = function (edit) { | ... | ... |
cit-contratos-web/src/main/webapp/html/termoReferencia/termoReferenciaList.html
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | <translate>LABEL.EDITAR</translate> |
| 21 | 21 | </button> |
| 22 | 22 | |
| 23 | - <button title="{{$translate.instant('LABEL.REMOVER')}}" alt="{{$translate.instant('LABEL.REMOVER')}}" class="btn btn-clear" ng-click="remove();" type="button" | |
| 23 | + <button title="{{$translate.instant('LABEL.REMOVER')}}" alt="{{$translate.instant('LABEL.REMOVER')}}" class="btn btn-clear" ng-click="remover();" type="button" | |
| 24 | 24 | ng-show="true"> |
| 25 | 25 | <i class="fa fa-times red"></i> |
| 26 | 26 | <translate>LABEL.REMOVER</translate> | ... | ... |