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
@@ -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>
@@ -33,6 +33,42 @@
<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-calendar.svg"></ion-icon>
</div>
<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>
</div>
<div class="container-div width-100">
<div class="ion-item-class-2">
<div class="ion-icon-class">
@@ -55,18 +91,6 @@
</div>
</div>
<!-- <div class="container-div width-100" >
<div class="ion-item-class-2 d-flex width-100">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
</div>
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs " >
<ion-input [disabled]=true autocomplete="on" autocorrect="on" spellcheck="true" placeholder="CalendarName*" [(ngModel)]="CalendarNameOwnerName"></ion-input>
</div>
</div>
</div> -->
<div class="container-div width-100">
<div class="ion-item-class-2 width-100 d-flex">
@@ -21,6 +21,9 @@ 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 { Utils } from 'src/app/services/Repositorys/Agenda/utils';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { Observable } from 'rxjs';
import { RoleIdService } from 'src/app/services/role-id.service'
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -94,6 +97,11 @@ export class EditEventPage implements OnInit {
deletedAttachmentsList = [];
addedAttachmentsList = [];
sharedCalendar: Observable<TableSharedCalendar[]>
hasChangeCalendar = false
selectedUserCalendar:any;
SessionStore = SessionStore
constructor(
private modalController: ModalController,
private navParams: NavParams,
@@ -107,7 +115,8 @@ export class EditEventPage implements OnInit {
private contactsService: ContactsService,
private domSanitazerService: DomSanitizerService,
private agendaDataRepository: AgendaDataRepositoryService,
private utils: Utils
private utils: Utils,
public RoleIdService: RoleIdService,
) {
/* this.postEvent = new Event(); */
@@ -167,9 +176,26 @@ export class EditEventPage implements OnInit {
this.CalendarNameOwnerName = this.eventsService.detectCalendarNameByCalendarId(this.postEvent.CalendarId)
this.changeAgenda()
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
if (!this.postEvent.IsRecurring) {
this.postEvent.EventRecurrence.frequency = 'never'
} else {
@@ -423,42 +449,49 @@ export class EditEventPage implements OnInit {
try {
const events = []
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, editAllEvent).subscribe((value) => {
console.log(value)
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
}, ((error) => {
console.log('edit event error: ', error)
}));
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, editAllEvent, calendar.value).subscribe((value) => {
console.log(value)
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
}, ((error) => {
console.log('edit event error: ', error)
}));
this.agendaDataRepository.addEventAttendee(this.postEvent.EventId, this.postEvent.Attendees).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add Attendee error: ', error)
}));
await this.saveDocument()
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) => {
console.log('add attachment error: ', error)
console.log('add Attendee error: ', error)
}));
}
if (this.deletedAttachmentsList.length > 0) {
this.agendaDataRepository.removeEventAttachment(this.postEvent.EventId, { attachments: this.deletedAttachmentsList }).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('remove attachment error: ', error)
}));
await this.saveDocument()
if (this.addedAttachmentsList.length > 0) {
this.agendaDataRepository.addEventAttachment(this.postEvent.EventId, this.loadedEventAttachments).subscribe((value) => {
console.log(value)
}, ((error) => {
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) => {
console.log('remove attachment error: ', error)
}));
}
this.isEventEdited = true;
} else {
console.log(calendar.error)
}
this.isEventEdited = true;
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
@@ -1,6 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, Platform } from '@ionic/angular';
import { EventAttachment, EventAttachment_v2 } from 'src/app/models/attachment.model';
import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model';
import { SearchList } from 'src/app/models/search-document';
@@ -23,11 +22,8 @@ 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 { momentG } from 'src/plugin/momentG';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, ThemePalette } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MomentDateAdapter } from '@angular/material-moment-adapter';
import { EventInputDTO } from '../../../services/Repositorys/Agenda/agendaDataModels';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { Observable } from 'rxjs';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
@@ -177,7 +173,7 @@ export class NewEventPage implements OnInit {
this.setCalendarByDefault(true)
}
hasPrCalendar(data: TableSharedCalendar[]) {
for(const e of data) {
if(e.roleId == this.RoleIdService.PRES) {
@@ -431,7 +427,7 @@ export class NewEventPage implements OnInit {
}
injectValidation() {
this.Form = new FormGroup({
Subject: new FormControl(this.postEvent.Subject, [
Validators.required,
@@ -483,7 +479,7 @@ export class NewEventPage implements OnInit {
}
save_v2() {
async save_v2() {
this.injectValidation()
this.runValidation()
@@ -498,20 +494,26 @@ export class NewEventPage implements OnInit {
return false
}
const loader = this.toastService.loading()
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.postEvent.IsAllDayEvent = this.allDayCheck;
this.agendaDataRepository.createEvent(this.postEvent, this.selectedUserCalendar, this.documents).subscribe((value) => {
console.log(value)
loader.remove()
this.hhtpErrorHandle.httpsSucessMessagge('new event')
let data = Object.assign(this.postEvent)
this.modalController.dismiss(data);
}, ((error) => {
console.log('create event error: ', error)
loader.remove()
}));
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
const loader = this.toastService.loading()
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.postEvent.IsAllDayEvent = this.allDayCheck;
this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value).subscribe((value) => {
console.log(value)
loader.remove()
this.hhtpErrorHandle.httpsSucessMessagge('new event')
let data = Object.assign(this.postEvent)
this.modalController.dismiss(data);
}, ((error) => {
console.log('create event error: ', error)
loader.remove()
}));
}
}