Edit event from home page

This commit is contained in:
Peter Maquiran
2021-04-06 11:28:46 +01:00
parent 016c006edc
commit 38283f2855
9 changed files with 282 additions and 220 deletions
@@ -3,7 +3,6 @@ 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';
@@ -27,6 +26,11 @@ export class EditEventPage implements OnInit {
selectedDate: Date;
minDate: string;
taskParticipants: any = [];
taskParticipantsCc: any = [];
adding: "intervenient" | "CC" = "intervenient";
constructor(
private modalController: ModalController,
private navParams: NavParams,
@@ -36,6 +40,18 @@ export class EditEventPage implements OnInit {
) {
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";
}
@@ -46,8 +62,6 @@ export class EditEventPage implements OnInit {
}
ngOnInit() {
console.log(this.profile);
console.log(this.postEvent);
window.onresize = (event) => {
// if not mobile remove all component
@@ -77,24 +91,50 @@ export class EditEventPage implements OnInit {
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;
}
});
}
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 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(){}
}