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
}
}
@@ -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()
+7 -2
View File
@@ -23,6 +23,8 @@ import { CPSession } from 'src/app/store/documentManagement';
import { StorageService } from 'src/app/services/storage.service';
import { DeviceService } from 'src/app/services/device.service'
import { Cy } from 'cypress/enum'
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
@@ -62,7 +64,8 @@ export class LoginPage implements OnInit {
private storage: Storage,
private storageService: StorageService,
private NotificationHolderService: NotificationHolderService,
private DeviceService: DeviceService
private DeviceService: DeviceService,
public AgendaDataRepositoryService: AgendaDataRepositoryService,
) { }
ngOnInit() { }
@@ -137,7 +140,9 @@ export class LoginPage implements OnInit {
loader.remove()
if (attempt) {
if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt);
@@ -147,7 +152,7 @@ export class LoginPage implements OnInit {
if (attempt.ChatData) {
try {
await this.AgendaDataRepositoryService.getSharedCalendar()
await MessageModel.deleteAll();
await DeleteMessageModel.deleteAll();
this.ChatSystemService.clearChat();
@@ -53,7 +53,8 @@ export class AgendaDataRepositoryService {
}
async EventList({userId = null, startDate = null, endDate = null, status= 2, category= null, type= null, calendarOwnerName = ''}) {
async EventList({userId, startDate , endDate , status= 2, category= null, type= null, calendarOwnerName = ''}) {
try {
const result = await this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
map((response) => {
@@ -177,6 +178,19 @@ export class AgendaDataRepositoryService {
if(result.isOk()) {
await this.agendaLocalDataSourceService.clearSharedCalendar()
if(result.value?.data) {
const currentUserCalendar = {
wxUserId: SessionStore.user.UserId,
wxFullName: SessionStore.user.FullName,
wxeMail: SessionStore.user.Email,
role: SessionStore.user.RoleDescription,
roleId: SessionStore.user.RoleID,
shareType: 0,
date: '',
}
result.value.data.push(currentUserCalendar)
return await this.agendaLocalDataSourceService.bulkCreate(result.value.data)
} else {
return result
@@ -41,7 +41,7 @@ export class AgendaDataService {
}
// Events Endpoints
createEvent(eventData: EventInputDTO): Observable<any> {
createEvent(eventData: EventInputDTO) {
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
}
@@ -50,6 +50,10 @@ export class AgendaDataService {
.set('UserId', userId)
.set('Status', status)
if(userId == null || userId == undefined) {
throw('userId '+ userId)
}
if (startDate !== null && startDate !== undefined) {
params = params.set('startDate', startDate);
}
@@ -27,7 +27,6 @@ export function APIReturn(schema: z.ZodTypeAny) {
Sentry.captureException(error);
});
console.error('Validation failed:', error.errors);
} else {
console.log('failed to setup the connection successful')
// Throw any other unexpected errors
+3 -13
View File
@@ -11,6 +11,7 @@ import { catchError } from "rxjs/operators";
import { SessionStore } from '../store/session.service';
import { calendarInterface } from '../models/user.model';
import { Subscribe } from './subcribe';
import { EventOutputDTO } from './Repositorys/Agenda/model/eventDTOOutput';
@Injectable({
@@ -418,19 +419,8 @@ export class EventsService {
isMyEvent(event: any) {
for (let calendar of SessionStore.user.OwnerCalendars) {
if(event.CalendarId == calendar.CalendarId) {
return true
}
}
for (let sharedCalendar of SessionStore.user.SharedCalendars) {
if(event.CalendarId == sharedCalendar.CalendarId) {
return false
}
}
return false
const data: any = event
return data.Organizer.Id == SessionStore.user.UserId
}
@@ -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;
@@ -9,42 +9,42 @@
<ion-icon class="mr-10 font-25" src="assets/images/theme/gov/crescente.svg" ></ion-icon>
</div>
<div class="d-flex" (click)="reorderList('recent')" *ngIf="ordinance != 'recent' ">
<ion-icon class="mr-10 font-25" src="assets/images/theme/gov/decrescente.svg" ></ion-icon>
</div>
</div>
<div>
<mat-form-field class="task-filter-input" appearance="none" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="filterName">
<mat-option value="Para hoje" >
Para hoje
</mat-option>
<mat-option value="Novos" >
Novas
</mat-option>
<mat-option value="Lidos" >
Lidas
</mat-option>
<mat-option value="Não lidos" >
Não lidas
</mat-option>
<mat-option value="OverdueTasks">
Em atraso
</mat-option>
<mat-option value="Todos" >
Todas
</mat-option>
</mat-select>
</mat-form-field>
</div>
@@ -53,35 +53,17 @@
</div>
<ion-toolbar>
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)" >
<!-- <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 [(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>
@@ -13,6 +13,10 @@ import { environment } from 'src/environments/environment';
import { TaskService } from 'src/app/services/task.service'
import { ThemeService } from 'src/app/services/theme.service'
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { map } from 'rxjs/operators';
import { RoleIdService } from 'src/app/services/role-id.service'
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { Observable } from 'rxjs';
@Component({
selector: 'app-events-to-approve',
@@ -26,7 +30,7 @@ export class EventsToApprovePage implements OnInit {
eventBody: EventBody;
categories: string[];
serialnumber:string;
segment:any;
selectedUserCalendar:any;
eventaprovacaostore = EventoAprovacaoStore;
eventsList: any = []
@@ -47,7 +51,7 @@ export class EventsToApprovePage implements OnInit {
}
routerSubscription;
SessionStore = SessionStore;
sharedCalendar: Observable<TableSharedCalendar[]>
constructor(
private processes:ProcessesService,
@@ -58,31 +62,31 @@ export class EventsToApprovePage implements OnInit {
public eventService: EventsService,
public TaskService: TaskService,
public ThemeService: ThemeService,
public AgendaDataRepositoryService: AgendaDataRepositoryService
public AgendaDataRepositoryService: AgendaDataRepositoryService,
public RoleIdService: RoleIdService,
)
{}
ngOnInit() {
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
}
// 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
};
// 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.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.LoadToApproveEvents()
@@ -116,6 +120,18 @@ export class EventsToApprovePage implements OnInit {
this.dynamicSearch();
}
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()
@@ -135,7 +151,7 @@ export class EventsToApprovePage 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())
@@ -143,7 +159,7 @@ export class EventsToApprovePage 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)
}
@@ -176,11 +192,11 @@ export class EventsToApprovePage implements OnInit {
async LoadToApproveEvents() {
this.showLoader = true;
const segment = this.segment
const segment = this.selectedUserCalendar
let userId;
if(this.segment == 'Meu calendario') {
if(this.selectedUserCalendar == SessionStore.user.UserId) {
// color
if(SessionStore.user.Profile == 'PR') {
this.color = 'pr'
@@ -191,7 +207,7 @@ export class EventsToApprovePage implements OnInit {
} else {
this.color = 'pr'
userId = segment
userId = this.selectedUserCalendar
}
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})