allow to alter agenda

This commit is contained in:
Peter Maquiran
2024-06-21 13:45:06 +01:00
parent 9ea120bfcd
commit 3b6da3d2c7
21 changed files with 1058 additions and 237 deletions
@@ -21,6 +21,9 @@ import { ContactsService } from 'src/app/services/contacts.service';
import { DomSanitizerService } from 'src/app/services/DomSanitizer.service';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { Utils } from 'src/app/services/Repositorys/Agenda/utils';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { Observable } from 'rxjs';
import { RoleIdService } from 'src/app/services/role-id.service'
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -94,6 +97,11 @@ export class EditEventPage implements OnInit {
deletedAttachmentsList = [];
addedAttachmentsList = [];
sharedCalendar: Observable<TableSharedCalendar[]>
hasChangeCalendar = false
selectedUserCalendar:any;
SessionStore = SessionStore
constructor(
private modalController: ModalController,
private navParams: NavParams,
@@ -107,7 +115,8 @@ export class EditEventPage implements OnInit {
private contactsService: ContactsService,
private domSanitazerService: DomSanitizerService,
private agendaDataRepository: AgendaDataRepositoryService,
private utils: Utils
private utils: Utils,
public RoleIdService: RoleIdService,
) {
/* this.postEvent = new Event(); */
@@ -167,9 +176,26 @@ export class EditEventPage implements OnInit {
this.CalendarNameOwnerName = this.eventsService.detectCalendarNameByCalendarId(this.postEvent.CalendarId)
this.changeAgenda()
this.sharedCalendar = this.agendaDataRepository.getShareCalendarItemsLiveWithOrder()
}
hasPrCalendar(data: TableSharedCalendar[]) {
for(const e of data) {
if(e.roleId == this.RoleIdService.PRES) {
return true
}
}
return false
}
changeSegmentCalendar() {
this.hasChangeCalendar = true
}
ngOnInit() {
console.log('this.postEvent', this.postEvent)
this.selectedUserCalendar = this.postEvent.owner.wxUserId
if (!this.postEvent.IsRecurring) {
this.postEvent.EventRecurrence.frequency = 'never'
} else {
@@ -423,42 +449,49 @@ export class EditEventPage implements OnInit {
try {
const events = []
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, editAllEvent).subscribe((value) => {
console.log(value)
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
}, ((error) => {
console.log('edit event error: ', error)
}));
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, editAllEvent, calendar.value).subscribe((value) => {
console.log(value)
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
}, ((error) => {
console.log('edit event error: ', error)
}));
this.agendaDataRepository.addEventAttendee(this.postEvent.EventId, this.postEvent.Attendees).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add Attendee error: ', error)
}));
await this.saveDocument()
if (this.addedAttachmentsList.length > 0) {
this.agendaDataRepository.addEventAttachment(this.postEvent.EventId, this.loadedEventAttachments).subscribe((value) => {
this.agendaDataRepository.addEventAttendee(this.postEvent.EventId, this.postEvent.Attendees).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add attachment error: ', error)
console.log('add Attendee error: ', error)
}));
}
if (this.deletedAttachmentsList.length > 0) {
this.agendaDataRepository.removeEventAttachment(this.postEvent.EventId, { attachments: this.deletedAttachmentsList }).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('remove attachment error: ', error)
}));
await this.saveDocument()
if (this.addedAttachmentsList.length > 0) {
this.agendaDataRepository.addEventAttachment(this.postEvent.EventId, this.loadedEventAttachments).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add attachment error: ', error)
}));
}
if (this.deletedAttachmentsList.length > 0) {
this.agendaDataRepository.removeEventAttachment(this.postEvent.EventId, { attachments: this.deletedAttachmentsList }).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('remove attachment error: ', error)
}));
}
this.isEventEdited = true;
} else {
console.log(calendar.error)
}
this.isEventEdited = true;
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)