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
@@ -46,7 +46,6 @@
<p>
<span class="location">{{loadedEvent.workflowInstanceDataFields.Location}}</span>
{{ loadedEvent.workflowDisplayName }}
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial MDGPR' " style="background-color: #ffb703;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
@@ -69,7 +69,6 @@ export class ApproveEventPage implements OnInit {
ngOnInit() {
this.getTask();
this.getAttachments();
}
@@ -147,15 +146,6 @@ export class ApproveEventPage implements OnInit {
}
async getAttachments() {
try {
this.loadedAttachments = await this.attachmentsService.getAttachmentsById(this.InstanceId).toPromise();
} catch (error) {
console.error('getAttchaments', error)
}
}
async viewDocument(DocId: string, Document) {
@@ -9,33 +9,16 @@
</div>
</div>
<ion-toolbar >
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
<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 [(ngModel)]="selectedUserCalendar" (ionChange)="segmentChanged($event)" *ngIf="SessionStore.user.RoleID !== 100000014 && (sharedCalendar | async) as calendarData">
<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>
</ion-toolbar>
</div>
@@ -54,7 +37,7 @@
<div class="width-100" >
<div
class="item ion-no-padding width-100 cursor-pointer"
*ngFor="let event of eventoaprovacaostore.get(segment)"
*ngFor="let event of eventoaprovacaostore.get(selectedUserCalendar)"
(click)="openApproveModal(event.serialNumber, event)"
>
<div class="event-{{color}}-{{event.workflowInstanceDataFields.Agenda}} width-100">
@@ -11,6 +11,11 @@ import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.servic
import { environment } from 'src/environments/environment';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { EventToApproveList } from 'src/app/models/entiry/agenda/eventToApproveList';
import { RoleIdService } from 'src/app/services/role-id.service'
import { map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
@Component({
selector: 'app-event-list',
templateUrl: './event-list.page.html',
@@ -37,36 +42,55 @@ export class EventListPage implements OnInit {
@Input() showComponent:string;
@Output() cloneAllmobileComponent = new EventEmitter<any>();
@Output() approveEventDismiss = new EventEmitter<any>();
sharedCalendar: Observable<TableSharedCalendar[]>
selectedUserCalendar:any;
constructor(
private processes:ProcessesService,
private router: Router,
private sortService: SortService,
public eventService: EventsService,
public AgendaDataRepositoryService: AgendaDataRepositoryService
public AgendaDataRepositoryService: AgendaDataRepositoryService,
public RoleIdService: RoleIdService,
) {
this.loggeduser = SessionStore.user;
// 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()
})
}
ngAfterViewInit(): void {
this.eventService.onCalendarFinishLoad.subscribe(() => {
if(!this.segment) {
if(this.eventService.calendarNamesAry.includes('Meu calendario')) {
this.segment = 'Meu calendario';
} else {
this.segment = this.eventService.calendarNamesAry[0].OwnerUserId
}
async setCalendarByDefault() {
const data = await this.AgendaDataRepositoryService.geCalendars()
// select pr by default
const pr = this.eventService.calendarNamesAry.find( e => e.Role == 'Presidente da República')
if(pr) {
this.segment = pr.OwnerUserId
}
}
})
const prObject = data.find(e => e?.roleId == 100000014)
if(prObject) {
this.selectedUserCalendar = prObject.wxUserId
} else {
this.selectedUserCalendar = SessionStore.user.UserId
}
}
ngAfterViewInit(): void {}
ngOnInit() {
const pathname = window.location.pathname
@@ -96,11 +120,13 @@ export class EventListPage implements OnInit {
async LoadToApproveEvents() {
this.showLoader = true;
const segment = this.selectedUserCalendar
const segment: any = this.segment
let userId;
if(this.segment == 'Meu calendario') {
if(this.selectedUserCalendar == SessionStore.user.UserId) {
// color
if(SessionStore.user.Profile == 'PR') {
this.color = 'pr'
} else {
@@ -110,7 +136,7 @@ export class EventListPage implements OnInit {
} else if(segment) {
this.color = 'pr'
userId = segment
userId = this.selectedUserCalendar
}
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})
@@ -118,13 +144,12 @@ export class EventListPage implements OnInit {
if(allEvents.value.length >= 1) {
this.eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
this.eventoaprovacaostore.save(segment, this.eventsList)
this.eventoaprovacaostore.save(this.selectedUserCalendar, this.eventsList)
} else {
this.eventoaprovacaostore.save(segment, [])
this.eventoaprovacaostore.save(this.selectedUserCalendar, [])
}
} else {
this.eventsList = [];
// this.showLoader = false;
}
this.showLoader = false;