mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
add calendar list on creating event
This commit is contained in:
@@ -59,6 +59,29 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="(sharedCalendar | async) as calendarData" style="" class="select-calendar">
|
||||
|
||||
|
||||
<!-- Debug line to print data -->
|
||||
<mat-form-field class="select-calendar" appearance="none" color="ion-color-secondary" placeholder="Selecione agenda" *ngIf="calendarData?.length" >
|
||||
<mat-select [(value)]="selectedUserCalendar" >
|
||||
<mat-option *ngFor="let calendars of calendarData" value="{{calendars.wxUserId}}">
|
||||
|
||||
<div *ngIf="calendars.roleId == RoleIdService.PRES">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>
|
||||
|
||||
</mat-option>
|
||||
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="container-div">
|
||||
<div class="ion-item-class-2 d-flex">
|
||||
<div class="ion-icon-class">
|
||||
|
||||
@@ -31,7 +31,7 @@ import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { EventToAprove } from 'src/app/models/eventToAprove.model';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
|
||||
import { TaskService } from 'src/app/services/task.service'
|
||||
import { ContactsService } from 'src/app/services/contacts.service';
|
||||
@@ -39,6 +39,9 @@ import { DomSanitizerService } from 'src/app/services/DomSanitizer.service';
|
||||
import { ChangeProfileService } from 'src/app/services/change-profile.service';
|
||||
import { EventInputDTO } from 'src/app/services/Repositorys/Agenda/agendaDataModels';
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
import { RoleIdService } from 'src/app/services/role-id.service'
|
||||
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
|
||||
parse: {
|
||||
@@ -140,6 +143,12 @@ export class NewEventPage implements OnInit {
|
||||
contacts: EventPerson[] = [];
|
||||
allDayCheck: boolean = false;
|
||||
|
||||
|
||||
sharedCalendar: Observable<TableSharedCalendar[]>
|
||||
selectedUserCalendar:any;
|
||||
SessionStore = SessionStore
|
||||
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
public eventService: EventsService,
|
||||
@@ -154,12 +163,47 @@ export class NewEventPage implements OnInit {
|
||||
private contactsService: ContactsService,
|
||||
private domSanitazerService: DomSanitizerService,
|
||||
private changeProfileService: ChangeProfileService,
|
||||
private agendaDataRepository: AgendaDataRepositoryService
|
||||
private agendaDataRepository: AgendaDataRepositoryService,
|
||||
public RoleIdService: RoleIdService,
|
||||
) {
|
||||
this.dateAdapter.setLocale('pt');
|
||||
this.loggeduser = SessionStore.user;
|
||||
this.postEvent = new Event();
|
||||
|
||||
|
||||
// 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.agendaDataRepository.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.setCalendarByDefault(true)
|
||||
}
|
||||
|
||||
async setCalendarByDefault(force) {
|
||||
if (!this.selectedUserCalendar || force) {
|
||||
|
||||
const data = await this.agendaDataRepository.geCalendars()
|
||||
|
||||
const prObject = data.find(e => e?.roleId == 100000014)
|
||||
if(prObject) {
|
||||
this.selectedUserCalendar = prObject.wxUserId
|
||||
} else {
|
||||
this.selectedUserCalendar = SessionStore.user.UserId
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -429,7 +473,7 @@ export class NewEventPage implements OnInit {
|
||||
cssClass: 'modal-width-100-width-background modal',
|
||||
componentProps: {
|
||||
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
||||
eventAgenda: true,
|
||||
eventAgenda: true,
|
||||
showSearchInput: true,
|
||||
select: true
|
||||
}
|
||||
@@ -552,9 +596,9 @@ export class NewEventPage implements OnInit {
|
||||
loader.remove();
|
||||
}));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* async save() {
|
||||
|
||||
Reference in New Issue
Block a user