Improve search

This commit is contained in:
Peter Maquiran
2021-04-19 15:21:35 +01:00
parent bd2a2fd3f4
commit 8b26ffd9a5
8 changed files with 116 additions and 36 deletions
@@ -2,11 +2,13 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model';
import { EventsService } from 'src/app/services/events.service';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { Event } from 'src/app/models/event.model';
import { ModalController } from '@ionic/angular';
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchDocument } from "src/app/models/search-document";
import { EventAttachment } from 'src/app/models/attachment.model';
@Component({
selector: 'app-new-event',
templateUrl: './new-event.component.html',
@@ -23,7 +25,6 @@ export class NewEventPage implements OnInit {
@Input() selectedDate: Date;
@Input() taskParticipants: EventPerson[];
@Input() taskParticipantsCc: any = [];
@Output() setIntervenient = new EventEmitter<any>();
@Output() setIntervenientCC = new EventEmitter<any>();
@@ -42,6 +43,7 @@ export class NewEventPage implements OnInit {
constructor(
private modalController: ModalController,
private eventService: EventsService,
private attachmentsService: AttachmentsService
) {}
ngOnInit() {
@@ -154,24 +156,70 @@ export class NewEventPage implements OnInit {
save(){
async save(){
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
if(this.documents.length >= 0){
this.postEvent.HasAttachments = true;
}
if(this.profile=='mdgpr') {
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe();
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe(
(id) => {
const eventId: string = id;
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
return {
ParentId: eventId,
Source: '1',
SourceId: e.Id,
ApplicationId: e.ApplicationType.toString(),
Id: '',
Link: '',
SerialNumber: ''
};
});
DocumentToSave.forEach((attachments) => {
this.attachmentsService.setEventAttachmentById(attachments).subscribe();
});
});
}
else if(this.profile=='pr') {
this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe();
this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe(
(id) => {
const eventId: string = id;
const toDocumentTosSave: EventAttachment[] = this.documents.map((e) => {
return {
ParentId: eventId,
Source: '1',
SourceId: e.Id,
ApplicationId: e.ApplicationType.toString(),
};
});
toDocumentTosSave.forEach((attachments) => {
this.attachmentsService.setEventAttachmentById(attachments);
});
});
}
this.deleteTemporaryData();
this.onAddEvent.emit(this.postEvent);
this.GoBackEditOrAdd.emit();
this.gobackOnSave();
}
this.setIntervenient.emit([]);
this.setIntervenientCC.emit([]);
async gobackOnSave(){
//this.onAddEvent.emit(this.postEvent);
//this.GoBackEditOrAdd.emit();
//this.deleteTemporaryData();
//this.setIntervenient.emit([]);
//this.setIntervenientCC.emit([]);
}
@@ -211,7 +259,7 @@ export class NewEventPage implements OnInit {
const restoredData = window['temp.path:/home/agenda/new-event.component.ts']
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData){
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData) {
this.postEvent = restoredData.postEvent
this.eventBody = restoredData.eventBody
this.segment = restoredData.segment