diff --git a/package-lock.json b/package-lock.json index 73e1c0b20..7896c0a29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3722,6 +3722,11 @@ "integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==", "dev": true }, + "@types/uuid": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz", + "integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==" + }, "@types/webpack-sources": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.8.tgz", @@ -19762,6 +19767,22 @@ "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==", "dev": true }, + "uuidv4": { + "version": "6.2.11", + "resolved": "https://registry.npmjs.org/uuidv4/-/uuidv4-6.2.11.tgz", + "integrity": "sha512-OTS4waH9KplrXNADKo+Q1kT9AHWr8DaC0S5F54RQzEwcUaEzBEWQQlJyDUw/u1bkRhJyqkqhLD4M4lbFbV+89g==", + "requires": { + "@types/uuid": "8.3.1", + "uuid": "8.3.2" + }, + "dependencies": { + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + } + } + }, "valid-identifier": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/valid-identifier/-/valid-identifier-0.0.2.tgz", diff --git a/package.json b/package.json index f2a435fe0..2af2bc0c2 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "sharp": "^0.25.4", "socket.io-client": "^2.3.0", "tslib": "^2.0.0", + "uuidv4": "^6.2.11", "wordcloud": "^1.1.2", "ws": "^7.4.6", "zone.js": "~0.10.2" diff --git a/src/app/pages/agenda/edit-event/edit-event.page.html b/src/app/pages/agenda/edit-event/edit-event.page.html index 05d1fc398..a167d9ae2 100644 --- a/src/app/pages/agenda/edit-event/edit-event.page.html +++ b/src/app/pages/agenda/edit-event/edit-event.page.html @@ -235,23 +235,24 @@ -
- +
+

{{document.SourceName}} - +

-

{{document.Stakeholders}}

+

Correspondência Acções Presidenciais Arquivo Despacho Electrónico - {{document.CreateDate | date: 'dd-MM-yy'}}

+ +

diff --git a/src/app/pages/agenda/edit-event/edit-event.page.ts b/src/app/pages/agenda/edit-event/edit-event.page.ts index 0228acc0b..75dfabae1 100644 --- a/src/app/pages/agenda/edit-event/edit-event.page.ts +++ b/src/app/pages/agenda/edit-event/edit-event.page.ts @@ -38,7 +38,7 @@ export class EditEventPage implements OnInit { caller:string; - loadedEventAttachments: Attachment[]; + loadedEventAttachments: Attachment[] = []; taskParticipants: any = []; taskParticipantsCc: any = []; adding: "intervenient" | "CC" = "intervenient"; @@ -185,6 +185,40 @@ export class EditEventPage implements OnInit { this.toastService.badRequest() } + this.saveDocument() + } + + + saveDocument() { + + this.loadedEventAttachments.forEach((e)=>{ + + const id: any = e.Id + const remove = e['remove'] + + if ( id == 'add') { + //data.selected + const DocumentToSave = { + SourceTitle: e.SourceName, + ParentId: this.postEvent.EventId, + Source: '1', + SourceId: e.SourceId, + ApplicationId: e.ApplicationId.toString(), + Id: '0', + Link: '', + SerialNumber: '', + }; + + this.attachmentsService.setEventAttachmentById(DocumentToSave).subscribe(()=>{ + this.getAttachments(this.postEvent.EventId); + }); + + } else if(remove) { + this.attachmentsService.deleteEventAttachmentById(e.Id).subscribe( res=> {}) + } + + }) + } async openAttendees() { @@ -254,12 +288,17 @@ export class EditEventPage implements OnInit { }); } - deleteAttachment(attachmentID: string) { + deleteAttachment(attachmentID: string, index) { - this.attachmentsService.deleteEventAttachmentById(attachmentID).subscribe( - res=>{ - this.loadedEventAttachments = this.loadedEventAttachments.filter(e=> e.Id.toString() != attachmentID); - }) + const id: any = this.loadedEventAttachments[index].Id + + if(id == 'add') { + this.loadedEventAttachments = this.loadedEventAttachments.filter((e,i)=> i!=index) + } else { + this.loadedEventAttachments[index]['remove'] = true + } + + } async getDoc() { @@ -273,27 +312,30 @@ export class EditEventPage implements OnInit { } }); await modal.present(); - modal.onDidDismiss().then( async (res)=>{ - if(res){ + modal.onDidDismiss().then( async (res)=> { + if(res) { const data = res.data; - //data.selected - const DocumentToSave = { - SourceTitle: data.selected.Assunto, + + const ApplicationIdDocumentToSave: any = { + SourceName: data.selected.Assunto, ParentId: this.postEvent.EventId, - Source: '1', SourceId: data.selected.Id, + Stakeholders: false, ApplicationId: data.selected.ApplicationType.toString(), - Id: '0', + CreateDate: false, + // needed to attach this document + Id: 'add', + SourceTitle: data.selected.Assunto, + Source: '1', Link: '', SerialNumber: '', - }; + } - await this.attachmentsService.setEventAttachmentById(DocumentToSave).subscribe(()=>{ - this.getAttachments(this.postEvent.EventId); - }); + console.log( this.loadedEventAttachments) + this.loadedEventAttachments.push(ApplicationIdDocumentToSave) } - }); + }) } } \ No newline at end of file diff --git a/src/app/pages/search/search.page.ts b/src/app/pages/search/search.page.ts index a3cda93c2..7e0e52038 100644 --- a/src/app/pages/search/search.page.ts +++ b/src/app/pages/search/search.page.ts @@ -463,15 +463,15 @@ export class SearchPage implements OnInit { } } - clearInputRemetente() { + clearInputRemetente(){ this.searchSender = ""; } - clearInputDocumentDate() { + clearInputDocumentDate(){ this.searchDocumentDate = ""; } - clearInputOrganicEntity() { + clearInputOrganicEntity(){ this.searchOrganicEntiry = ""; } @@ -531,10 +531,10 @@ export class SearchPage implements OnInit { } - async filterDocList(categoryName:string) { + async filterDocList(categoryName:string){ // show all category - if(this. showCategory == categoryName ) { + if(this. showCategory == categoryName ){ this.showSearchDocuments = this.searchDocuments; @@ -562,12 +562,12 @@ export class SearchPage implements OnInit { const ApplicationType = searchDocument.ApplicationType.toString() const Id = searchDocument.Id - if(this.select == false) { + if(this.select == false){ if(this.type == "Agenda") { const modal = await this.modalCtrl.create({ component: ViewEventPage, - componentProps: { + componentProps:{ eventId: Id }, cssClass: 'modal modal-desktop', @@ -575,7 +575,7 @@ export class SearchPage implements OnInit { await modal.present(); modal.onDidDismiss().then((res)=>{}); - } else if(this.type == "AccoesPresidenciais") { + } else if(this.type == "AccoesPresidenciais"){ this.viewPublicationDetail(Id); } @@ -585,8 +585,6 @@ export class SearchPage implements OnInit { } - } else { - console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', this.select) } }