Improve documents

This commit is contained in:
Peter Maquiran
2021-07-09 12:50:03 +01:00
parent 01d9c70975
commit cdece357e3
3 changed files with 62 additions and 19 deletions
@@ -261,8 +261,8 @@
</ion-label>
</div>
<div class="d-flex container-div width-100" *ngFor="let document of loadedEventAttachments" >
<ion-list class="width-100 list">
<div class="d-flex container-div width-100" *ngFor="let document of loadedEventAttachments; let i = index" >
<ion-list class="width-100 list" *ngIf="!document.remove">
<ion-item class="width-100">
<ion-label class="width-100">
<p class="d-flex ion-justify-content-between">
@@ -270,7 +270,7 @@
<span class="app-name" *ngIf="document.ApplicationId == '8'"> Correspondencia </span>
<span class="app-name" *ngIf="document.ApplicationId == '386'"> AccoesPresidenciais </span>
<span class="app-name" *ngIf="document.ApplicationId == '361' "> ArquivoDespachoElect </span>
<span class="close-button text-black cursor-pointer" (click)="deleteAttachment(document.Id)" >
<span class="close-button text-black cursor-pointer" (click)="deleteAttachment(document.Id, i)" >
<ion-icon class="font-20" src="assets/images/icons-delete-25.svg"></ion-icon>
</span>
@@ -30,7 +30,7 @@ export class EditEventPage implements OnInit {
segment:string = "true";
eventAttendees: EventPerson[];
// minDate: string;
loadedEventAttachments: Attachment[];
loadedEventAttachments: Attachment[]=[];
public date: any;
public disabled = false;
@@ -221,6 +221,41 @@ export class EditEventPage implements OnInit {
this.clearPostEvent.emit();
this.deleteTemporaryData();
this.close();
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 addParticipants() {
@@ -300,12 +335,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
}
}
@@ -323,21 +363,25 @@ export class EditEventPage implements OnInit {
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: '',
};
}
console.log( this.loadedEventAttachments)
this.loadedEventAttachments.push(ApplicationIdDocumentToSave)
await this.attachmentsService.setEventAttachmentById(DocumentToSave).subscribe(()=>{
this.getAttachments(this.postEvent.EventId);
});
}
});
@@ -27,7 +27,6 @@ export class EventListPage implements OnInit {
@Output() approveEventDismiss = new EventEmitter<any>();
constructor(
private processes:ProcessesService,
private modalController: ModalController,