allow to alter agenda

This commit is contained in:
Peter Maquiran
2024-06-21 13:45:06 +01:00
parent 9ea120bfcd
commit 3b6da3d2c7
21 changed files with 1058 additions and 237 deletions
@@ -372,39 +372,44 @@ export class EditEventToApprovePage implements OnInit {
try {
/* await this.eventsService.postEventToApproveEdit(event).toPromise() */
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event, false).subscribe((value) => {
console.log(value)
this.close()
const calendar = await this.agendaDataRepository.getCalendarByUserId((this.eventProcess as any).owner.wxUserId)
if(calendar.isOk()) {
}, ((error) => {
console.log('edit event error: ', error)
}));
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event, false, calendar.value).subscribe((value) => {
console.log(value)
this.close()
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, this.eventProcess.workflowInstanceDataFields.ParticipantsList).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add Attendee error: ', error)
}));
}, ((error) => {
console.log('edit event error: ', error)
}));
if (this.addedAttachmentsList.length > 0) {
this.agendaDataRepository.addEventAttachment(this.eventProcess.serialNumber, this.loadedAttachments).subscribe((value) => {
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, this.eventProcess.workflowInstanceDataFields.ParticipantsList).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('add attachment error: ', error)
console.log('add Attendee error: ', error)
}));
}
if (this.deletedAttachmentsList.length > 0) {
this.agendaDataRepository.removeEventAttachment(this.eventProcess.serialNumber, { attachments: this.deletedAttachmentsList }).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('remove attachment error: ', error)
}));
}
if (this.addedAttachmentsList.length > 0) {
this.agendaDataRepository.addEventAttachment(this.eventProcess.serialNumber, this.loadedAttachments).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('add attachment error: ', error)
}));
}
this.httpErrorHandler.httpsSucessMessagge('Editar evento');
if (this.deletedAttachmentsList.length > 0) {
this.agendaDataRepository.removeEventAttachment(this.eventProcess.serialNumber, { attachments: this.deletedAttachmentsList }).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('remove attachment error: ', error)
}));
}
this.httpErrorHandler.httpsSucessMessagge('Editar evento');
}
} catch (e) {
this.httpErrorHandler.httpStatusHandle(e);
@@ -47,21 +47,40 @@
</div>
<!-- <div class="container-div">
<div class="ion-item-class-2 width-100 d-flex">
<div *ngIf="(sharedCalendar | async) as calendarData" class="container-div" >
<div class="ion-item-class-2 d-flex">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div>
<div class="ion-input-class flex-grow-1" >
<ion-input [disabled]=true autocomplete="on" autocorrect="on" spellcheck="true" placeholder="Localização*" [(ngModel)]="CalendarNameOwnerName"></ion-input>
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs " [class.input-error]="Form?.get('CalendarName')?.invalid && validateFrom ">
<mat-form-field appearance="none" class="width-100" color="ion-color-secondary" placeholder="Selecione agenda">
<div *ngIf="selectedUserCalendar == SessionStore.user.UserId && !hasChangeCalendar && SessionStore.user.Profile != 'PR' " style="margin-bottom: -20px;">
Minha agenda
</div>
<div *ngIf="!(selectedUserCalendar == SessionStore.user.UserId && SessionStore.user.Profile != 'PR' ) && !hasChangeCalendar" style="margin-bottom: -20px;">
PR
</div>
<mat-select [(value)]="selectedUserCalendar" (selectionChange)="changeAgenda();changeSegmentCalendar()">
<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 && calendars.wxUserId != SessionStore.user.UserId"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.wxUserId == SessionStore.user.UserId && SessionStore.user.Profile != 'PR'">
Minha agenda
</div>
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
<span class="error ion-padding" >
Campo obrigatório
</span>
</div> -->
</div>
<div *ngIf="Form && validateFrom">
<div *ngIf="Form.get('Location').invalid " class="input-errror-message">
@@ -7,18 +7,18 @@ import { Event } from 'src/app/models/event.model';
import { AlertController } from '@ionic/angular';
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { SearchPage } from 'src/app/pages/search/search.page';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ParticipantsPipe } from 'src/app/pipes/participants.pipe';
import { ThemeService } from 'src/app/services/theme.service'
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { ContactsService } from 'src/app/services/contacts.service'
import { DomSanitizerService } from 'src/app/services/DomSanitizer.service';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { SearchList_v2 } from 'src/app/models/search-document';
import { Utils } from 'src/app/services/Repositorys/Agenda/utils';
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-edit-event',
templateUrl: './edit-event.page.html',
@@ -92,29 +92,47 @@ export class EditEventPage implements OnInit {
public stepSeconds = [1, 5, 10, 15, 20, 25];
private participantsPipe = new ParticipantsPipe()
sesseionStora = SessionStore
SessionStore= SessionStore
CalendarNameOwnerName = ''
CalendarNamesOptions = []
allDayCheck: boolean = false;
addedAttachmentsList = [];
sharedCalendar: Observable<TableSharedCalendar[]>
hasChangeCalendar = false
selectedUserCalendar:any;
constructor(
private modalController: ModalController,
private eventsService: EventsService,
public alertController: AlertController,
private attachmentsService: AttachmentsService,
public ThemeService: ThemeService,
private httpErrorHandle: HttpErrorHandle,
private contactsService: ContactsService,
private domSanitizeService: DomSanitizerService,
private agendaDataRepository: AgendaDataRepositoryService,
private utils: Utils
private utils: Utils,
public RoleIdService: RoleIdService,
) {
this.sharedCalendar = this.agendaDataRepository.getShareCalendarItemsLiveWithOrder()
}
hasPrCalendar(data: TableSharedCalendar[]) {
for(const e of data) {
if(e.roleId == this.RoleIdService.PRES) {
return true
}
}
return false
}
changeSegmentCalendar() {
this.hasChangeCalendar = true
}
ngOnInit() {
console.log('this.postEvent', this.postEvent)
this.selectedUserCalendar = this.postEvent.owner.wxUserId
this.loadedEventAttachments = this.postEvent.Attachments
console.log(this.postEvent.Category)
this._postEvent = this.postEvent
@@ -404,47 +422,57 @@ export class EditEventPage implements OnInit {
}
this._postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.showLoader = true;
try {
this.agendaDataRepository.updateEvent(this._postEvent.EventId, this._postEvent, editAllEvent).subscribe((value) => {
console.log(value)
console.log('this.selectedUserCalendar', this.selectedUserCalendar)
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
this.clearPostEvent.emit();
this.deleteTemporaryData();
this.showLoader = false;
this.close();
if(calendar.isOk()) {
this.showLoader = true;
this.agendaDataRepository.updateEvent(this._postEvent.EventId, this._postEvent, editAllEvent, calendar.value).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('edit event error: ', error)
}));
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
this.clearPostEvent.emit();
this.deleteTemporaryData();
this.showLoader = false;
this.close();
this.agendaDataRepository.addEventAttendee(this._postEvent.EventId, this._postEvent.Attendees).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add Attendee error: ', error)
}));
}, ((error) => {
console.log('edit event error: ', error)
}));
if (this.addedAttachmentsList.length > 0) {
this.agendaDataRepository.addEventAttachment(this._postEvent.EventId, this.loadedEventAttachments).subscribe((value) => {
this.agendaDataRepository.addEventAttendee(this._postEvent.EventId, this._postEvent.Attendees).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('add attachment error: ', error)
console.log('add Attendee error: ', error)
}));
if (this.addedAttachmentsList.length > 0) {
this.agendaDataRepository.addEventAttachment(this._postEvent.EventId, this.loadedEventAttachments).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('add attachment error: ', error)
}));
}
if (this.deletedAttachmentsList.length > 0) {
this.agendaDataRepository.removeEventAttachment(this._postEvent.EventId, { attachments: this.deletedAttachmentsList }).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('remove attachment error: ', error)
}));
}
} else {
console.log('this.selectedUserCalendar', this.selectedUserCalendar)
console.log(calendar.error)
}
if (this.deletedAttachmentsList.length > 0) {
this.agendaDataRepository.removeEventAttachment(this._postEvent.EventId, { attachments: this.deletedAttachmentsList }).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('remove attachment error: ', error)
}));
}
} catch (error) {
@@ -2,46 +2,37 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model';
import { EventsService } from 'src/app/services/events.service';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { Event } from 'src/app/models/event.model';
import { ModalController } from '@ionic/angular';
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchList, SearchList_v2 } from "src/app/models/search-document";
import { EventAttachment, EventAttachment_v2 } from 'src/app/models/attachment.model';
import { SearchList_v2 } from "src/app/models/search-document";
import { ToastService } from 'src/app/services/toast.service';
import { LoginUserRespose } from 'src/app/models/user.model';
import { DateAdapter } from '@angular/material/core';
import * as _moment from 'moment';
import * as _rollupMoment from 'moment';
import { FormControl } from '@angular/forms';
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
import { ThemePalette } from '@angular/material/core';
import { ViewChild } from '@angular/core';
import { FormGroup, Validators } from '@angular/forms';
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
import { ThemeService } from 'src/app/services/theme.service'
import { ChatMethodsService } from 'src/app/services/chat/chat-methods.service';
import { ServerConnectionService } from 'src/app/services/server-connection.service';
import { SessionStore } from 'src/app/store/session.service';
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 { Observable, Subject } from 'rxjs';
import { Observable } from 'rxjs';
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 { 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: {
@@ -151,16 +142,13 @@ export class NewEventPage implements OnInit {
constructor(
private modalController: ModalController,
public eventService: EventsService,
private attachmentsService: AttachmentsService,
private toastService: ToastService,
private dateAdapter: DateAdapter<any>,
public ThemeService: ThemeService,
private chatMethodService: ChatMethodsService,
private hhtpErrorHandle: HttpErrorHandle,
private processeService: ProcessesService,
public TaskService: TaskService,
private contactsService: ContactsService,
private domSanitazerService: DomSanitizerService,
private changeProfileService: ChangeProfileService,
private agendaDataRepository: AgendaDataRepositoryService,
public RoleIdService: RoleIdService,
@@ -169,28 +157,11 @@ export class NewEventPage implements OnInit {
this.loggeduser = SessionStore.user;
this.postEvent = new Event();
this.sharedCalendar = this.agendaDataRepository.getShareCalendarItemsLiveWithOrder()
// 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;
}))
)
}
hasPrCalendar(data: TableSharedCalendar[]) {
for(const e of data) {
if(e.roleId == this.RoleIdService.PRES) {
@@ -218,7 +189,6 @@ export class NewEventPage implements OnInit {
ngOnInit() {
this.setCalendarByDefault(true)
console.log(' INTERVENIENTES', this.taskParticipants)
this.changeProfileService.registerCallback(() => {
this.initializeData()
})
@@ -439,11 +409,11 @@ export class NewEventPage implements OnInit {
}
}
changeSegmentCalendar() {
this.hasChangeCalendar = true
}
changeAgenda() {
this.CalendarNameShow = false
@@ -583,7 +553,7 @@ export class NewEventPage implements OnInit {
}
save_v2() {
async save_v2() {
this.injectValidation()
this.runValidation()
@@ -599,21 +569,21 @@ export class NewEventPage implements OnInit {
let loader = this.toastService.loading();
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.postEvent.IsAllDayEvent = this.allDayCheck;
console.log('evenr rec 1 ',this.eventRecurence)
console.log('eent rec 2 ',this.postEvent.EventRecurrence.frequency)
this.agendaDataRepository.createEvent(this.postEvent, this.selectedUserCalendar, this.documents).subscribe((value) => {
console.log(value)
this.afterSave();
this.hhtpErrorHandle.httpsSucessMessagge('new event')
loader.remove();
}, ((error) => {
console.log('create event error: ', error)
loader.remove();
this.hhtpErrorHandle.httpStatusHandle(error.status)
}));
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value).subscribe((value) => {
console.log(value)
this.afterSave();
this.hhtpErrorHandle.httpsSucessMessagge('new event')
loader.remove();
}, ((error) => {
console.log('create event error: ', error)
loader.remove();
this.hhtpErrorHandle.httpStatusHandle(error.status)
}));
}
}
@@ -270,7 +270,7 @@ export class EditEventToApproveComponent implements OnInit {
this.modalController.dismiss();
}
save() {
async save() {
// set dates to eventProcess object
this.taskParticipantsCc.forEach(e => {
@@ -316,48 +316,46 @@ export class EditEventToApproveComponent implements OnInit {
Category: this.eventProcess.workflowInstanceDataFields.Category
}
const calendar = await this.agendaDataRepository.getCalendarByUserId((this.eventProcess as any).owner.wxUserId)
/* this.eventsService.postEventToApproveEdit(event).subscribe(()=>{
this.httpErroHalde.httpsSucessMessagge('Editar evento')
window['approve-event-getTask']()
}, error => {
this.httpErroHalde.httpStatusHandle(error)
}) */
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event,false, calendar.value).subscribe((value) => {
console.log(value)
this.httpErroHalde.httpsSucessMessagge('Editar evento')
window['approve-event-getTask']()
this.close();
}, ((error) => {
this.httpErroHalde.httpStatusHandle(error)
console.log('edit event error: ', error)
}));
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event,false).subscribe((value) => {
console.log(value)
this.httpErroHalde.httpsSucessMessagge('Editar evento')
window['approve-event-getTask']()
this.close();
}, ((error) => {
this.httpErroHalde.httpStatusHandle(error)
console.log('edit event error: ', error)
}));
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, this.eventProcess.workflowInstanceDataFields.ParticipantsList).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add Attendee error: ', error)
}));
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, this.eventProcess.workflowInstanceDataFields.ParticipantsList).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add Attendee error: ', error)
}));
if (this.addedAttachmentsList.length > 0) {
this.agendaDataRepository.addEventAttachment(this.eventProcess.serialNumber, this.loadedAttachments).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('add attachment error: ', error)
}));
}
if (this.addedAttachmentsList.length > 0) {
this.agendaDataRepository.addEventAttachment(this.eventProcess.serialNumber, this.loadedAttachments).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('add attachment error: ', error)
}));
}
if (this.deletedAttachmentsList.length > 0) {
this.agendaDataRepository.removeEventAttachment(this.eventProcess.serialNumber, { attachments: this.deletedAttachmentsList }).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('remove attachment error: ', error)
}));
}
}
if (this.deletedAttachmentsList.length > 0) {
this.agendaDataRepository.removeEventAttachment(this.eventProcess.serialNumber, { attachments: this.deletedAttachmentsList }).subscribe((value) => {
console.log(value)
}, ((error) => {
this.showLoader = false
console.log('remove attachment error: ', error)
}));
}