remove calendar id

This commit is contained in:
Peter Maquiran
2024-06-07 10:26:26 +01:00
parent 07c0223ed2
commit 59d0881669
15 changed files with 274 additions and 246 deletions
+16 -18
View File
@@ -54,28 +54,28 @@
margin-right: 10px;"
class="select-calendar">
{{ selectedUserCalendar }}
<!-- Debug line to print data -->
<mat-form-field class="select-calendar" appearance="none" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="selectedUserCalendar" (selectionChange)="reloadCalendar()" *ngIf="calendarData?.length">
<mat-form-field class="select-calendar" appearance="none" color="ion-color-secondary" placeholder="Selecione agenda" *ngIf="calendarData?.length && showCalendarField">
<mat-select [(value)]="selectedUserCalendar" (selectionChange)="reloadCalendar()" >
<mat-option *ngFor="let calendars of calendarData" value="{{calendars.wxUserId}}">
<div *ngIf="environment.presidential">
<div *ngIf="calendars.roleId == RoleIdService.PRES"> PR </div>
<div *ngIf="calendars.roleId == RoleIdService.MD"> MDGPR </div>
<div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.roleId != RoleIdService.PRES && calendars.roleId != RoleIdService.MD && calendars.wxUserId == SessionStore.user.UserId ">
Minha agenda
</div>
<div *ngIf="environment.presidential">
<div *ngIf="calendars.roleId == RoleIdService.PRES"> PR </div>
<div *ngIf="calendars.roleId == RoleIdService.MD"> MDGPR </div>
<div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.roleId != RoleIdService.PRES && calendars.roleId != RoleIdService.MD && calendars.wxUserId == SessionStore.user.UserId ">
Minha agenda
</div>
</div>
<div *ngIf="!environment.presidential">
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId == RoleIdService.PRES"> {{ environment.agendaPR}} </div>
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId == RoleIdService.MD"> {{ environment.agendaVP}} </div>
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.wxUserId == SessionStore.user.UserId">Minha agenda</div>
</div>
<div *ngIf="!environment.presidential">
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId == RoleIdService.PRES"> {{ environment.agendaPR}} </div>
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId == RoleIdService.MD"> {{ environment.agendaVP}} </div>
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.wxUserId == SessionStore.user.UserId">Minha agenda</div>
</div>
</mat-option>
@@ -224,8 +224,6 @@
<div class="ss-timeline timeline-mobile flex-grow-1 pr-10 text-black height-100 width-100 overflow-y-auto" >
{{ TimelineMDList | json }}
<div *ngFor="let year of TimelineMDList " >
<!-- {{year.yearInfo.yearName}} -->
<div *ngFor="let month of year.months " class="header-day" >
+68 -66
View File
@@ -178,6 +178,8 @@ export class AgendaPage implements OnInit {
sharedCalendar: Observable<TableSharedCalendar[]>
showCalendarField = false
constructor(
@Inject(LOCALE_ID) private locale: string,
private modalCtrl: ModalController,
@@ -193,7 +195,15 @@ export class AgendaPage implements OnInit {
public AgendaDataRepositoryService: AgendaDataRepositoryService,
) {
this.AgendaDataRepositoryService.getSharedCalendar()
this.AgendaDataRepositoryService.getSharedCalendar().then(async ()=> {
this.setCalendarByDefault(true)
const selectedCalendarIds = await this.getSelectedAgendaCalendars();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.reloadCalendar()
this.tigerUpdate()
})
// Define the role priorities
const rolePriorities: { [key: number]: number } = {
@@ -268,17 +278,6 @@ export class AgendaPage implements OnInit {
}
this.weekToShow()
this.eventService.registerOnLoadCalendars(async ()=> {
this.setCalendarByDefault(true)
const selectedCalendarIds = await this.getSelectedAgendaCalendars();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.reloadCalendar()
this.tigerUpdate()
})
}
tigerUpdate() {
@@ -380,6 +379,7 @@ export class AgendaPage implements OnInit {
async setCalendarByDefault(force) {
if (!this.selectedUserCalendar || force) {
const data = await this.AgendaDataRepositoryService.geCalendars()
const prObject = data.find(e => e?.roleId == 100000014)
@@ -389,6 +389,8 @@ export class AgendaPage implements OnInit {
} else {
this.selectedUserCalendar = SessionStore.user.UserId
}
this.showCalendarField = true
}
}
@@ -630,7 +632,6 @@ export class AgendaPage implements OnInit {
this.array = [];
this.rangeStartDate = startTime
this.rangeEndDate = endTime
this.showLoader = true;
this.loadRangeEventRun(startTime, endTime)
}
@@ -662,18 +663,9 @@ export class AgendaPage implements OnInit {
this.rangeStartDate = startTime
this.rangeEndDate = endTime
this.showLoader = true;
const selectedCalendarIds = await this.getSelectedAgendaCalendars()
console.log({selectedCalendarIds})
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
console.log('listToPresent', this.listToPresent)
// this.calendar.currentDate.setDate(1);
this.updateEventListBox()
try {
@@ -681,59 +673,62 @@ export class AgendaPage implements OnInit {
this.myCal.loadEvents();
} catch (error) {}
let load = 0;
for (const selectedCalendar of selectedCalendarIds) {
const response = await this.AgendaDataRepositoryService.EventList({
userId: selectedCalendar.wxUserId,
calendarOwnerName: selectedCalendar.wxFullName,
endDate: endTime.toISOString(),
startDate: startTime.toISOString()
})
if(selectedCalendar.wxUserId) {
this.showLoader = true;
if(response.isOk()) {
let label;
const response = await this.AgendaDataRepositoryService.EventList({
userId: selectedCalendar.wxUserId,
calendarOwnerName: selectedCalendar.wxFullName,
endDate: endTime.toISOString(),
startDate: startTime.toISOString()
})
if (SessionStore.user.Profile == 'PR') {
label = "pr"
} else if (selectedCalendar.wxUserId == SessionStore.user.UserId as any) {
label = 'md'
if(response.isOk()) {
let label;
if (SessionStore.user.Profile == 'PR') {
label = "pr"
} else if (selectedCalendar.wxUserId == SessionStore.user.UserId as any) {
label = 'md'
} else {
label = "pr"
}
this.CalendarStore.removeRangeForCalendar(startTime, endTime, null , selectedCalendar.wxUserId as any)
let eventsList = response.value;
this.CalendarStore.pushEvent(eventsList, label, selectedCalendar.wxUserId);
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.showTimelinePR = true;
load++
if (load ==(selectedCalendarIds).length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.updateEventListBox()
} else {
label = "pr"
load++
if (load == (selectedCalendarIds).length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.updateEventListBox()
}
this.CalendarStore.removeRangeForCalendar(startTime, endTime, null , selectedCalendar.wxUserId as any)
let eventsList = response.value;
this.CalendarStore.pushEvent(eventsList, label, selectedCalendar.wxUserId);
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.showTimelinePR = true;
load++
if (load ==(selectedCalendarIds).length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.updateEventListBox()
} else {
load++
if (load == (selectedCalendarIds).length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.updateEventListBox()
alert('sekip '+ JSON.stringify(selectedCalendar))
console.log('not user', JSON.stringify(selectedCalendar))
}
}
}
@@ -758,7 +753,14 @@ export class AgendaPage implements OnInit {
const data = await this.AgendaDataRepositoryService.geCalendars()
return [data.find(e => e?.wxUserId == this.selectedUserCalendar)]
const array = []
const selected = data.find( e => e.wxUserId == this.selectedUserCalendar)
if(selected) {
array.push(selected)
}
return array
}
}