2021-01-29 09:45:27 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-01-31 01:40:19 +01:00
|
|
|
import { AlertController, ModalController, NavParams } from '@ionic/angular';
|
|
|
|
|
import { EventBody } from 'src/app/models/eventbody.model';
|
|
|
|
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
|
|
|
|
import { AlertService } from 'src/app/services/alert.service';
|
|
|
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
|
|
|
import { EventsService } from 'src/app/services/events.service';
|
|
|
|
|
import { Event } from '../../../models/event.model';
|
|
|
|
|
import { AttendeesPage } from '../../events/attendees/attendees.page';
|
2021-01-29 09:45:27 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-edit-event',
|
|
|
|
|
templateUrl: './edit-event.page.html',
|
|
|
|
|
styleUrls: ['./edit-event.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class EditEventPage implements OnInit {
|
|
|
|
|
|
2021-01-31 01:40:19 +01:00
|
|
|
postEvent: Event;
|
|
|
|
|
isRecurring:string;
|
|
|
|
|
isEventEdited: boolean;
|
|
|
|
|
loadedEvent: Event;
|
|
|
|
|
eventBody: EventBody;
|
|
|
|
|
segment:string = "true";
|
|
|
|
|
profile:string;
|
|
|
|
|
eventAttendees: EventPerson[];
|
|
|
|
|
selectedSegment: string;
|
|
|
|
|
selectedDate: Date;
|
|
|
|
|
minDate: string;
|
|
|
|
|
|
2021-01-29 09:45:27 +01:00
|
|
|
constructor(
|
|
|
|
|
private modalController: ModalController,
|
2021-01-31 01:40:19 +01:00
|
|
|
private navParams: NavParams,
|
|
|
|
|
private eventsService: EventsService,
|
|
|
|
|
private alertService: AlertService,
|
|
|
|
|
public alertController: AlertController,
|
|
|
|
|
) {
|
|
|
|
|
this.isEventEdited = false;
|
|
|
|
|
this.postEvent = this.navParams.get('event');
|
|
|
|
|
if(this.postEvent.IsRecurring == false){
|
|
|
|
|
this.isRecurring = "Não se repete";
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.isRecurring = "Repete";
|
|
|
|
|
}
|
|
|
|
|
this.profile = this.navParams.get('profile');
|
|
|
|
|
}
|
2021-01-29 09:45:27 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-01-31 01:40:19 +01:00
|
|
|
console.log(this.profile);
|
|
|
|
|
console.log(this.postEvent);
|
|
|
|
|
|
2021-01-29 09:45:27 +01:00
|
|
|
}
|
|
|
|
|
close(){
|
2021-01-31 01:40:19 +01:00
|
|
|
this.modalController.dismiss();
|
2021-01-29 09:45:27 +01:00
|
|
|
}
|
|
|
|
|
save(){
|
2021-01-31 01:40:19 +01:00
|
|
|
console.log(this.postEvent);
|
2021-01-29 09:45:27 +01:00
|
|
|
|
2021-01-31 01:40:19 +01:00
|
|
|
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();
|
|
|
|
|
});
|
2021-02-01 09:17:38 +01:00
|
|
|
this.isEventEdited = true;
|
2021-01-31 01:40:19 +01:00
|
|
|
this.modalController.dismiss(this.isEventEdited);
|
2021-01-29 09:45:27 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-31 01:40:19 +01:00
|
|
|
async openAttendees()
|
|
|
|
|
{
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: AttendeesPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
eventAttendees: this.postEvent.Attendees
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'attendee',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await modal.present();
|
|
|
|
|
|
|
|
|
|
modal.onDidDismiss().then((data) => {
|
|
|
|
|
if (data['data'] != null)
|
|
|
|
|
{
|
|
|
|
|
let newattendees: EventPerson[] = data['data'];
|
|
|
|
|
this.postEvent.Attendees = newattendees;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-29 09:45:27 +01:00
|
|
|
}
|