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
@@ -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) {