fix ownertype and category type

This commit is contained in:
Peter Maquiran
2024-06-21 23:33:29 +01:00
parent 558810ab83
commit 0c14b9be97
13 changed files with 90 additions and 531 deletions
@@ -8,7 +8,7 @@
<ion-header>
<div class="title-content">
<div class="middle">
<ion-label id="vsdfajnl" class="title" style="font-size: 21.1px">Editar Evento[]</ion-label>
<ion-label id="vsdfajnl" class="title" style="font-size: 21.1px">Editar Evento</ion-label>
</div>
</div>
</ion-header>
@@ -34,7 +34,7 @@
<div *ngIf="(sharedCalendar | async) as calendarData" class="container-div" >
<div *ngIf="(sharedCalendar | async) as calendarData" class="container-div width-100" >
<div class="ion-item-class-2 d-flex">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
@@ -31,7 +31,7 @@
<div *ngIf="selectedUserCalendar == SessionStore.user.UserId && !hasChangeCalendar && SessionStore.user.Profile != 'PR'" style="margin-bottom: -20px;">
Minha agenda
</div>
<mat-select [(value)]="hasChangeCalendar" (selectionChange)="changeAgenda();changeSegmentCalendar()">
<mat-select [(value)]="selectedUserCalendar" (selectionChange)="changeAgenda();changeSegmentCalendar()">
<mat-option *ngFor="let calendars of calendarData" value="{{calendars.wxUserId}}">
@@ -4,7 +4,6 @@ import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model';
import { SearchList } from 'src/app/models/search-document';
import { LoginUserRespose } from 'src/app/models/user.model';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { EventsService } from 'src/app/services/events.service';
import { ToastService } from 'src/app/services/toast.service';
import { Event } from '../../../models/event.model';
@@ -15,13 +14,11 @@ import { ThemeService } from 'src/app/services/theme.service';
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
import { SessionStore } from 'src/app/store/session.service';
import { ChatMethodsService } from 'src/app/services/chat/chat-methods.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { environment } from 'src/environments/environment';
import { ProcessesService } from 'src/app/services/processes.service';
import { TaskService } from 'src/app/services/task.service'
import { ContactsService } from 'src/app/services/contacts.service';
import { DomSanitizerService } from 'src/app/services/DomSanitizer.service';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, ThemePalette } from '@angular/material/core';
import { MomentDateAdapter } from '@angular/material-moment-adapter';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
@@ -127,17 +124,13 @@ export class NewEventPage implements OnInit {
private modalController: ModalController,
private navParams: NavParams,
public eventService: EventsService,
private attachmentsService: AttachmentsService,
private toastService: ToastService,
public ThemeService: ThemeService,
private platform: Platform,
private chatMethodService: ChatMethodsService,
private hhtpErrorHandle: HttpErrorHandle,
private processeService: ProcessesService,
public TaskService: TaskService,
private contactsService: ContactsService,
private domSanitazerService: DomSanitizerService,
private dateAdapter: DateAdapter<Date>,
private agendaDataRepository: AgendaDataRepositoryService,
public RoleIdService: RoleIdService,
) {
@@ -495,7 +488,6 @@ export class NewEventPage implements OnInit {
return false
}
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
const loader = this.toastService.loading()
@@ -8,7 +8,7 @@
</button>
</div>
<div class="header-title">
<label>Eventos para Aprovação</label>
<label> Eventos para aprovação</label>
</div>
<div style="float:right" *ngIf="showFilter" class="d-flex align-center">
@@ -56,7 +56,7 @@
</mat-form-field>
</div>
<ion-toolbar>
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)" *ngIf="SessionStore.user.RoleID !== 100000014 && (sharedCalendar | async) as calendarData">
<ion-segment [(ngModel)]="selectedUserCalendar" (ionChange)="segmentChanged($event)" *ngIf="SessionStore.user.RoleID !== 100000014 && (sharedCalendar | async) as calendarData">
<!-- <ion-segment-button value="MDGPR">
Minha agenda
</ion-segment-button> -->
@@ -34,7 +34,6 @@ export class EventListPage implements OnInit {
// [desktop] event list to approve
profile: string;
segment: any;
showLoader: boolean;
eventPerson: EventPerson;
eventBody: EventBody;
@@ -62,7 +61,6 @@ export class EventListPage implements OnInit {
selectedUserCalendar:any;
constructor(
private processes: ProcessesService,
private modalController: ModalController,
private router: Router,
private sortService: SortService,
@@ -83,26 +81,6 @@ export class EventListPage implements OnInit {
}
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
}
// select pr by default
const pr = this.eventService.calendarNamesAry.find( e => e.Role == 'Presidente da República')
if(pr) {
this.segment = pr.OwnerUserId
}
this.dynamicSearch()
} else {
this.dynamicSearch()
}
})
this.listSubscription = this.eventoaprovacaostore.registerCallback({
id: import.meta.url,
funx:() => {
@@ -140,26 +118,8 @@ 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()
})
this.sharedCalendar = this.AgendaDataRepositoryService.getShareCalendarItemsLiveWithOrder()
this.setCalendarByDefault();
}
@@ -173,6 +133,9 @@ export class EventListPage implements OnInit {
} else {
this.selectedUserCalendar = SessionStore.user.UserId
}
this.LoadToApproveEvents()
}
ngOnDestroy() {
@@ -180,10 +143,7 @@ export class EventListPage implements OnInit {
}
ngAfterViewInit(): void {
}
ngAfterViewInit(): void {}
reorderList(orderBy: string) {
@@ -197,7 +157,7 @@ export class EventListPage implements OnInit {
if(this.showSearch && this.searchSubject) {
const list = this.eventoaprovacaostore.get(this.segment).filter((task) => {
const list = this.eventoaprovacaostore.get(this.selectedUserCalendar).filter((task) => {
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
subject = subject.toLowerCase();
return subject.includes(this.searchSubject.toLowerCase())
@@ -205,7 +165,7 @@ export class EventListPage implements OnInit {
this.list = this.TaskService.reorderList(this.ordinance, list)
} else {
const list = this.eventoaprovacaostore.get(this.segment)
const list = this.eventoaprovacaostore.get(this.selectedUserCalendar)
this.list = this.TaskService.reorderList(this.ordinance, list)
}
@@ -221,52 +181,59 @@ export class EventListPage implements OnInit {
async LoadToApproveEvents(tracing?: TracingType) {
console.log('aprove event')
this.showLoader = true;
this.skeletonLoader = true
const segment: any = this.segment
let userId;
if(this.segment == 'Meu calendario') {
if(SessionStore.user.Profile == 'PR') {
const segment = this.selectedUserCalendar
if(segment) {
let userId;
if(this.selectedUserCalendar == SessionStore.user.UserId) {
// color
if(SessionStore.user.Profile == 'PR') {
this.color = 'pr'
} else {
this.color = 'mdgpr'
}
userId = SessionStore.user.UserId
} else if(segment) {
this.color = 'pr'
} else {
this.color = 'mdgpr'
userId = this.selectedUserCalendar
}
userId = SessionStore.user.UserId
} else if(segment) {
this.color = 'pr'
userId = segment
}
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
userId,
status: EEventFilterStatus.Pending
}, tracing)
this.skeletonLoader = true
if(allEvents.isOk()) {
tracing.setAttribute('outcome', 'success')
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
userId,
status: EEventFilterStatus.Pending
}, tracing)
if(allEvents.value.length >= 1) {
const eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
this.eventoaprovacaostore.save(segment, eventsList)
} else {
if(allEvents.isOk()) {
tracing.setAttribute('outcome', 'success')
if(allEvents.value.length >= 1) {
const eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
this.eventoaprovacaostore.save(segment, eventsList)
} else {
this.eventoaprovacaostore.save(segment, [])
}
} else {
tracing.setAttribute('outcome', 'failed')
tracing.bugFlag()
if(!isHttpError(allEvents.error)) {
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #4')
}
this.eventoaprovacaostore.save(segment, [])
// this.showLoader = false;
}
} else {
tracing.setAttribute('outcome', 'failed')
tracing.bugFlag()
if(!isHttpError(allEvents.error)) {
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #4')
}
this.eventoaprovacaostore.save(segment, [])
// this.showLoader = false;
this.showLoader = false;
this.skeletonLoader = false
}
this.showLoader = false;
this.skeletonLoader = false
}