This commit is contained in:
2022-04-02 14:13:37 +01:00
parent c0a500f5e0
commit fa25462897
9 changed files with 409 additions and 104 deletions
@@ -14,6 +14,8 @@ import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expedient
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { ThemeService } from 'src/app/services/theme.service'
import { RouteService } from 'src/app/services/route.service';
import { CalendarService } from 'src/app/store/calendar.service';
import { SessionStore } from 'src/app/store/session.service';
@Component({
@@ -46,6 +48,7 @@ export class ViewEventPage implements OnInit {
@Input() eventId: string;
@Output() viewEventDetailDismiss = new EventEmitter<any>();
sesseionStora = SessionStore
constructor(
private eventsService: EventsService,
@@ -55,7 +58,8 @@ export class ViewEventPage implements OnInit {
private modalController: ModalController,
public popoverController: PopoverController,
private toastService: ToastService,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private CalendarService: CalendarService
) {
this.isEventEdited = false;
this.loadedEvent = new Event();
@@ -97,24 +101,54 @@ export class ViewEventPage implements OnInit {
loadEvent() {
this.eventsService.getEvent(this.eventId).subscribe(res => {
console.log(res);
this.loadedEvent = res;
this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
}, (error)=> {
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.getEvent(this.eventId).subscribe(res => {
console.log(res);
this.loadedEvent = res;
this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
}, (error)=> {
this.viewEventDetailDismiss.emit({
type: 'close'
})
if(error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este evento no modo offline')
} else {
this.toastService.badRequest('Este evento já não existe na sua agenda')
}
});
} else {
this.viewEventDetailDismiss.emit({
type: 'close'
})
if(error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este evento no modo offline')
} else {
this.toastService.badRequest('Este evento já não existe na sua agenda')
const event = this.CalendarService.eventSource.find((ele) => ele.id == this.eventId)
if(event?.CalendarId) {
this.eventsService.genericGetEvent(this.eventId, event.CalendarId).subscribe(res => {
console.log(res);
this.loadedEvent = res;
this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
}, (error)=> {
this.viewEventDetailDismiss.emit({
type: 'close'
})
if(error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este evento no modo offline')
} else {
this.toastService.badRequest('Este evento já não existe na sua agenda')
}
});
}
});
}
}
async deleteEvent() {
@@ -122,24 +156,56 @@ export class ViewEventPage implements OnInit {
if (this.loadedEvent.IsRecurring) {
const loader = this.toastService.loading()
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
this.toastService.successMessage('Evento apagado');
this.close();
},()=>{},
()=>{
loader.remove();
});
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
this.toastService.successMessage('Evento apagado');
this.close();
},()=>{},
()=>{
loader.remove();
});
} else {
const event = this.CalendarService.eventSource.find((ele) => ele.id == this.eventId)
if(event?.CalendarId) {
this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, event?.CalendarId).subscribe(async () => {
this.toastService.successMessage('Evento apagado');
this.close();
},()=>{},
()=>{
loader.remove();
});
}
}
} else {
const loader = this.toastService.loading()
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
this.toastService.successMessage('Evento apagado');
this.close();
},()=>{},
()=>{
loader.remove();
});
} else {
const event = this.CalendarService.eventSource.find((ele) => ele.id == this.eventId)
if(event?.CalendarId) {
this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, event?.CalendarId).subscribe(async () => {
this.toastService.successMessage('Evento apagado');
this.close();
},()=>{},
()=>{
loader.remove();
});
}
}
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
this.toastService.successMessage('Evento apagado');
this.close();
},()=>{},
()=>{
loader.remove();
});
}
}