mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
remove calendar id
This commit is contained in:
@@ -56,35 +56,18 @@
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<ion-toolbar>
|
||||
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
|
||||
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)" *ngIf="SessionStore.user.RoleID !== 100000014 && (sharedCalendar | async) as calendarData">
|
||||
<!-- <ion-segment-button value="MDGPR">
|
||||
Minha agenda
|
||||
</ion-segment-button> -->
|
||||
|
||||
<ion-segment-button *ngFor="let calendars of eventService.calendarNamesAryPR; let i index" [value]="i === 'Meu calendario' ? 'Meu calendario' : i.OwnerUserId ">
|
||||
<div *ngIf="calendars == 'Meu calendario'">
|
||||
<!-- <span *ngIf="SessionStore.user.Profile == 'PR' ">PR</span>
|
||||
<span *ngIf="SessionStore.user.Profile == 'MDGPR' ">MDGPR</span>
|
||||
<span *ngIf="SessionStore.user.Profile != 'MDGPR' && SessionStore.user.Profile != 'PR' ">Minha agenda</span> -->
|
||||
<ion-segment-button *ngFor="let calendars of calendarData" value="{{calendars.wxUserId}}" >
|
||||
<div *ngIf="calendars.roleId == RoleIdService.PRES">AGENDA DO PR </div>
|
||||
<div *ngIf="calendars.roleId == RoleIdService.MD && calendars.roleId != SessionStore.user.RoleID">AGENDA DO MDGPR</div>
|
||||
<div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName"> Agenda do {{calendars.wxFullName}} </div>
|
||||
<div *ngIf="calendars.wxUserId == SessionStore.user.UserId ">
|
||||
Minha agenda
|
||||
</div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Presidente da República'"> {{ environment.agendaPR}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Ministro e Director do Gabinete do PR'"> {{ environment.agendaVP}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República'"> Agenda do {{calendars.Fullname}} </div>
|
||||
</ion-segment-button>
|
||||
|
||||
<ion-segment-button [class.d-none]="!eventService.HasMdGPR" *ngFor="let calendars of eventService.calendarNamesAryOnlyMD; let i index" [value]="i === 'Meu calendario' ? 'Meu calendario' : i.OwnerUserId ">
|
||||
<div *ngIf="calendars == 'Meu calendario'"> Minha agenda </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Presidente da República'"> {{ environment.agendaPR}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Ministro e Director do Gabinete do PR'"> {{ environment.agendaVP}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República'"> Agenda do {{calendars.Fullname}} </div>
|
||||
</ion-segment-button>
|
||||
|
||||
<ion-segment-button *ngFor="let calendars of eventService.calendarNamesAryNoPrNMD; let i index" [value]="i === 'Meu calendario' ? 'Meu calendario' : i.OwnerUserId ">
|
||||
<div *ngIf="calendars == 'Meu calendario'"> Minha agenda </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Presidente da República'"> {{ environment.agendaPR}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Ministro e Director do Gabinete do PR'"> {{ environment.agendaVP}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República'"> Agenda do {{calendars.Fullname}} </div>
|
||||
</ion-segment-button>
|
||||
|
||||
</ion-segment>
|
||||
|
||||
@@ -15,7 +15,10 @@ import { EventsService } from 'src/app/services/events.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
|
||||
import { RoleIdService } from 'src/app/services/role-id.service'
|
||||
@Component({
|
||||
selector: 'app-event-list',
|
||||
templateUrl: './event-list.page.html',
|
||||
@@ -49,6 +52,8 @@ export class EventListPage implements OnInit {
|
||||
}
|
||||
|
||||
SessionStore = SessionStore;
|
||||
sharedCalendar: Observable<TableSharedCalendar[]>
|
||||
selectedUserCalendar:any;
|
||||
|
||||
constructor(
|
||||
private processes: ProcessesService,
|
||||
@@ -60,7 +65,8 @@ export class EventListPage implements OnInit {
|
||||
private RouteService: RouteService,
|
||||
public eventService: EventsService,
|
||||
public TaskService: TaskService,
|
||||
public AgendaDataRepositoryService: AgendaDataRepositoryService
|
||||
public AgendaDataRepositoryService: AgendaDataRepositoryService,
|
||||
public RoleIdService: RoleIdService,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
@@ -127,8 +133,40 @@ export class EventListPage implements OnInit {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Define the role priorities
|
||||
const rolePriorities: { [key: number]: number } = {
|
||||
100000014: 1, // Presidente da República
|
||||
100000011: 2, // Vice Presidente (example role ID)
|
||||
// Add other roles with their priorities here
|
||||
};
|
||||
|
||||
this.sharedCalendar = this.AgendaDataRepositoryService.getShareCalendarItemsLive().pipe(
|
||||
map(data => data.sort((a, b) => {
|
||||
console.log('Raw data:', data); // Debug line
|
||||
const priorityA = rolePriorities[a.roleId] || Infinity;
|
||||
const priorityB = rolePriorities[b.roleId] || Infinity;
|
||||
return priorityA - priorityB;
|
||||
}))
|
||||
)
|
||||
|
||||
this.eventService.onCalendarFinishLoad.subscribe(async() => {
|
||||
this.setCalendarByDefault()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async setCalendarByDefault() {
|
||||
const data = await this.AgendaDataRepositoryService.geCalendars()
|
||||
|
||||
const prObject = data.find(e => e?.roleId == 100000014)
|
||||
|
||||
if(prObject) {
|
||||
this.selectedUserCalendar = prObject.wxUserId
|
||||
} else {
|
||||
this.selectedUserCalendar = SessionStore.user.UserId
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.listSubscription.delete()
|
||||
|
||||
Reference in New Issue
Block a user