mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 05:45:50 +00:00
96 lines
2.5 KiB
TypeScript
96 lines
2.5 KiB
TypeScript
|
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||
|
|
import { ModalController } from '@ionic/angular';
|
||
|
|
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 { Event } from 'src/app/models/event.model';
|
||
|
|
import { AttendeesPage } from 'src/app/pages/events/attendees/attendees.page';
|
||
|
|
import { AlertController, NavParams } from '@ionic/angular';
|
||
|
|
import { AlertService } from 'src/app/services/alert.service';
|
||
|
|
|
||
|
|
|
||
|
|
@Component({
|
||
|
|
selector: 'app-edit-event',
|
||
|
|
templateUrl: './edit-event.component.html',
|
||
|
|
styleUrls: ['./edit-event.component.scss'],
|
||
|
|
})
|
||
|
|
export class EditEventComponent implements OnInit {
|
||
|
|
|
||
|
|
stEvent: Event;
|
||
|
|
isRecurring:string;
|
||
|
|
isEventEdited: boolean;
|
||
|
|
loadedEvent: Event;
|
||
|
|
eventBody: EventBody;
|
||
|
|
segment:string = "true";
|
||
|
|
eventAttendees: EventPerson[];
|
||
|
|
minDate: string;
|
||
|
|
|
||
|
|
@Input() profile:string;
|
||
|
|
@Input() selectedSegment: string;
|
||
|
|
@Input() postEvent: any;
|
||
|
|
|
||
|
|
|
||
|
|
@Output() cloneAllmobileComponent = new EventEmitter<any>();
|
||
|
|
|
||
|
|
|
||
|
|
constructor(
|
||
|
|
private modalController: ModalController,
|
||
|
|
private eventsService: EventsService,
|
||
|
|
public alertController: AlertController,
|
||
|
|
) {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
ngOnInit() {
|
||
|
|
this.isEventEdited = false;
|
||
|
|
|
||
|
|
if(this.postEvent.IsRecurring == false){
|
||
|
|
this.isRecurring = "Não se repete";
|
||
|
|
}
|
||
|
|
else{
|
||
|
|
this.isRecurring = "Repete";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
close(){
|
||
|
|
// this.modalController.dismiss();
|
||
|
|
this.cloneAllmobileComponent.emit();
|
||
|
|
}
|
||
|
|
save(){
|
||
|
|
|
||
|
|
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();
|
||
|
|
});
|
||
|
|
this.isEventEdited = true;
|
||
|
|
// this.modalController.dismiss(this.isEventEdited);
|
||
|
|
this.cloneAllmobileComponent.emit(this.isEventEdited);
|
||
|
|
}
|
||
|
|
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|