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 27ba6a432..f852f03f4 100644 --- a/src/app/pages/agenda/edit-event/edit-event.page.html +++ b/src/app/pages/agenda/edit-event/edit-event.page.html @@ -36,7 +36,7 @@
- { // if not mobile remove all component @@ -102,25 +108,31 @@ export class EditEventPage implements OnInit { this.modalController.dismiss(); } + goBack() { + console.log(this.caller); + this.router.navigate(['/home',this.caller]); + } + save() { - this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc) - try{ this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => { - /* const alert = await this.alertController.create({ - cssClass: 'my-custom-class', - header: 'Evento actualizado', - buttons: ['OK'] - }); - await alert.present(); */ + if(this.initCalendarName != this.postEvent.CalendarName){ + let body = { + "EventId": this.postEvent.EventId, + "CalendarDestinationName": this.postEvent.CalendarName, + } + console.log(body); + await this.eventsService.changeAgenda(body).toPromise(); + } + this.toastService.successMessage(); - this.toastService.successMessage() }, error => { this.toastService.badRequest() }); this.isEventEdited = true; + this.goBack(); this.modalController.dismiss(this.isEventEdited); } catch (error) { @@ -179,7 +191,7 @@ export class EditEventPage implements OnInit { } addParticipantsCC(){ - this.adding = 'CC' + this.adding = 'CC'; this.openAttendees(); } diff --git a/src/app/pages/agenda/view-event/view-event.page.ts b/src/app/pages/agenda/view-event/view-event.page.ts index 0b413e7c6..ee43756f9 100644 --- a/src/app/pages/agenda/view-event/view-event.page.ts +++ b/src/app/pages/agenda/view-event/view-event.page.ts @@ -35,6 +35,7 @@ export class ViewEventPage implements OnInit { profile:string; eventId:string; + caller:string; customDate:any; today:any; @@ -62,8 +63,12 @@ export class ViewEventPage implements OnInit { this.eventBody = { BodyType : "1", Text : ""}; this.loadedEvent.Body = this.eventBody; - this.activatedRoute.paramMap.subscribe(paramMap =>{ - this.eventId = paramMap['params'].eventId; + this.activatedRoute.paramMap.subscribe(params =>{ + this.eventId = params['params'].eventId; + if(params["params"].caller){ + this.caller = (params["params"].caller); + } + }); /* this.activatedRoute.queryParams.subscribe(params => { @@ -76,7 +81,6 @@ export class ViewEventPage implements OnInit { } ngOnInit() { - console.log('Notifi teste '+this.eventId); this.loadEvent(); this.getAttachments(); @@ -136,8 +140,8 @@ export class ViewEventPage implements OnInit { setTimeout(()=>{ alert.dismiss(); }, 1500); + this.goBack(); this.toastService.successMessage('Evento apagado'); - this.close(); }); } @@ -154,11 +158,14 @@ export class ViewEventPage implements OnInit { async editEventDetail() { + console.log(this.caller); + + const modal = await this.modalController.create({ component: EditEventPage, componentProps: { eventId: this.loadedEvent.EventId, - profile: this.profile, + caller: this.caller, }, cssClass: 'modal modal-desktop', @@ -192,7 +199,7 @@ export class ViewEventPage implements OnInit { component: EditEventPage, componentProps:{ event: this.loadedEvent, - profile: this.profile, + caller: this.caller, }, cssClass: classs, }); diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts index c5c4d8f96..a17062b26 100644 --- a/src/app/services/events.service.ts +++ b/src/app/services/events.service.ts @@ -90,11 +90,6 @@ export class EventsService { this.headers = new HttpHeaders(); this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey); - - - - - } /* getAllEvents(startdate:string, enddate:string): Observable{ @@ -297,6 +292,14 @@ export class EventsService { return this.http.put(`${puturl}`, event, options) } + changeAgenda(body:any){ + const puturl = environment.apiURL + 'Calendar/MoveEvent'; + let options = { + headers: this.headers, + }; + return this.http.post(`${puturl}`, body, options); + } + /* postEvent(event:Event, calendarName:string, sharedagenda:string) { const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PostEvent'); diff --git a/src/app/shared/agenda/edit-event/edit-event.page.ts b/src/app/shared/agenda/edit-event/edit-event.page.ts index ed6876d02..82437eff7 100644 --- a/src/app/shared/agenda/edit-event/edit-event.page.ts +++ b/src/app/shared/agenda/edit-event/edit-event.page.ts @@ -25,6 +25,7 @@ export class EditEventPage implements OnInit { isRecurring:string; isEventEdited: boolean; loadedEvent: Event; + initCalendarName: string; eventBody: EventBody; segment:string = "true"; eventAttendees: EventPerson[]; @@ -157,19 +158,16 @@ export class EditEventPage implements OnInit { this.showLoader = true await this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => { - this.showLoader = false - - const alert = await this.alertController.create({ - cssClass: 'my-custom-class', - header: 'Evento actualizado', - buttons: ['OK'] - }); - + if(this.initCalendarName != this.postEvent.CalendarName){ + let body = { + "EventId": this.postEvent.EventId, + "CalendarDestinationName": this.postEvent.CalendarName, + } + console.log(body); + await this.eventsService.changeAgenda(body).toPromise(); + } + this.showLoader = false; this.toastService.successMessage() - setTimeout(()=>{ - alert.dismiss(); - }, 1500); - }, error => { this.showLoader = false