diff --git a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts index be25665bc..adb7063d5 100644 --- a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts @@ -311,7 +311,7 @@ export class ExpedienteDetailPage implements OnInit { }); } - attachDocument(){ + attachDocument() { this.getDoc(); } @@ -326,11 +326,11 @@ export class ExpedienteDetailPage implements OnInit { } }); await modal.present(); - modal.onDidDismiss().then( async (res)=>{ + modal.onDidDismiss().then( async (res)=> { if(res){ const data = res.data; this.documents.push(data.selected); - this.documents.forEach((element: any) =>{ + this.documents.forEach((element: any) => { let body = { "InstanceID": this.task.InstanceID, @@ -348,10 +348,9 @@ export class ExpedienteDetailPage implements OnInit { this.attachmentsService.AddAttachment(body).subscribe((res)=> { this.toastService.successMessage() - - },()=> { + }, ()=> { this.toastService.badRequest() - },()=> { + }, ()=> { loader.remove() }); diff --git a/src/app/pages/search/search.page.ts b/src/app/pages/search/search.page.ts index 29b55a0e6..7a0f27203 100644 --- a/src/app/pages/search/search.page.ts +++ b/src/app/pages/search/search.page.ts @@ -7,13 +7,11 @@ import { formatDate } from '@angular/common'; import { SenderPage } from 'src/app/pages/search/sender/sender.page'; import { OrganicEntityPage } from 'src/app/pages/search/organic-entity/organic-entity.page'; import WordCloud from 'src/plugin/wordcloud2.js'; -import { slugify } from 'src/plugin/javascript-remove-accents.js'; import { ViewEventPage } from 'src/app/pages/agenda/view-event/view-event.page'; import { PublicationDetailPage } from '../publications/view-publications/publication-detail/publication-detail.page'; import { DocumentDetailPage } from 'src/app/modals/document-detail/document-detail.page'; -import { ExpedientTaskModalPage } from '../gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page'; import { OptsExpedientePage } from 'src/app/shared/popover/opts-expediente/opts-expediente.page'; -import { CreateProcessPage } from 'src/app/modals/create-process/create-process.page'; + @Component({ @@ -75,7 +73,6 @@ export class SearchPage implements OnInit { this.showSearchInput = this.navParams.get('showSearchInput'); - if(this.type == null || this.type == undefined) { if(this.currentPath == '/home/agenda') { @@ -89,10 +86,8 @@ export class SearchPage implements OnInit { console.log('search bug!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') } } - } - selectItem(item: SearchDocument) { if(this.select){ this.modalController.dismiss({ @@ -187,7 +182,7 @@ export class SearchPage implements OnInit { }, ); - },100); + }, 100); } diff --git a/src/app/pipes/search-document.pipe.ts b/src/app/pipes/search-document.pipe.ts index 59b762d06..8e475f9ab 100644 --- a/src/app/pipes/search-document.pipe.ts +++ b/src/app/pipes/search-document.pipe.ts @@ -1,6 +1,6 @@ import { Pipe, PipeTransform } from '@angular/core'; import { ExpedientTaskModalPageNavParamsTask } from '../models/ExpedientTaskModalPage'; -import { Attachments, FromSearchDocument, SearchFolder } from '../models/search-document'; +import { Attachments, FromSearchDocument, SearchDocument, SearchFolder } from '../models/search-document'; @Pipe({ name: 'searchDocument' @@ -12,29 +12,22 @@ export class SearchDocumentPipe implements PipeTransform { } - transformToAttachment(document): Attachments[] { - - let task: ExpedientTaskModalPageNavParamsTask - //let _document: = this.LoadedDocument - // let folder: SearchFolder = this.LoadedDocument - + transformToAttachment(document: SearchDocument): Attachments[] { const attachments = [] - if(document.Documents) { - document.Documents.forEach( (ele) => { - console.log(ele) - attachments.push({ - ApplicationId: 361, - Source: 1, - SourceId: ele.docID || ele.docId || ele.DocId || ele.Id, - SourceName: ele.Assunto - }) - }); - } else { + console.log('document', document) + if(document.ApplicationType == 361) { + attachments.push({ + ApplicationId: 361, + Source: 1, + SourceId: document['docID'] || document['docId'] || document['DocId'] || document.Id, + SourceName: document.Assunto + }) + } else if (document.ApplicationType == 8) { attachments.push({ ApplicationId: 8, Source: 1, - SourceId: document.docID || document.docId || document.DocId || document.Id, + SourceId: document['docID'] || document['docId'] || document['DocId'] || document.Id, SourceName: document.Assunto }) } diff --git a/src/app/shared/popover/opts-expediente/opts-expediente.page.ts b/src/app/shared/popover/opts-expediente/opts-expediente.page.ts index a3d01676d..82401fab4 100644 --- a/src/app/shared/popover/opts-expediente/opts-expediente.page.ts +++ b/src/app/shared/popover/opts-expediente/opts-expediente.page.ts @@ -2,10 +2,14 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, NavigationExtras, Router } from '@angular/router'; import { ModalController, NavParams, PopoverController } from '@ionic/angular'; import { AddNotePage } from 'src/app/modals/add-note/add-note.page'; +import { SearchDocument } from 'src/app/models/search-document'; import { PermissionService } from 'src/app/OtherService/permission.service'; import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page'; import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page'; import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page'; +import { SearchPage } from 'src/app/pages/search/search.page'; +import { SearchDocumentPipe } from 'src/app/pipes/search-document.pipe'; +import { AttachmentsService } from 'src/app/services/attachments.service'; import { ProcessesService } from 'src/app/services/processes.service'; import { ToastService } from 'src/app/services/toast.service'; @@ -21,6 +25,8 @@ export class OptsExpedientePage implements OnInit { caller:string; showEnviarPendentes = false + searchDocumentPipe = new SearchDocumentPipe() + documents:SearchDocument[] = []; constructor( private popoverController: PopoverController, @@ -30,7 +36,8 @@ export class OptsExpedientePage implements OnInit { private toastService: ToastService, private router: Router, private activatedRoute: ActivatedRoute, - public p: PermissionService + public p: PermissionService, + private attachmentsService: AttachmentsService, ) { this.task = this.navParams.get('task'); this.fulltask = this.navParams.get('fulltask'); @@ -53,7 +60,7 @@ export class OptsExpedientePage implements OnInit { this.popoverController.dismiss(); } else{ - this.modalController.dismiss(); + this.popoverController.dismiss(); } } @@ -107,7 +114,57 @@ export class OptsExpedientePage implements OnInit { } } - attachDocument(){} + attachDocument(){ + this.getDoc(); + } + + async getDoc() { + const modal = await this.modalController.create({ + component: SearchPage, + cssClass: 'modal-width-100-width-background modal', + componentProps: { + type: 'AccoesPresidenciais & ArquivoDespachoElect', + showSearchInput: true, + select: true + } + }); + await modal.present(); + modal.onDidDismiss().then( async (res)=>{ + if(res){ + const data = res.data; + this.documents.push(data.selected); + this.documents.forEach((element: any) =>{ + + let body = { + "InstanceID": this.task.InstanceID, + "WorkflowDisplayName": this.task.WorkflowName, + "FolderID": this.task.FolderId, + "DispatchNumber": this.task.DispatchNumber, + "AttachmentsProcessLastInstanceID": this.task.AttachmentsProcessLastInstanceID, + "Attachments": [] + } + + const Attachments = this.searchDocumentPipe.transformToAttachment(element) + body.Attachments = Attachments; + + const loader = this.toastService.loading() + + this.attachmentsService.AddAttachment(body).subscribe((res)=> { + this.toastService.successMessage() + },()=> { + this.toastService.badRequest() + },()=> { + loader.remove() + }); + + }); + + this.popoverController.dismiss() + + } + }); + + } async openAddNoteModal(actionName:string) { let classs; @@ -354,5 +411,6 @@ export class OptsExpedientePage implements OnInit { } }); } + }