mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
188 lines
4.5 KiB
TypeScript
188 lines
4.5 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ActivatedRoute } from '@angular/router';
|
|
import { EventsService } from 'src/app/services/events.service';
|
|
import { Router } from '@angular/router';
|
|
import { Event } from '../../../models/event.model';
|
|
import { EventBody } from 'src/app/models/eventbody.model';
|
|
import { AlertController, ModalController } from '@ionic/angular';
|
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
|
import { AttendeesPage } from 'src/app/pages/events/attendees/attendees.page';
|
|
import { AlertService } from 'src/app/services/alert.service';
|
|
import { Attachment } from 'src/app/models/attachment.model';
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
|
|
@Component({
|
|
selector: 'app-event-detail',
|
|
templateUrl: './event-detail.page.html',
|
|
styleUrls: ['./event-detail.page.scss'],
|
|
})
|
|
export class EventDetailPage implements OnInit {
|
|
|
|
loadedEvent: Event;
|
|
loadedEventAttachments: Attachment[];
|
|
pageId: string;
|
|
showLoader: boolean;
|
|
backURL: string;
|
|
|
|
minDate: Date;
|
|
|
|
|
|
constructor(public alertController: AlertController,
|
|
private router: Router, private activatedRoute: ActivatedRoute,
|
|
private eventsService: EventsService, private modalCtrl: ModalController,
|
|
private alertService: AlertService,
|
|
private attachamentsService: AttachmentsService) {
|
|
this.loadedEvent = new Event();
|
|
this.loadedEvent.Body = new EventBody();
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.loadEvent();
|
|
this.loadAttachments();
|
|
}
|
|
|
|
loadEvent()
|
|
{
|
|
let eventid: string;
|
|
|
|
this.activatedRoute.paramMap.subscribe(paramMap =>
|
|
{
|
|
if (!paramMap.has("eventId"))
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
this.pageId = paramMap.get('eventId');
|
|
eventid = paramMap.get('eventId');
|
|
}
|
|
|
|
if (paramMap.has("caller"))
|
|
{
|
|
this.backURL = "/home/" + paramMap.get('caller');
|
|
}
|
|
}
|
|
);
|
|
|
|
this.eventsService.getEvent(eventid).subscribe(response =>
|
|
{
|
|
this.loadedEvent = response;
|
|
});
|
|
}
|
|
|
|
async openAttendees()
|
|
{
|
|
const modal = await this.modalCtrl.create({
|
|
component: AttendeesPage,
|
|
componentProps: {
|
|
eventAttendees: this.loadedEvent.Attendees
|
|
},
|
|
cssClass: 'attendee',
|
|
backdropDismiss: false
|
|
});
|
|
|
|
await modal.present();
|
|
|
|
modal.onDidDismiss().then((data) => {
|
|
if (data['data'] != null)
|
|
{
|
|
let newattendees: EventPerson[] = data['data'];
|
|
this.loadedEvent.Attendees = newattendees;
|
|
}
|
|
});
|
|
}
|
|
|
|
getEventAttendees(): EventPerson[]
|
|
{
|
|
return this.loadedEvent.Attendees;
|
|
}
|
|
|
|
setEventAttendees(newattendes: EventPerson[])
|
|
{
|
|
this.loadedEvent.Attendees = newattendes;
|
|
}
|
|
|
|
async deleteConfirm()
|
|
{
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
header: 'Apagar evento!',
|
|
message: 'Deseja <strong>apagar</strong> o evento da agenda ' + this.loadedEvent.CalendarName + '?',
|
|
buttons: [
|
|
{
|
|
text: 'Não',
|
|
role: 'cancel',
|
|
cssClass: 'secondary',
|
|
handler: () => { }
|
|
}, {
|
|
text: 'Sim',
|
|
handler: () => {
|
|
this.Delete();
|
|
}
|
|
}
|
|
]
|
|
});
|
|
|
|
await alert.present();
|
|
}
|
|
|
|
Delete()
|
|
{
|
|
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0).subscribe(async () =>
|
|
{
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
header: 'Evento removido',
|
|
buttons: ['OK']
|
|
});
|
|
|
|
await alert.present();
|
|
|
|
this.router.navigate(['/home/events']);
|
|
});
|
|
}
|
|
|
|
Save()
|
|
{
|
|
this.eventsService.putEvent(this.loadedEvent, 2, 3).subscribe(async () =>
|
|
{
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
header: 'Evento actualizado',
|
|
buttons: ['OK']
|
|
});
|
|
|
|
await alert.present();
|
|
});
|
|
}
|
|
|
|
showAlert(){
|
|
this.alertService.presentAlert("Funcionalidade em desenvolvimento");
|
|
}
|
|
|
|
loadAttachments()
|
|
{
|
|
console.log(this.pageId);
|
|
this.attachamentsService.getEventAttachments(this.pageId).subscribe(attachments => {
|
|
this.loadedEventAttachments = attachments;
|
|
console.log(attachments);
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
back()
|
|
{
|
|
//this.back();
|
|
}
|
|
doRefresh(event){
|
|
/* this.RefreshEvents(); */
|
|
event.target.complete();
|
|
setTimeout(() => {
|
|
event.target.complete();
|
|
}, 2000);
|
|
|
|
}
|
|
}
|