ITOTEAM-525 send the rigth category and ownertype

This commit is contained in:
Peter Maquiran
2024-06-22 13:28:14 +01:00
parent 0c14b9be97
commit 536548af0c
17 changed files with 157 additions and 499 deletions
@@ -350,28 +350,6 @@
</div>
</div>
<!-- <div class="container-div d-flex width-100">
<div class="ion-item-class-2 width-100 d-flex">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-refresh.svg"></ion-icon>
</div>
<div class="ion-input-class flex-grow-1">
<mat-form-field appearance="none" floatLabel="never" class="width-100" value="false" interface="action-sheet" required>
<mat-select
placeholder="Selecione repetição*"
[(ngModel)]="selectedRecurringType"
(ngModelChange)="onSelectedRecurringChanged($event)">
<mat-option
*ngFor="let recurring of recurringTypes"
value="{{recurring.Code}}">
{{recurring.Description}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div> -->
<div *ngIf="selectedRecurringType != '-1'" class="container-div width-100">
<div class="ion-item-class-2 d-flex">
@@ -7,7 +7,6 @@ import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { EventsService } from 'src/app/services/events.service';
import { ToastService } from 'src/app/services/toast.service';
import { Event } from '../../../models/event.model';
import { AttendeesPageModal } from '../../events/attendees/attendees.page';
import { SearchPage } from '../../search/search.page';
@@ -18,12 +17,12 @@ 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 { 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'
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -61,7 +60,6 @@ export class EditEventPage implements OnInit {
selectedDate: Date;
initCalendarName: string;
caller: string;
recurringTypes: any;
selectedRecurringType: any;
CalendarNameOwnerName = ''
@@ -108,12 +106,10 @@ export class EditEventPage implements OnInit {
public eventsService: EventsService,
public alertController: AlertController,
private attachmentsService: AttachmentsService,
private toastService: ToastService,
private router: Router,
public ThemeService: ThemeService,
private httpErrorHandle: HttpErrorHandle,
private contactsService: ContactsService,
private domSanitazerService: DomSanitizerService,
private agendaDataRepository: AgendaDataRepositoryService,
private utils: Utils,
public RoleIdService: RoleIdService,
@@ -193,7 +189,6 @@ export class EditEventPage implements OnInit {
}
ngOnInit() {
console.log('this.postEvent', this.postEvent)
this.selectedUserCalendar = this.postEvent.owner.wxUserId
if (!this.postEvent.IsRecurring) {
@@ -202,8 +197,7 @@ export class EditEventPage implements OnInit {
this.postEvent.EventRecurrence.frequency = this.utils.recurenceTypeSeleted(this.postEvent.EventRecurrence.frequency)
}
this.postEvent.Category = this.setEventType(this.postEvent.Category)
console.log(this.postEvent?.Attachments)
console.log(this.loadedEventAttachments)
window.onresize = (event) => {
// if not mobile remove all component
if (window.innerWidth >= 1024) {
@@ -214,7 +208,6 @@ export class EditEventPage implements OnInit {
this.showAttendees = true;
}
this.getRecurrenceTypes();
setTimeout(() => {
this.selectedRecurringType = this.postEvent.EventRecurrence.Type.toString();
}, 500);
@@ -250,13 +243,6 @@ export class EditEventPage implements OnInit {
this.router.navigate(['/home', this.caller]);
}
getRecurrenceTypes() {
this.eventsService.getRecurrenceTypes().subscribe(res => {
this.recurringTypes = res;
});
}
roundTimeQuarterHour(timeToReturn = new Date()) {
let date = timeToReturn || new Date();
const minutes = date.getMinutes();
@@ -438,7 +424,9 @@ export class EditEventPage implements OnInit {
this.save_v2(false)
}
}
async save_v2(editAllEvent) {
@XTracerAsync({name:'desktop/create-event', bugPrint: true, daley: 4000})
async save_v2(editAllEvent, tracing?: TracingType) {
this.injectValidation()
this.runValidation()
@@ -448,15 +436,16 @@ export class EditEventPage implements OnInit {
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
try {
const events = []
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, editAllEvent, calendar.value).subscribe((value) => {
this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, editAllEvent, calendar.value, tracing).subscribe((value) => {
console.log(value)
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
tracing.setAttribute('outcome', 'success')
}, ((error) => {
tracing.setAttribute('outcome', 'failed')
console.log('edit event error: ', error)
}));
@@ -482,6 +471,7 @@ export class EditEventPage implements OnInit {
console.log(value)
}, ((error) => {
console.log('remove attachment error: ', error)
tracing.setAttribute('failed.remove.attachment', 'true')
}));
}
@@ -501,89 +491,6 @@ export class EditEventPage implements OnInit {
}
// async save() {
// this.injectValidation()
// this.runValidation()
// if (this.Form.invalid) return false;
// if (this.selectedRecurringType != '-1') {
// this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
// }
// this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc)
// this.postEvent.Subject = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Subject/* ) */;
// this.postEvent.Location = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Location/* ) */;
// this.postEvent.Body.Text = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Body.Text/* ) */;
// this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
// if (this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
// this.eventsService.editEvent(this.postEvent, 2, 3, null).subscribe(async () => {
// if (window['reloadCalendar']) {
// window['reloadCalendar']()
// }
// if (this.initCalendarName != this.postEvent.CalendarName) {
// let body = {
// "EventId": this.postEvent.EventId,
// "CalendarDestinationName": this.postEvent.CalendarName,
// }
// try {
// await this.eventsService.changeAgenda(body).toPromise();
// } catch (error) { }
// finally {
// }
// }
// this.httpErrorHandle.httpsSucessMessagge('Editar evento')
// }, error => {
// this.httpErrorHandle.httpStatusHandle(error)
// });
// } else {
// console.log('edid calendar id', this.postEvent.CalendarId);
// this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).subscribe(async () => {
// if (window['reloadCalendar']) {
// window['reloadCalendar']()
// }
// if (this.initCalendarName != this.postEvent.CalendarName) {
// let body = {
// "EventId": this.postEvent.EventId,
// "CalendarDestinationName": this.postEvent.CalendarName,
// }
// try {
// await this.eventsService.changeAgenda(body).toPromise();
// } catch (error) { }
// finally {
// }
// }
// this.httpErrorHandle.httpsSucessMessagge('Editar evento')
// }, error => {
// this.httpErrorHandle.httpStatusHandle(error)
// });
// }
// this.isEventEdited = true;
// await this.saveDocument()
// this.goBack();
// }
async saveDocument() {
try {
+13 -300
View File
@@ -26,6 +26,7 @@ import { Observable } from 'rxjs';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { map } from 'rxjs/operators';
import { RoleIdService } from 'src/app/services/role-id.service'
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -84,7 +85,6 @@ export class NewEventPage implements OnInit {
selectedSegment: string;
selectedDate: Date;
CalendarDate: Date;
recurringTypes: any;
selectedRecurringType: any;
adding: "intervenient" | "CC";
@@ -212,8 +212,6 @@ export class NewEventPage implements OnInit {
this.selectedRecurringType = "-1";
this.getRecurrenceTypes();
if (this.selectedSegment != "Combinada") {
this.postEvent = {
EventId: '',
@@ -342,14 +340,6 @@ export class NewEventPage implements OnInit {
}
}
getRecurrenceTypes() {
this.eventService.getRecurrenceTypes().subscribe(res => {
this.recurringTypes = res;
});
}
onSelectedRecurringChanged(ev: any) {
this.calculetedLastOccurrence(ev);
@@ -472,7 +462,8 @@ export class NewEventPage implements OnInit {
}
async save_v2() {
@XTracerAsync({name:'Mobile/create-event', bugPrint: true})
async save_v2(tracing?: TracingType) {
this.injectValidation()
this.runValidation()
@@ -493,132 +484,27 @@ export class NewEventPage implements OnInit {
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) => {
try {
const value = await this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value, tracing).toPromise()
console.log(value)
loader.remove()
this.hhtpErrorHandle.httpsSucessMessagge('new event')
let data = Object.assign(this.postEvent)
this.modalController.dismiss(data);
}, ((error) => {
tracing.setAttribute('outcome', 'success');
} catch(error) {
tracing.setAttribute('outcome', 'failed');
console.log('create event error: ', error)
loader.remove()
}));
}
} else {
}
}
// async save() {
// this.injectValidation()
// this.runValidation()
// if (this.Form.invalid) {
// return false
// }
// if (this.documents.length >= 0) {
// this.postEvent.HasAttachments = true;
// }
// if (this.selectedRecurringType != '-1') {
// this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
// }
// this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
// this.postEvent.Subject = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Subject/* ); */
// this.postEvent.Location = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Location/* ); */
// this.postEvent.Body.Text = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Body.Text/* ); */
// let eventId: any;
// const loader = this.toastService.loading()
// try {
// const CalendarId = this.selectedCalendarId()
// this.postEvent.CalendarId = CalendarId
// if (this.loggeduser.Profile == 'MDGPR') {
// eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
// this.hhtpErrorHandle.httpsSucessMessagge('new event')
// }
// else if (this.loggeduser.Profile == 'PR') {
// const CalendarId = this.selectedCalendarId()
// this.postEvent.CalendarId = CalendarId
// eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
// this.hhtpErrorHandle.httpsSucessMessagge('new event')
// } else if (this.loggeduser.Profile == 'SGGPR') {
// this.saveAproveEvent();
// } else {
// const CalendarId = this.selectedCalendarId()
// this.postEvent.CalendarId = CalendarId
// eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
// this.hhtpErrorHandle.httpsSucessMessagge('new event')
// }
// //foi adicionado este if para não ter de fazer muitas alterações sobre a criação dos eventos. Deve ser refatorado
// if (this.loggeduser.Profile != 'SGGPR') {
// const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
// return {
// SourceTitle: e.Assunto,
// ParentId: eventId,
// Source: '1',
// SourceId: e.Id,
// ApplicationId: e.ApplicationType.toString(),
// Id: '',
// Link: '',
// SerialNumber: ''
// };
// });
// await DocumentToSave.forEach(async (attachments, i) => {
// try {
// await this.attachmentsService.setEventAttachmentById(attachments).toPromise();
// } catch (error) {
// }
// });
// let data1 = {
// "subject": this.postEvent.Subject,
// "start": this.postEvent.StartDate,
// "end": this.postEvent.EndDate,
// "venue": this.postEvent.Location,
// "id": eventId,
// "calendarId": CalendarId
// }
// if (this.roomId) {
// this.chatMethodService.sendMessage(this.roomId, data1);
// }
// this.hhtpErrorHandle.httpsSucessMessagge('new event');
// let data = Object.assign(this.postEvent, { id: eventId })
// this.modalController.dismiss(data);
// }
// } catch (error) {
// this.hhtpErrorHandle.httpStatusHandle(error)
// } finally {
// loader.remove()
// }
// }
//This method return calendar id
@@ -772,179 +658,6 @@ export class NewEventPage implements OnInit {
}
}
//Deve ser removido posteriormente
// async saveAproveEvent() {
// // console.log(this.postEvent)
// // console.log(this.postEvent.CalendarName)
// // console.log(this.CalendarName)
// // console.log(this.eventService.calendarNamesAry)
// const CalendarId = this.selectedCalendarId()
// let selectedCalendar
// try {
// selectedCalendar = this.eventService.calendarNamesAry.find(calendar => calendar.Fullname === this.CalendarName)
// } catch (error) {
// }
// // console.log('selectedCalendar', selectedCalendar)
// if (selectedCalendar) {
// if (selectedCalendar.Role = 'Presidente da República') {
// let loader = this.toastService.loading();
// const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
// return {
// SourceTitle: e.Assunto,
// ParentId: "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate(),
// Source: '1',
// SourceId: e.Id,
// ApplicationId: e.ApplicationType.toString(),
// Id: '',
// Link: '',
// SerialNumber: ''
// };
// });
// let body = this.eventToaproveBody(this.postEvent, CalendarId, this.loggeduser.RoleID, this.loggeduser.UserId, DocumentToSave);
// await this.processeService.createEventToAprove(this.postEvent.CalendarName, 'pr', body).subscribe((id) => {
// loader.remove()
// this.modalController.dismiss();
// this.hhtpErrorHandle.httpsSucessMessagge('new event to aprove')
// /* DocumentToSave.forEach((attachments, i) => {
// this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => {
// if (DocumentToSave.length == (i + 1)) {
// this.afterSave();
// }
// });
// });
// if (DocumentToSave.length == 0) {
// this.afterSave();
// } */
// }, (error) => {
// loader.remove()
// this.hhtpErrorHandle.httpStatusHandle(error)
// });
// } else if (selectedCalendar.Role = 'Ministro e Director do Gabinete do PR') {
// let loader = this.toastService.loading();
// const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
// return {
// SourceTitle: e.Assunto,
// ParentId: "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate(),
// Source: '1',
// SourceId: e.Id,
// ApplicationId: e.ApplicationType.toString(),
// Id: '',
// Link: '',
// SerialNumber: ''
// };
// });
// let body = this.eventToaproveBody(this.postEvent, CalendarId, this.loggeduser.RoleID, this.loggeduser.UserId, DocumentToSave);
// await this.processeService.createEventToAprove(this.postEvent.CalendarName, 'md', body).subscribe((id) => {
// loader.remove()
// this.modalController.dismiss();
// this.hhtpErrorHandle.httpsSucessMessagge('new event to aprove')
// /* DocumentToSave.forEach((attachments, i) => {
// this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => {
// if (DocumentToSave.length == (i + 1)) {
// this.afterSave();
// }
// });
// });
// if (DocumentToSave.length == 0) {
// this.afterSave();
// } */
// }, (error) => {
// loader.remove()
// this.hhtpErrorHandle.httpStatusHandle(error)
// });
// }
// }
// if (!selectedCalendar && this.CalendarName == "Meu calendario") {
// console.log('SG generic')
// this.postEvent.CalendarName
// const CalendarId = this.selectedCalendarId()
// let loader = this.toastService.loading();
// this.postEvent.CalendarId = CalendarId
// this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe(
// (id) => {
// loader.remove();
// const eventId: any = id;
// const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
// return {
// SourceTitle: e.Assunto,
// ParentId: eventId,
// Source: '1',
// SourceId: e.Id,
// ApplicationId: e.ApplicationType.toString(),
// Id: '',
// Link: '',
// SerialNumber: ''
// };
// });
// DocumentToSave.forEach((attachments, i) => {
// this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => {
// if (DocumentToSave.length == (i + 1)) {
// }
// });
// });
// if (DocumentToSave.length == 0) {
// }
// this.hhtpErrorHandle.httpsSucessMessagge('new event')
// let data = {
// "subject": this.postEvent.Subject,
// "start": this.postEvent.StartDate,
// "end": this.postEvent.EndDate,
// "venue": this.postEvent.Location,
// "id": id,
// "calendarId": CalendarId
// }
// if (this.roomId) {
// this.chatMethodService.sendMessage(this.roomId, data);
// }
// let dataa = Object.assign(this.postEvent, { id: eventId })
// this.modalController.dismiss(dataa);
// }, (error) => {
// loader.remove()
// this.hhtpErrorHandle.httpStatusHandle(error)
// });
// }
// }
// Deve ser removido posteriormente
eventToaproveBody(event, calendarId, role, userId, attachments) {
let toAproveObject = {