diff --git a/src/app/pages/agenda/new-event/new-event.page.ts b/src/app/pages/agenda/new-event/new-event.page.ts
index 7a8277286..241e22819 100644
--- a/src/app/pages/agenda/new-event/new-event.page.ts
+++ b/src/app/pages/agenda/new-event/new-event.page.ts
@@ -82,11 +82,12 @@ export class NewEventPage implements OnInit {
autoStartTime;
autoEndTime;
+ CalendarNamesOptions = ['Oficial', 'Pessoal']
constructor(
private modalController: ModalController,
private navParams: NavParams,
- private eventService: EventsService,
+ public eventService: EventsService,
private attachmentsService: AttachmentsService,
private toastService: ToastService,
userService: AuthService,
@@ -297,23 +298,21 @@ export class NewEventPage implements OnInit {
try {
-
+ const CalendarId = this.selectedCalendarId()
if(this.loggeduser.Profile == 'MDGPR') {
-
-
-
- eventId = await this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).toPromise();
-
-
+ eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
+
}
else if(this.loggeduser.Profile == 'PR') {
-
- eventId = await this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).toPromise();
+ const CalendarId = this.selectedCalendarId()
+ eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
} else {
- eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName).toPromise();
+
+ const CalendarId = this.selectedCalendarId()
+ eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
}
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
@@ -351,6 +350,44 @@ export class NewEventPage implements OnInit {
}
+
+ selectedCalendarId () {
+
+ if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) {
+ return this.eventService.calendarNamesType[this.CalendarName]['OficialId']
+
+ } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) {
+
+ return this.eventService.calendarNamesType[this.CalendarName]['PessoalId']
+
+ } else {
+ return '11:11'
+ }
+ }
+
+ changeAgenda() {
+
+ setTimeout(() => {
+
+ if(this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) {
+
+ this.CalendarNamesOptions = ['Oficial', 'Pessoal']
+
+ } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) {
+ this.CalendarNamesOptions = ['Oficial']
+ this.postEvent.CalendarName = 'Oficial'
+
+ } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) {
+ this.CalendarNamesOptions = ['Pessoal']
+ this.postEvent.CalendarName = 'Pessoal'
+
+ } else {
+ this.CalendarNamesOptions = ['Oficial', 'Pessoal']
+ }
+ }, 50)
+
+ }
+
async openAttendees() {
const modal = await this.modalController.create({
diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts
index 4e733933e..90602818c 100644
--- a/src/app/services/auth.service.ts
+++ b/src/app/services/auth.service.ts
@@ -137,7 +137,7 @@ export class AuthService {
SessionStore.reset(session)
this.ValidatedUser = SessionStore.user;
- console.log('!!!::!!===', this.ValidatedUser)
+ // console.log('!!!::!!===', this.ValidatedUser)
this.storageService.store(AuthConnstants.USER, response);
return true;
diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts
index f2cc203fd..353e088c7 100644
--- a/src/app/services/events.service.ts
+++ b/src/app/services/events.service.ts
@@ -55,6 +55,11 @@ export class EventsService {
userCalendarNameOwnPessoal = '';
calendarNames = {}
+
+ calendarNamesAry = []
+ calendarNamesType = {}
+
+ myCalendarNames = {}
constructor(
private http: HttpClient,
@@ -118,6 +123,10 @@ export class EventsService {
this.userCalendarNameOwnPessoal = '';
this.calendarIds = [];
+ this.calendarNames = {}
+
+ this.calendarNamesAry = []
+ this.calendarNamesType = {}
if (this.loggeduser) {
if (this.loggeduser.Profile == 'MDGPR') {
@@ -189,8 +198,6 @@ export class EventsService {
});
}
-
-
this.loggeduser.OwnerCalendars.forEach(calendar => {
if(!this.calendarIds.includes(calendar.OwnerUserId)) {
@@ -250,22 +257,42 @@ export class EventsService {
if(sharedCalendar?.OwnerUserId) {
this.GetCalendarName(sharedCalendar.OwnerUserId).subscribe((e)=> {
this.calendarNames[sharedCalendar.CalendarId] = e.FullName
+ this.myCalendarNames[sharedCalendar.CalendarId] = e.FullName
+
+ if(!this.calendarNamesAry.includes(e.FullName)) {
+ this.calendarNamesAry.push(e.FullName)
+ this.calendarNamesType[e.FullName] = {}
+ }
+
+ this.calendarNamesType[e.FullName][sharedCalendar.CalendarName] = true
+ this.calendarNamesType[e.FullName][sharedCalendar.CalendarName+'Id'] = sharedCalendar.CalendarId
+
})
}
}
for (let sharedCalendar of this.loggeduser.OwnerCalendars) {
- if(sharedCalendar?.OwnerUserId) {
- this.GetCalendarName(sharedCalendar.OwnerUserId).subscribe((e)=> {
- this.calendarNames[sharedCalendar.CalendarId] = e.FullName
- })
+
+ this.calendarNames[sharedCalendar.CalendarId] = 'Meu calendario'
+
+ if(!this.calendarNamesAry.includes('Meu calendario')) {
+ this.calendarNamesAry.push('Meu calendario')
+ this.calendarNamesType['Meu calendario'] = {}
}
+
+ this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName] = true
+ this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName+'Id'] = sharedCalendar.CalendarId
}
}
}
}
+
+ isMyCalendar(CalendarId) {
+ return this.myCalendarNames[CalendarId] || ""
+ }
+
getCalendarOwnNameByCalendarId(CalendarId) {
return this.calendarNames[CalendarId] || ""
}
@@ -787,7 +814,7 @@ export class EventsService {
- postEventGeneric(event: Event, calendarName: string) {
+ postEventGeneric(event: Event, calendarName: string, CalendarId) {
const puturl = environment.apiURL + 'Calendar/PostEvent';
let params = new HttpParams();
@@ -795,48 +822,27 @@ export class EventsService {
let options: any;
+ const headers = [
+ this.headerSharedOficial,
+ this.headerSharedPessoal,
+ this.headerOwnPessoal,
+ this.headerOwnOficial
+ ]
- if(this.hasOwnCalendar) {
- switch (calendarName) {
- case 'Oficial':
- options = {
- headers: this.headerOwnOficial,
- params: params
- };
- break;
-
- case 'Pessoal':
-
- options = {
- headers: this.headerOwnPessoal,
- params: params
- };
- break;
- }
- } else {
- switch (calendarName) {
- case 'Oficial':
- options = {
- headers: this.headerSharedOficial,
- params: params
- };
- break;
-
- case 'Pessoal':
-
- options = {
- headers: this.headerSharedPessoal,
- params: params
- };
- break;
- }
- }
-
-
+ const header = headers.find((header)=> {
+ return header?.get('CalendarId')?.includes(CalendarId)
+ })
+ options = {
+ headers: header,
+ params: params
+ };
+
return this.http.post(`${puturl}`, event, options)
}
+
+
deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) {
let arrayReq = [];
let Object = {
diff --git a/src/app/shared/agenda/new-event/new-event.page.html b/src/app/shared/agenda/new-event/new-event.page.html
index f5c683c3e..c51ac294f 100644
--- a/src/app/shared/agenda/new-event/new-event.page.html
+++ b/src/app/shared/agenda/new-event/new-event.page.html
@@ -28,8 +28,8 @@