mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
146 lines
3.5 KiB
TypeScript
146 lines
3.5 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
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 { EventsService } from 'src/app/services/events.service';
|
|
import { Event } from '../../../models/event.model';
|
|
import { AttendeesPage } from '../../events/attendees/attendees.page';
|
|
|
|
@Component({
|
|
selector: 'app-edit-event',
|
|
templateUrl: './edit-event.page.html',
|
|
styleUrls: ['./edit-event.page.scss'],
|
|
})
|
|
export class EditEventPage implements OnInit {
|
|
|
|
postEvent: Event;
|
|
isRecurring:string;
|
|
isEventEdited: boolean;
|
|
loadedEvent: Event;
|
|
eventBody: EventBody;
|
|
segment:string = "true";
|
|
profile:string;
|
|
eventAttendees: EventPerson[];
|
|
selectedSegment: string;
|
|
selectedDate: Date;
|
|
minDate: string;
|
|
|
|
|
|
taskParticipants: any = [];
|
|
taskParticipantsCc: any = [];
|
|
adding: "intervenient" | "CC" = "intervenient";
|
|
|
|
constructor(
|
|
private modalController: ModalController,
|
|
private navParams: NavParams,
|
|
private eventsService: EventsService,
|
|
private alertService: AlertService,
|
|
public alertController: AlertController,
|
|
) {
|
|
this.isEventEdited = false;
|
|
this.postEvent = this.navParams.get('event');
|
|
|
|
this.taskParticipants = [];
|
|
this.taskParticipantsCc = [];
|
|
|
|
if(this.postEvent.Attendees == null){
|
|
this.taskParticipants = []
|
|
} else {
|
|
this.taskParticipants = this.postEvent.Attendees;
|
|
}
|
|
|
|
this.taskParticipantsCc = [];
|
|
|
|
if(this.postEvent.IsRecurring == false){
|
|
this.isRecurring = "Não se repete";
|
|
}
|
|
else{
|
|
this.isRecurring = "Repete";
|
|
}
|
|
this.profile = this.navParams.get('profile');
|
|
}
|
|
|
|
ngOnInit() {
|
|
|
|
window.onresize = (event) => {
|
|
// if not mobile remove all component
|
|
if( window.innerWidth >= 800){
|
|
this.modalController.dismiss();
|
|
}
|
|
};
|
|
|
|
}
|
|
close(){
|
|
this.modalController.dismiss();
|
|
}
|
|
save(){
|
|
console.log(this.postEvent);
|
|
|
|
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);
|
|
}
|
|
|
|
async openAttendees()
|
|
{
|
|
|
|
this.adding = 'intervenient';
|
|
|
|
if(window.innerWidth == 1024) {
|
|
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.setIntervenient(newattendees);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
|
|
async dynamicSetIntervenient(data){
|
|
this.taskParticipants = data['taskParticipants'];
|
|
this.taskParticipantsCc = data['taskParticipantsCc'];
|
|
}
|
|
|
|
async setIntervenient(data){
|
|
this.taskParticipants = data;
|
|
|
|
this.postEvent.Attendees = data;
|
|
}
|
|
|
|
async setIntervenientCC(data){
|
|
this.taskParticipantsCc = data;
|
|
}
|
|
|
|
async addParticipants(){
|
|
this.adding = 'intervenient'
|
|
}
|
|
|
|
async addParticipantsCC(){
|
|
this.adding = 'CC'
|
|
}
|
|
|
|
async closeComponent(){}
|
|
}
|