From 8290989f4eedbb9c1879fdfa1aff131dc39bc4c6 Mon Sep 17 00:00:00 2001 From: maycon.silva Date: Tue, 29 Mar 2016 20:20:02 -0300 Subject: [PATCH] correção --- cit-ecm-web/src/main/webapp/assets/js/angular/custom/controller/GerenciarProcessoController.js | 1219 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 624 insertions(+), 595 deletions(-) diff --git a/cit-ecm-web/src/main/webapp/assets/js/angular/custom/controller/GerenciarProcessoController.js b/cit-ecm-web/src/main/webapp/assets/js/angular/custom/controller/GerenciarProcessoController.js index 0822132..86f697f 100644 --- a/cit-ecm-web/src/main/webapp/assets/js/angular/custom/controller/GerenciarProcessoController.js +++ b/cit-ecm-web/src/main/webapp/assets/js/angular/custom/controller/GerenciarProcessoController.js @@ -1,611 +1,640 @@ 'use strict'; +citApp.controller( 'GerenciarProcessoController', [ + '$scope', + '$translate', + '$timeout', + 'GerenciarProcessoRepository', + 'ProcessoRepository', + 'RuntimeManagerRepository', + '$rootScope', + 'DocumentoGedRepository', + 'HistoricoAlteracaoProcessoRepository', + 'UnidadeRepository', + 'UnidadeProcessoRepository', + 'CredencialProcessoRepository', + function GerenciarProcessoController ( $scope, $translate, $timeout, GerenciarProcessoRepository, ProcessoRepository, RuntimeManagerRepository, $rootScope, DocumentoGedRepository, + HistoricoAlteracaoProcessoRepository, UnidadeRepository, UnidadeProcessoRepository, CredencialProcessoRepository ) { + + $scope.processo = {}; + $scope.iconAnexo = {}; + $scope.taskVariables = []; + $scope.unidades = []; + + // INICIALIZA VARIAVEIS PARA HABILITAR E FECHAR DIVS DE AÇÕES DO PROCESSO + + $scope.isHistoricoProcesso = true; + $scope.fecharPagina = function () { + $scope.isProcessoRelacionado = false; + $scope.isDocumentoEdit = false; + $scope.isProcessoEdit = false; + $scope.isHistoricoProcesso = false; + $scope.isVersoesDocumento = false; + $scope.isEnviarProcesso = false; + $scope.isCancelarDocumento = false; + $scope.isJustificativaAcaoProcesso = false; + $scope.isHistoricoJustificativa = false; + $scope.isAnexarProcesso = false; + $scope.widgetExemploIsCollapsed = true; + $scope.tratimitado(); + $scope.isGerenciarCredencialProcesso = false; + $scope.isClassificarProcessoDocumento = false; -citApp.controller('GerenciarProcessoController', [ '$scope', '$translate', '$timeout','GerenciarProcessoRepository', 'ProcessoRepository', 'RuntimeManagerRepository','$rootScope', 'DocumentoGedRepository', 'HistoricoAlteracaoProcessoRepository','UnidadeRepository','UnidadeProcessoRepository','CredencialProcessoRepository', - function GerenciarProcessoController($scope, $translate, $timeout, GerenciarProcessoRepository, ProcessoRepository, RuntimeManagerRepository,$rootScope, DocumentoGedRepository, HistoricoAlteracaoProcessoRepository,UnidadeRepository, UnidadeProcessoRepository,CredencialProcessoRepository ) { - - $scope.processo = {}; - $scope.iconAnexo = {}; - $scope.taskVariables = []; - $scope.unidades = []; - - //INICIALIZA VARIAVEIS PARA HABILITAR E FECHAR DIVS DE AÇÕES DO PROCESSO - - $scope.isHistoricoProcesso = true; - $scope.fecharPagina = function() { - $scope.isProcessoRelacionado = false; - $scope.isDocumentoEdit = false; - $scope.isProcessoEdit = false; - $scope.isHistoricoProcesso = false; - $scope.isVersoesDocumento = false; - $scope.isEnviarProcesso = false; - $scope.isCancelarDocumento = false; - $scope.isJustificativaAcaoProcesso = false; - $scope.isHistoricoJustificativa = false; - $scope.isAnexarProcesso = false; - $scope.widgetExemploIsCollapsed = true; - $scope.tratimitado(); - $scope.isGerenciarCredencialProcesso = false; - $scope.isClassificarProcessoDocumento = false; - - }; - - //CRIAR RELACIONAMENTO DE PROCESSO - $scope.editProcessoRelacionado = function(){ - - $scope.fecharPagina(); - $scope.isProcessoRelacionado = true; - - $timeout(function() { - angular.element("#editProcessoRelacionado").scope().getProcessoRelacionado(); - }); - - }; - - $scope.historicoJustificativa = function(){ - $scope.fecharPagina(); - $scope.isHistoricoJustificativa = true; - $timeout(function() { - angular.element("#justificativaAcaoProcessoList").scope().inicializarJustificativa(); - }); - }; - - $scope.abrirJustificativa = function(acao){ - $scope.fecharPagina(); - $scope.isCancelarDocumento = true; - }; - - - // CRIA NOVO DOCUMENTO - $scope.newDocument = function() { - - $scope.fecharPagina(); - $scope.isDocumentoEdit = true; - $scope.isVersoesDocumento = false; - $timeout(function() { - angular.element("#editDocumentoGed").scope().resetForm(); - }); - }; - - // Abre a tela de edição do documento - $scope.editDocument = function(editarDocumento, edit) { - - $scope.fecharPagina(); - $scope.isDocumentoEdit = true; - $scope.isVersoesDocumento = false; - - $timeout(function() { - angular.element("#editDocumentoGed").scope().getDocumentoGed(editarDocumento.id, edit); - }); - }; - - // ABRE ABA PARA CRIAR NOVO PROCESSO - $scope.novoProcesso = function() { - - var workspace = angular.element('#editProcessoEcm').scope().workspace; - if (workspace) { - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); - } - - $scope.openWorkspaceIfNotOpen($translate.instant('ECM.LABEL.PROCESSO'), '/cit-ecm-web/html/processo/processo.html', 'mod-orange'); - - $timeout(function() { - angular.element('#editProcessoEcm').scope().$showPageEditWorkspace(angular.element('#editProcessoEcm').scope().workspace); - angular.element('#editProcessoEcm').scope().resetForm(); - - }, 600); - - }; - - //Gerenciar as credenciais do processo - $scope.gerenciarCredenciaisProcesso = function() { - - $scope.fecharPagina(); - $scope.isGerenciarCredencialProcesso = true; - - $timeout(function() { - angular.element("#credencialProcessoEdit").scope().iniciarCredencial($scope.processo.id, $scope.credencialUsuarioProcesso); - }); - }; - - - //EXECUÇÃO PROCESSO - $scope.executarProcesso = function(action){ - $scope.flowAction = action; - - if(action.requireReason){ - $scope.fecharPagina(); - $scope.isJustificativaAcaoProcesso = true; - $timeout(function() { - angular.element("#justificativaAcaoProcesso").scope().resetForm(); - }); - }else{ - $scope.closeWidget(); - - DocumentoGedRepository.existeVinculo({'joinClass' : 'processo.id', 'id': $scope.processo.id}).then(function(result) { - if(!result){ - var mensagem = $translate.instant('ECM.MSG.PROCESSO_SEM_DOCUMENTO') + $scope.flowAction.name; - $scope.showAlert("warning", mensagem ); - } else{ - var mensagem = $translate.instant('ECM.MSG.CONFIRMA_EXECUCAO_FLUXO'); - mensagem += $scope.flowAction.name; - $scope.$openModalConfirm({message: mensagem, callback: $scope.avancarFluxo}); - } - }); - - $scope.saveHistoricoProcessoAcao(); - } - }; - - $scope.avancarFluxo = function (){ - $scope.$modalConfirmInstance.dismiss('cancel'); - $scope.updateTask(true); - - }; - - //Salvar Historico Execução Processo - $scope.saveHistoricoProcessoAcao = function(){ - - var historicoAlteracaoProcesso = { - descricaoAcao : $translate.instant('ECM.MSG_HISTORICO_ECM.ACAO_PROCESSO'), - processo : $scope.processo, - autor : $scope.usuarioLogado, - acaoAlteracao : "ACAO_PROCESSO", - mapaAtributos : {"protocolo" : $scope.processo.nup, "acao" : $scope.flowAction.name} - }; - - HistoricoAlteracaoProcessoRepository.saveParams(historicoAlteracaoProcesso).then(function(result){ - }); - }; - - - //Conclui o proceso - $scope.concluir = function(){ - - DocumentoGedRepository.existeVinculo({'joinClass' : 'processo.id', 'id': $scope.processo.id}).then(function(result) { - if(!result){ - var mensagem = $translate.instant('ECM.MSG.PROCESSO_SEM_DOCUMENTO') +" " +$translate.instant('ECM.LABEL.CONCLUIR') ; - $scope.showAlert("warning", mensagem ); - } else{ - - $scope.$openModalConfirm({message: $translate.instant('ECM.MSG.CONFIRMA_CONCLUIR_PROCESSO'), callback: $scope.saveConcluir}); - } - }); - }; - - $scope.saveConcluir = function(){ - - ProcessoRepository.concluir({"idProcesso" : $scope.processo.id, "idTask" : $scope.task.id}).then(function(result) { - - //Verifica se foi concluido em todas unidades. - $timeout(function() { - if(result){ - if($scope.task.flowElement.actions && $scope.task.flowElement.actions.length == 1){ - $scope.executarProcesso($scope.task.flowElement.actions[0]); + }; + + // CRIAR RELACIONAMENTO DE PROCESSO + $scope.editProcessoRelacionado = function () { + + $scope.fecharPagina(); + $scope.isProcessoRelacionado = true; + + $timeout( function () { + angular.element( "#editProcessoRelacionado" ).scope().getProcessoRelacionado(); + } ); + + }; + + $scope.historicoJustificativa = function () { + $scope.fecharPagina(); + $scope.isHistoricoJustificativa = true; + $timeout( function () { + angular.element( "#justificativaAcaoProcessoList" ).scope().inicializarJustificativa(); + } ); + }; + + $scope.abrirJustificativa = function ( acao ) { + $scope.fecharPagina(); + $scope.isCancelarDocumento = true; + }; + + // CRIA NOVO DOCUMENTO + $scope.newDocument = function () { + + $scope.fecharPagina(); + $scope.isDocumentoEdit = true; + $scope.isVersoesDocumento = false; + $timeout( function () { + angular.element( "#editDocumentoGed" ).scope().resetForm(); + } ); + }; + + // Abre a tela de edição do documento + $scope.editDocument = function ( editarDocumento, edit ) { + + $scope.fecharPagina(); + $scope.isDocumentoEdit = true; + $scope.isVersoesDocumento = false; + + $timeout( function () { + angular.element( "#editDocumentoGed" ).scope().getDocumentoGed( editarDocumento.id, edit ); + } ); + }; + + // ABRE ABA PARA CRIAR NOVO PROCESSO + $scope.novoProcesso = function () { + + var workspace = angular.element( '#editProcessoEcm' ).scope().workspace; + if ( workspace ) { + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); + } + + $scope.openWorkspaceIfNotOpen( $translate.instant( 'ECM.LABEL.PROCESSO' ), '/cit-ecm-web/html/processo/processo.html', 'mod-orange' ); + + $timeout( function () { + angular.element( '#editProcessoEcm' ).scope().$showPageEditWorkspace( angular.element( '#editProcessoEcm' ).scope().workspace ); + angular.element( '#editProcessoEcm' ).scope().resetForm(); + + }, 600 ); + + }; + + // Gerenciar as credenciais do processo + $scope.gerenciarCredenciaisProcesso = function () { + + $scope.fecharPagina(); + $scope.isGerenciarCredencialProcesso = true; + + $timeout( function () { + angular.element( "#credencialProcessoEdit" ).scope().iniciarCredencial( $scope.processo.id, $scope.credencialUsuarioProcesso ); + } ); + }; + + // EXECUÇÃO PROCESSO + $scope.executarProcesso = function ( action ) { + $scope.flowAction = action; + + if ( action.requireReason ) { + $scope.fecharPagina(); + $scope.isJustificativaAcaoProcesso = true; + $timeout( function () { + angular.element( "#justificativaAcaoProcesso" ).scope().resetForm(); + } ); + } else { + $scope.closeWidget(); + + DocumentoGedRepository.existeVinculo( { + 'joinClass' : 'processo.id', + 'id' : $scope.processo.id + } ).then( function ( result ) { + if ( !result ) { + var mensagem = $translate.instant( 'ECM.MSG.PROCESSO_SEM_DOCUMENTO' ) + $scope.flowAction.name; + $scope.showAlert( "warning", mensagem ); + } else { + var mensagem = $translate.instant( 'ECM.MSG.CONFIRMA_EXECUCAO_FLUXO' ); + mensagem += $scope.flowAction.name; + $scope.$openModalConfirm( { + message : mensagem, + callback : $scope.avancarFluxo + } ); + } + } ); + + $scope.saveHistoricoProcessoAcao(); + } + }; + + $scope.avancarFluxo = function () { + $scope.$modalConfirmInstance.dismiss( 'cancel' ); + $scope.updateTask( true ); + + }; + + // Salvar Historico Execução Processo + $scope.saveHistoricoProcessoAcao = function () { + + var historicoAlteracaoProcesso = { + descricaoAcao : $translate.instant( 'ECM.MSG_HISTORICO_ECM.ACAO_PROCESSO' ), + processo : $scope.processo, + autor : $scope.usuarioLogado, + acaoAlteracao : "ACAO_PROCESSO", + mapaAtributos : { + "protocolo" : $scope.processo.nup, + "acao" : $scope.flowAction.name } - }else{ - var workspace = angular.element('#editProcessoEcm').scope().workspace; - if (workspace) { - $scope.$modalConfirmInstance.dismiss('cancel'); - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); - - angular.element("#citapp-controller").scope().showAlert("success", $translate.instant('MSG.PROCESSO_ENVIADO_SUCESSO')); - } + }; + + HistoricoAlteracaoProcessoRepository.saveParams( historicoAlteracaoProcesso ).then( function ( result ) { + } ); + }; + + // Conclui o proceso + $scope.concluir = function () { + + DocumentoGedRepository.existeVinculo( { + 'joinClass' : 'processo.id', + 'id' : $scope.processo.id + } ).then( function ( result ) { + if ( !result ) { + var mensagem = $translate.instant( 'ECM.MSG.PROCESSO_SEM_DOCUMENTO' ) + " " + $translate.instant( 'ECM.LABEL.CONCLUIR' ); + $scope.showAlert( "warning", mensagem ); + } else { + + $scope.$openModalConfirm( { + message : $translate.instant( 'ECM.MSG.CONFIRMA_CONCLUIR_PROCESSO' ), + callback : $scope.saveConcluir + } ); + } + } ); + }; + + $scope.saveConcluir = function () { + + ProcessoRepository.concluir( { + "idProcesso" : $scope.processo.id, + "idTask" : $scope.task.id + } ).then( function ( result ) { + + // Verifica se foi concluido em todas unidades. + $timeout( function () { + if ( result ) { + if ( $scope.task.flowElement.actions && $scope.task.flowElement.actions.length == 1 ) { + $scope.executarProcesso( $scope.task.flowElement.actions[ 0 ] ); + } + } else { + var workspace = angular.element( '#editProcessoEcm' ).scope().workspace; + if ( workspace ) { + $scope.$modalConfirmInstance.dismiss( 'cancel' ); + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); + + angular.element( "#citapp-controller" ).scope().showAlert( "success", $translate.instant( 'MSG.PROCESSO_ENVIADO_SUCESSO' ) ); + } + } + + }, 100 ); + + $scope.showAlert( "success", $translate.instant( 'ECM.MSG.SUCESSO_CONCLUIR_PROCESSO' ) ); + + $scope.$modalConfirmInstance.dismiss( 'cancel' ); + + $scope.saveHistoricoProcesso(); + } ); + }; + + // Salvar Historico processo UNIDADE + $scope.saveHistoricoProcesso = function ( unidadesProcessoList ) { + + var historicoAlteracaoProcesso = { + descricaoAcao : $translate.instant( 'ECM.MSG_HISTORICO_ECM.CONCLUSAO_PROCESSO_UNIDADE' ), + processo : $scope.processo, + autor : $scope.usuarioLogado, + acaoAlteracao : "CONCLUSAO_PROCESSO_UNIDADE" + }; + + HistoricoAlteracaoProcessoRepository.saveParams( historicoAlteracaoProcesso ).then( function ( result ) { + + } ); + + }; + + // MONTA O EDITAR DO PROCESSO + $scope.editProcessoECM = function () { + + $scope.fecharPagina(); + $scope.isProcessoEdit = true; + $scope.isVersoesDocumento = false; + + $timeout( function () { + angular.element( '#editProcessoEcm' ).scope().getProcesso( $scope.processo, true ); + angular.element( document.querySelector( '#topoMenu' ) ).remove(); + angular.element( document.querySelector( '#cabecalhoProcesso' ) ).remove(); + } ); + + }; + + // ATUALIZAR PADRÃO DE PROCESSO + $scope.atualizaProcesso = function () { + + $timeout( function () { + ProcessoRepository.get( $scope.processo.id ).then( function ( result ) { + $scope.processo = result.originalElement; + } ); + }, 100 ); + + }; + + // VERSOES DO DOCUMENTO + $scope.visualizarVersoes = function ( documento ) { + + $scope.fecharPagina(); + $scope.isVersoesDocumento = true; + $scope.idDocumento = documento.id; + var idRaiz = documento.idRaiz; + if ( !idRaiz ) { + idRaiz = documento.id; } - - }, 100); - - $scope.showAlert("success", $translate.instant('ECM.MSG.SUCESSO_CONCLUIR_PROCESSO')); - - $scope.$modalConfirmInstance.dismiss('cancel'); - - $scope.saveHistoricoProcesso(); - }); - }; - - //Salvar Historico processo UNIDADE - $scope.saveHistoricoProcesso = function(unidadesProcessoList){ - - var historicoAlteracaoProcesso = { - descricaoAcao : $translate.instant('ECM.MSG_HISTORICO_ECM.CONCLUSAO_PROCESSO_UNIDADE'), - processo : $scope.processo, - autor : $scope.usuarioLogado, - acaoAlteracao : "CONCLUSAO_PROCESSO_UNIDADE" - }; - - HistoricoAlteracaoProcessoRepository.saveParams(historicoAlteracaoProcesso).then(function(result){ - - }); - - }; - - // MONTA O EDITAR DO PROCESSO - $scope.editProcessoECM = function() { - - $scope.fecharPagina(); - $scope.isProcessoEdit = true; - $scope.isVersoesDocumento = false; - - $timeout(function() { - angular.element('#editProcessoEcm').scope().getProcesso($scope.processo, true); - angular.element(document.querySelector('#topoMenu')).remove(); - angular.element(document.querySelector('#cabecalhoProcesso')).remove(); - }); - - - }; - - //ATUALIZAR PADRÃO DE PROCESSO - $scope.atualizaProcesso = function() { - - $timeout(function(){ - ProcessoRepository.get($scope.processo.id).then(function(result) { - $scope.processo = result.originalElement; - }); - }, 100); - - }; - - //VERSOES DO DOCUMENTO - $scope.visualizarVersoes = function(documento){ - - $scope.fecharPagina(); - $scope.isVersoesDocumento = true; - $scope.idDocumento = documento.id; - var idRaiz = documento.idRaiz; - if(!idRaiz){ - idRaiz = documento.id; - } - DocumentoGedRepository.findByIdDocumentoTodasVersoes(idRaiz).then(function(result) { - $scope.listVersoes = result; - }); - - }; - - //ENVIAR PROCESSO - $scope.enviarProcesso = function(){ - - DocumentoGedRepository.existeVinculo({'joinClass' : 'processo.id', 'id': $scope.processo.id}).then(function(result) { - if(result){ + DocumentoGedRepository.findByIdDocumentoTodasVersoes( idRaiz ).then( function ( result ) { + $scope.listVersoes = result; + } ); + + }; + + // ENVIAR PROCESSO + $scope.enviarProcesso = function () { + + DocumentoGedRepository.existeVinculo( { + 'joinClass' : 'processo.id', + 'id' : $scope.processo.id + } ).then( function ( result ) { + if ( result ) { + $scope.fecharPagina(); + $scope.isEnviarProcesso = true; + + $timeout( function () { + angular.element( "#enviarProcessoEdit" ).scope().iniciarEnvio( $scope.processo.id, $scope.task.id ); + } ); + } else { + $scope.showAlert( "warning", $translate.instant( 'ECM.MSG.PROCESSO_SEM_DOCUMENTO_ENVIO_UNIDADE' ) ); + } + } ); + }; + + // ANEXAR PROCESSO + $scope.anexarProcesso = function () { $scope.fecharPagina(); - $scope.isEnviarProcesso = true; - - $timeout(function() { - angular.element("#enviarProcessoEdit").scope().iniciarEnvio($scope.processo.id, $scope.task.id); - }); - }else{ - $scope.showAlert("warning", $translate.instant('ECM.MSG.PROCESSO_SEM_DOCUMENTO_ENVIO_UNIDADE')); - } - }); - }; - - //ANEXAR PROCESSO - $scope.anexarProcesso = function(){ - $scope.fecharPagina(); - $scope.isAnexarProcesso = true; - $timeout(function() { - angular.element("#anexarProcessoEdit").scope().getProcessoAnexado(); - }); - }; - - - //CLASSIFICAR PROCESSO E DOCUMENTO - $scope.classificarDocumentoProceso = function(){ - $scope.fecharPagina(); - $scope.isClassificarProcessoDocumento = true; - $timeout(function() { - angular.element("#classificarDocumento").scope().getProcesso($scope.processo); - }); - }; - - //REMOVER DOCUMENTO - $scope.removeDocumento = function(documento, index){ - $scope.$openModalConfirm({ - message: $translate.instant('MSG.CONFIRMA_EXCLUSAO'), - callback: function () { - DocumentoGedRepository.remove(documento).then(function() { - - $scope.$modalConfirmInstance.dismiss('cancel'); - $scope.showAlert("success", $translate.instant('MSG.SUCESSO_EXCLUIR')); - $scope.isDocumentoEdit = false; - $scope.processo.documentos.splice(index , 1); - - var historicoAlteracaoProcesso = { - documentoGed : $scope.documentoGed, - descricaoAcao : $translate.instant('ECM.MSG_HISTORICO_ECM.REMOCAO_DOCUMENTO'), - processo : $scope.processo, - autor : $scope.usuarioLogado, - idTask : $scope.task.id, - acaoAlteracao : "REMOCAO_DOCUMENTO" - }; - HistoricoAlteracaoProcessoRepository.saveParams(historicoAlteracaoProcesso).then(function(result){ - - }); - }); - } - }); - }; - - //Exibir dialog para remover credencial do usuário - $scope.exibirDialogConfirmacaoRemoverCredencial = function(){ - - $scope.$openModalConfirm({message: $translate.instant('ECM.MSG.CONFIRMA_RENUNCIAR_CREDENCIAL'), callback: $scope.removeCredemcial}); - - }; - - //Remover a credencial do usuário - $scope.removeCredemcial = function(){ - - CredencialProcessoRepository.remove($scope.credencialUsuarioProcesso).then(function() { - - $scope.credencialUsuarioProcesso = null; - - $scope.voltarGerenciamentoTarefa(); - - }); - }; - - //Voltar para tela de gerenciamento de tarefa - $scope.voltarGerenciamentoTarefa = function(){ - - var workspace = angular.element('#searchGerenciarProcesso').scope().workspace; - if (workspace) { - $scope.$modalConfirmInstance.dismiss('cancel'); - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); - - angular.element("#citapp-controller").scope().showAlert("success", $translate.instant('ECM.MSG.CREDENCIAL_REMOVIDA_SUCESSO')); - } - - $timeout(function(){ - angular.element('#idGerenciamentoTarefas').scope().fetchResult(); - }); - - }; - - //Cancelar documento - $scope.cancelarDocumento = function(documento){ - - $scope.fecharPagina(); - $scope.isCancelarDocumento = true; - $timeout(function() { - angular.element("#cancelarDocumento").scope().resetForm(documento, $scope.task.id); - }); - }; - - $scope.getCancelamentoDocumento = function(documento){ - - $scope.fecharPagina(); - $scope.isCancelarDocumento = true; - $timeout(function() { - angular.element("#cancelarDocumento").scope().getCancelamentoDocumento(documento.cancelamentoDocumentoGed.id); - }); - }; - - // SALVA PROCESSO - $scope.saveOrUpdateProcessoECM = function() { - - // CHAMA GRAVAR DO PROCESSOCONTROLLER.JS - angular.element('#editProcessoEcm').scope().saveOrUpdate(); - - $scope.closeWidget(); - $scope.atualizaProcesso(); - }; - - - // ABRE A VIEW DE GERENCIAR PROCESSO ANEXO - $scope.viewProcessoAnexo = function (processoViewAnexo){ - if(processoViewAnexo != null){ - - var pagina = '/cit-ecm-web/html/gerenciarProcesso/gerenciarProcessoView.html'; - - $scope.openWorkspaceIfNotOpen($translate.instant('ECM.LABEL.PROCESSO'), pagina, 'mod-orange'); - - $timeout(function() { - angular.element('#viewGerenciarProcesso').scope().getProcessoRelacionado(processoViewAnexo); - - }, 400); - } - }; - //FIM - - // FECHA WIDGET E INICIA WIDGET PADRÃO - $scope.closeWidget = function() { - angular.element("#widget-historico").scope().atualizar(); - - $scope.fecharPagina(); - $scope.widgetExemploIsCollapsed = false; - //WIDGET PRADAO - $scope.isHistoricoProcesso = true; - }; - - $scope.tratimitado = function(){ - UnidadeProcessoRepository.existeVinculo({'joinClass' : 'processo.id', 'id': $scope.processo.id}).then(function(result) { - if(result){ - $scope.isTramitado = true; - }else{ - $scope.isTramitado = false; - } - }); - }; - - - - // ------------------------------EXECUTA BPE------------------------------------ - - // ATUALIZAR TASK BPE - $scope.updateTask = function(complete) { - if ($scope.updateAction && (!$scope.flowAction || !$scope.flowAction.id)) { - $scope.showAlert("error", $translate.instant('ESI.MSG.SELECIONE_ACAO')); - return; - } + $scope.isAnexarProcesso = true; + $timeout( function () { + angular.element( "#anexarProcessoEdit" ).scope().getProcessoAnexado(); + } ); + }; + // CLASSIFICAR PROCESSO E DOCUMENTO + $scope.classificarDocumentoProceso = function () { + $scope.fecharPagina(); + $scope.isClassificarProcessoDocumento = true; + $timeout( function () { + angular.element( "#classificarDocumento" ).scope().getProcesso( $scope.processo ); + } ); + }; - // Executa regras criadas - if ($scope.businessRule && $scope.businessRule != '') { - $scope.buildBusinessRuleVariables(); - $scope[$scope.businessRule] = undefined; - RuntimeManagerRepository.executeBusinessRule($scope.businessRule, $scope.businessRuleVariables).then(function(result) { - $scope[$scope.businessRule] = result.originalElement.businessRule; - if ($scope[$scope.businessRule] && $scope[$scope.businessRule].valid) { - $scope.execute(complete); - } - }); - }else{ - $scope.execute(complete); - } - - }; - - // FIM - - $scope.hasTaskVariable = function(name) { - for (var i = 0; i < $scope.taskVariables.length; i++) { - if ($scope.taskVariables[i].name == name) { - return true; - } - } - return false; - }; - - - // EXCUTA TAREFA BPE - $scope.execute = function(complete) { - $scope.setLoading(true,$translate.instant('ESI.EXECUTANDO_TAREFA')+" "+$scope.task.flowElement.name); - $scope.runtimeManagerUtils.executeCode("beforeUpdate"); - - var idRetorno = ESI_RETURN+$scope.flowName; - var idParam = ESI_PARAM+$scope.flowName; - $scope[idParam] = new RuntimeEnvironmentInput($scope.flowName,$scope.taskVariables); - $scope[idParam].workItemId = $scope.task.id; - $scope[idParam].updateFlowAction = $scope.updateAction; - - // ADICIONA ACÃO DO FLUXO NO SCOPO - if ($scope.updateAction) { - $scope[idParam].flowAction = $scope.flowAction; - } + // REMOVER DOCUMENTO + $scope.removeDocumento = function ( documento, index ) { + $scope.$openModalConfirm( { + message : $translate.instant( 'MSG.CONFIRMA_EXCLUSAO' ), + callback : function () { + DocumentoGedRepository.remove( documento ).then( function () { + + $scope.$modalConfirmInstance.dismiss( 'cancel' ); + $scope.showAlert( "success", $translate.instant( 'MSG.SUCESSO_EXCLUIR' ) ); + $scope.isDocumentoEdit = false; + $scope.processo.documentos.splice( index, 1 ); + + var historicoAlteracaoProcesso = { + documentoGed : $scope.documentoGed, + descricaoAcao : $translate.instant( 'ECM.MSG_HISTORICO_ECM.REMOCAO_DOCUMENTO' ), + processo : $scope.processo, + autor : $scope.usuarioLogado, + idTask : $scope.task.id, + acaoAlteracao : "REMOCAO_DOCUMENTO" + }; + HistoricoAlteracaoProcessoRepository.saveParams( historicoAlteracaoProcesso ).then( function ( result ) { + + } ); + } ); + } + } ); + }; - $scope[idRetorno] = new RuntimeEnvironmentOutput(null); - - RuntimeManagerRepository.updateTask($scope[idParam], complete).then(function(result) { - $scope[idRetorno] = new RuntimeEnvironmentOutput(result.originalElement); - $scope.runtimeManagerUtils.setObjectValues($scope[idRetorno]); - - $scope.processInstance = result.originalElement.processInstance; - - $scope.runtimeManagerUtils.saveDocuments($scope[idRetorno].processInstance, $scope.task); - - $scope.runtimeManagerUtils.executeCode("afterUpdate"); - $scope.setLoading(false); - $scope.showExecuteButton = false; - if ($scope.callbackFunction != null) - $scope.callbackFunction(); - $rootScope.controllerScope.fetchResult(); - if ($scope.removeWorkspace) - $scope.close(); - $scope.showAlert("success","ESI.MSG.TAREFA_EXECUTADA",""); - - }); - }; - - // FIM - - $scope.close = function() { - var workspace = angular.element('#searchGerenciarProcesso').scope().workspace; - if (workspace) { - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); - } - }; - - - // RETORNA VARIAVEIS DA TASK BPE - $scope.buildTaskVariables = function() { - if ($scope.task.flowElement.variables) { - for (var i = 0; i < $scope.task.flowElement.variables.length; i++) { - var taskVariable = $scope.task.flowElement.variables[i]; - if (taskVariable.output) { - if ($scope[taskVariable.flowVariable.variable.name] != undefined && !$scope.hasTaskVariable(taskVariable.flowVariable.variable.name)) { - $scope.taskVariables.push(new RuntimeVariable(taskVariable.flowVariable.variable.name , taskVariable.flowVariable.variable.variableType, $scope[taskVariable.flowVariable.variable.name])); + // Exibir dialog para remover credencial do usuário + $scope.exibirDialogConfirmacaoRemoverCredencial = function () { + + $scope.$openModalConfirm( { + message : $translate.instant( 'ECM.MSG.CONFIRMA_RENUNCIAR_CREDENCIAL' ), + callback : $scope.removeCredemcial + } ); + + }; + + // Remover a credencial do usuário + $scope.removeCredemcial = function () { + + CredencialProcessoRepository.remove( $scope.credencialUsuarioProcesso ).then( function () { + + $scope.credencialUsuarioProcesso = null; + + $scope.voltarGerenciamentoTarefa(); + + } ); + }; + + // Voltar para tela de gerenciamento de tarefa + $scope.voltarGerenciamentoTarefa = function () { + + var workspace = angular.element( '#searchGerenciarProcesso' ).scope().workspace; + if ( workspace ) { + $scope.$modalConfirmInstance.dismiss( 'cancel' ); + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); + + angular.element( "#citapp-controller" ).scope().showAlert( "success", $translate.instant( 'ECM.MSG.CREDENCIAL_REMOVIDA_SUCESSO' ) ); + } + + $timeout( function () { + angular.element( '#idGerenciamentoTarefas' ).scope().fetchResult(); + } ); + + }; + + // Cancelar documento + $scope.cancelarDocumento = function ( documento ) { + + $scope.fecharPagina(); + $scope.isCancelarDocumento = true; + $timeout( function () { + angular.element( "#cancelarDocumento" ).scope().resetForm( documento, $scope.task.id ); + } ); + }; + + $scope.getCancelamentoDocumento = function ( documento ) { + + $scope.fecharPagina(); + $scope.isCancelarDocumento = true; + $timeout( function () { + angular.element( "#cancelarDocumento" ).scope().getCancelamentoDocumento( documento.cancelamentoDocumentoGed.id ); + } ); + }; + + // SALVA PROCESSO + $scope.saveOrUpdateProcessoECM = function () { + + // CHAMA GRAVAR DO PROCESSOCONTROLLER.JS + angular.element( '#editProcessoEcm' ).scope().saveOrUpdate(); + + $scope.closeWidget(); + $scope.atualizaProcesso(); + }; + + // ABRE A VIEW DE GERENCIAR PROCESSO ANEXO + $scope.viewProcessoAnexo = function ( processoViewAnexo ) { + if ( processoViewAnexo != null ) { + + var pagina = '/cit-ecm-web/html/gerenciarProcesso/gerenciarProcessoView.html'; + + $scope.openWorkspaceIfNotOpen( $translate.instant( 'ECM.LABEL.PROCESSO' ), pagina, 'mod-orange' ); + + $timeout( function () { + angular.element( '#viewGerenciarProcesso' ).scope().getProcessoRelacionado( processoViewAnexo ); + + }, 400 ); + } + }; + // FIM + + // FECHA WIDGET E INICIA WIDGET PADRÃO + $scope.closeWidget = function () { + angular.element( "#widget-historico" ).scope().atualizar(); + + $scope.fecharPagina(); + $scope.widgetExemploIsCollapsed = false; + // WIDGET PRADAO + $scope.isHistoricoProcesso = true; + }; + + $scope.tratimitado = function () { + UnidadeProcessoRepository.existeVinculo( { + 'joinClass' : 'processo.id', + 'id' : $scope.processo.id + } ).then( function ( result ) { + if ( result ) { + $scope.isTramitado = true; + } else { + $scope.isTramitado = false; + } + } ); + }; + + // ------------------------------EXECUTA BPE------------------------------------ + + // ATUALIZAR TASK BPE + $scope.updateTask = function ( complete ) { + if ( $scope.updateAction && ( !$scope.flowAction || !$scope.flowAction.id ) ) { + $scope.showAlert( "error", $translate.instant( 'ESI.MSG.SELECIONE_ACAO' ) ); + return; + } + + // Executa regras criadas + if ( $scope.businessRule && $scope.businessRule != '' ) { + $scope.buildBusinessRuleVariables(); + $scope[ $scope.businessRule ] = undefined; + RuntimeManagerRepository.executeBusinessRule( $scope.businessRule, $scope.businessRuleVariables ).then( function ( result ) { + $scope[ $scope.businessRule ] = result.originalElement.businessRule; + if ( $scope[ $scope.businessRule ] && $scope[ $scope.businessRule ].valid ) { + $scope.execute( complete ); } + } ); + } else { + $scope.execute( complete ); + } + + }; + + // FIM + + $scope.hasTaskVariable = function ( name ) { + for ( var i = 0; i < $scope.taskVariables.length; i++ ) { + if ( $scope.taskVariables[ i ].name == name ) { + return true; } } + return false; }; - }; - // FIM - - // METODOS DE INICIACAO DO BPE - $scope.initialize = function() { - $scope.setLoading(true); - - RuntimeManagerRepository.initializeUserTask($scope.task.id).then(function(result) { - $scope.task = result.originalElement.workItem; - - //VERIFICA SE A TASK(WORKITEM) JÁ FOI EXECULTADO - if ($scope.task.status == 'CANCELLED' || $scope.task.status == 'COMPLETED') { - $scope.setLoading(false); - $scope.showAlert('error', $translate.instant('ESI.MSG.TAREFA_JA_EXECUTADA')); - return ; + + // EXCUTA TAREFA BPE + $scope.execute = function ( complete ) { + $scope.setLoading( true, $translate.instant( 'ESI.EXECUTANDO_TAREFA' ) + " " + $scope.task.flowElement.name ); + $scope.runtimeManagerUtils.executeCode( "beforeUpdate" ); + + var idRetorno = ESI_RETURN + $scope.flowName; + var idParam = ESI_PARAM + $scope.flowName; + $scope[ idParam ] = new RuntimeEnvironmentInput( $scope.flowName, $scope.taskVariables ); + $scope[ idParam ].workItemId = $scope.task.id; + $scope[ idParam ].updateFlowAction = $scope.updateAction; + + // ADICIONA ACÃO DO FLUXO NO SCOPO + if ( $scope.updateAction ) { + $scope[ idParam ].flowAction = $scope.flowAction; } - - // COLOCA AS VARIAVEIS DE RETORNO NO SCOPO - $scope.runtimeManagerUtils = new RuntimeManagerUtils($scope, $scope, $translate, RuntimeManagerRepository); - var idRetorno = ESI_RETURN+$scope.task.processInstance.id; - $scope[idRetorno] = new RuntimeEnvironmentOutput(result.originalElement); - $scope.runtimeManagerUtils.setObjectValues($scope[idRetorno]); - // FIM - - //VERIFICA SE EXISTE MAIS DE UMA AÇÃO NA EXECUÇÃO DO WORK ITEM - $scope.updateAction = $scope.task.flowElement.actions && $scope.task.flowElement.actions.length > 0; - if ($scope.task.flowElement.actions.length == 1) { - $scope.flowAction = $scope.task.flowElement.actions[0]; + + $scope[ idRetorno ] = new RuntimeEnvironmentOutput( null ); + + RuntimeManagerRepository.updateTask( $scope[ idParam ], complete ).then( function ( result ) { + $scope[ idRetorno ] = new RuntimeEnvironmentOutput( result.originalElement ); + $scope.runtimeManagerUtils.setObjectValues( $scope[ idRetorno ] ); + + $scope.processInstance = result.originalElement.processInstance; + + $scope.runtimeManagerUtils.saveDocuments( $scope[ idRetorno ].processInstance, $scope.task ); + + $scope.runtimeManagerUtils.executeCode( "afterUpdate" ); + $scope.setLoading( false ); + $scope.showExecuteButton = false; + if ( $scope.callbackFunction != null ) + $scope.callbackFunction(); + $rootScope.controllerScope.fetchResult(); + if ( $scope.removeWorkspace ) + $scope.close(); + $scope.showAlert( "success", "ESI.MSG.TAREFA_EXECUTADA", "" ); + + } ); + }; + + // FIM + + $scope.close = function () { + var workspace = angular.element( '#searchGerenciarProcesso' ).scope().workspace; + if ( workspace ) { + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); } - $scope.siglas = []; - - - // CARREGA O PROCESSO VINCULADO A TAREFA - $timeout(function(){ - // console.log('idProcesso:' + $scope.idProcesso); - ProcessoRepository.get($scope.idProcesso).then(function(result) { - $scope.processo = result.originalElement; - - CredencialProcessoRepository.obterCredencialUsuarioLogado($scope.idProcesso).then(function(result) { - $scope.credencialUsuarioProcesso = result.originalElement; - }); - - if ($scope.$parent != undefined) { - $scope.$parent.idProcesso = $scope.idProcesso; - } - - if (angular.element('#viewGerenciarProcesso').scope() != undefined) { - var workspace = angular.element('#viewGerenciarProcesso').scope().workspace; - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); + }; + + // RETORNA VARIAVEIS DA TASK BPE + $scope.buildTaskVariables = function () { + if ( $scope.task.flowElement.variables ) { + for ( var i = 0; i < $scope.task.flowElement.variables.length; i++ ) { + var taskVariable = $scope.task.flowElement.variables[ i ]; + if ( taskVariable.output ) { + if ( $scope[ taskVariable.flowVariable.variable.name ] != undefined && !$scope.hasTaskVariable( taskVariable.flowVariable.variable.name ) ) { + $scope.taskVariables.push( new RuntimeVariable( taskVariable.flowVariable.variable.name, taskVariable.flowVariable.variable.variableType, + $scope[ taskVariable.flowVariable.variable.name ] ) ); + } } - - $scope.tratimitado(); - - $scope.setLoading(false); - }); - - }, 400); - }); - }; - // FIM EXECUTAR BPE - - if($scope.task != null){ - $scope.initialize(); - } - - $scope.getProcesso = function(processo){ - - $scope.setLoadingGet(true); - - $scope.isHistoricoProcesso = true; - - $scope.processo = processo; - $scope.idProcesso = $scope.processo.id; - - $scope.setLoading(false); - - }; - - -}]); + } + } + ; + }; + // FIM + + // METODOS DE INICIACAO DO BPE + $scope.initialize = function () { + $scope.setLoading( true ); + + RuntimeManagerRepository.initializeUserTask( $scope.task.id ).then( function ( result ) { + $scope.task = result.originalElement.workItem; + + // VERIFICA SE A TASK(WORKITEM) JÁ FOI EXECULTADO + if ( $scope.task.status == 'CANCELLED' || $scope.task.status == 'COMPLETED' ) { + $scope.setLoading( false ); + $scope.showAlert( 'error', $translate.instant( 'ESI.MSG.TAREFA_JA_EXECUTADA' ) ); + return; + } + + // COLOCA AS VARIAVEIS DE RETORNO NO SCOPO + $scope.runtimeManagerUtils = new RuntimeManagerUtils( $scope, $scope, $translate, RuntimeManagerRepository ); + var idRetorno = ESI_RETURN + $scope.task.processInstance.id; + $scope[ idRetorno ] = new RuntimeEnvironmentOutput( result.originalElement ); + $scope.runtimeManagerUtils.setObjectValues( $scope[ idRetorno ] ); + // FIM + + // VERIFICA SE EXISTE MAIS DE UMA AÇÃO NA EXECUÇÃO DO WORK ITEM + $scope.updateAction = $scope.task.flowElement.actions && $scope.task.flowElement.actions.length > 0; + if ( $scope.task.flowElement.actions.length == 1 ) { + $scope.flowAction = $scope.task.flowElement.actions[ 0 ]; + } + $scope.siglas = []; + + // CARREGA O PROCESSO VINCULADO A TAREFA + $timeout( function () { + // console.log('idProcesso:' + $scope.idProcesso); + ProcessoRepository.get( $scope.idProcesso ).then( function ( result ) { + $scope.processo = result.originalElement; + + CredencialProcessoRepository.obterCredencialUsuarioLogado( $scope.idProcesso ).then( function ( result ) { + $scope.credencialUsuarioProcesso = result.originalElement; + } ); + + if ( $scope.$parent != undefined ) { + $scope.$parent.idProcesso = $scope.idProcesso; + } + + if ( angular.element( '#viewGerenciarProcesso' ).scope() != undefined ) { + var workspace = angular.element( '#viewGerenciarProcesso' ).scope().workspace; + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); + } + + $scope.tratimitado(); + + $scope.setLoading( false ); + } ); + + }, 400 ); + } ); + }; + // FIM EXECUTAR BPE + + if ( $scope.task != null ) { + $scope.initialize(); + } + + $scope.getProcesso = function ( processo ) { + + $scope.setLoadingGet( true ); + + $scope.isHistoricoProcesso = true; + + $scope.processo = processo; + $scope.idProcesso = $scope.processo.id; + + $scope.setLoading( false ); + + }; + + } +] ); -- libgit2 0.21.2