diff --git a/src/app/pages/agenda/new-event/new-event.page.ts b/src/app/pages/agenda/new-event/new-event.page.ts index aada420d3..48c6418de 100644 --- a/src/app/pages/agenda/new-event/new-event.page.ts +++ b/src/app/pages/agenda/new-event/new-event.page.ts @@ -440,7 +440,11 @@ export class NewEventPage implements OnInit { this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc); this.postEvent.IsAllDayEvent = this.allDayCheck; - this.agendaDataRepository.createEvent(this.postEvent,this.CalendarName,this.documents); + this.agendaDataRepository.createEvent(this.postEvent,this.CalendarName,this.documents).subscribe((value) => { + console.log(value) + }, ((error) => { + console.log('create event error: ', error) + })); loader.remove() this.modalController.dismiss(); this.hhtpErrorHandle.httpsSucessMessagge('new event') diff --git a/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts b/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts index 3893f82f9..7560cbb83 100644 --- a/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts +++ b/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts @@ -3,7 +3,7 @@ import { AgendaDataService } from './agenda-data.service'; import { map } from 'rxjs/operators'; import { ListEventMapper } from './mapper/EventListMapper'; import { EventMapper } from './mapper/EventDetailsMapper'; -import { Utils } from './utils'; +import { Utils } from './utils'; import { EventInputDTO } from './agendaDataModels'; import { Event } from 'src/app/models/event.model'; import { SessionStore } from 'src/app/store/session.service'; @@ -26,27 +26,27 @@ export class AgendaDataRepositoryService { ) } - EventList({userId = null, startDate = null, endDate = null, status= 2, category= null, type= null, calendarOwnerName = ''}) { + EventList({ userId = null, startDate = null, endDate = null, status = 2, category = null, type = null, calendarOwnerName = '' }) { return this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe( map((response) => { return ListEventMapper.toDomain(response.data, calendarOwnerName, userId) } - )) + )) } - eventToApprove({userId, startDate = null, endDate = null, status = 0, category= null, type= null, calendarOwnerName = ''}) { - return this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category= null, type= null).pipe( + eventToApprove({ userId, startDate = null, endDate = null, status = 0, category = null, type = null, calendarOwnerName = '' }) { + return this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category = null, type = null).pipe( map((response) => { return ListEventMapper.toDomain(response.data, calendarOwnerName, userId) } - )) + )) } - createEvent(eventData: Event,CalendarName,documents) { + createEvent(eventData: Event, CalendarName, documents) { console.log(eventData) let eventInput = { - userId: this.utils.selectedCalendarUserId(CalendarName,eventData) as any, + userId: this.utils.selectedCalendarUserId(CalendarName, eventData) as any, ownerType: this.utils.selectedCalendarOwner(CalendarName), subject: eventData.Subject, body: eventData.Body.Text, @@ -65,48 +65,42 @@ export class AgendaDataRepositoryService { isAllDayEvent: eventData.IsAllDayEvent, } - this.agendaDataService.createEvent(eventInput).subscribe((value) => { - console.log(value) - },((error) => { - console.log('create event',error) - })); + return this.agendaDataService.createEvent(eventInput) } - updateEvent(eventId,eventData: Event,CalendarName,documents) { - console.log(this.utils.editeEventCalendarUserId(CalendarName,eventData)); + updateEvent(eventId, eventData: Event, CalendarName, documents) { + console.log(eventData.StartDate) + console.log(eventData.EndDate) let eventInput = { - userId: this.utils.selectedCalendarUserId(CalendarName,eventData), - ownerType: this.utils.selectedCalendarOwner(CalendarName), subject: eventData.Subject, body: eventData.Body.Text, location: eventData.Location, - startDate: JSON.stringify(eventData.StartDate), - endDate: JSON.stringify(eventData.EndDate), - type: this.utils.calendarTypeSeleted(eventData.Category), - category: this.utils.calendarCategorySeleted(eventData.CalendarName), - attendees: this.utils.attendeesAdded(eventData.Attendees), - attachments: this.utils.documentAdded(documents), + startDate: eventData.StartDate, + endDate: eventData.EndDate, + isAllDayEvent: eventData.IsAllDayEvent, + updateAllEvents: false, recurrence: { frequency: 0, - occurrences: 0, - }, - organizerId: SessionStore.user.UserId, - isAllDayEvent: eventData.IsAllDayEvent, + occurrences: 0 + } } + return this.agendaDataService.updateEvent(eventId, eventInput) + } - this.agendaDataService.updateEvent(eventId, eventInput).subscribe((value) => { - console.log(value) - },((error) => { - console.log(error) - })); + addEventAttendee(id,attendeeData) { + return this.agendaDataService.addEventAttendee(id,attendeeData); + } + + addEventAttachment(id,attachmentData) { + return this.agendaDataService.addEventAttachment(id,attachmentData); } deleteEvent(eventId) { - this.agendaDataService.deleteEvent(eventId,false).subscribe(() => { - console.log() - },((error) => { - console.log(error) - })) + return this.agendaDataService.deleteEvent(eventId, false) + } + + removeEventAttachment(eventId,attachmentData) { + return this.agendaDataService.removeEventAttachment(eventId,attachmentData); } } diff --git a/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts b/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts index f8da9f50d..9c4baac3a 100644 --- a/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts +++ b/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts @@ -58,10 +58,10 @@ export class EventMapper { "LastOccurrence": null }, "Attachments": dto.attachments.map( e => ({ - "Id": e.sourceId, + "Id": e.id, // "ParentId": "AAMkADVhOGY3ZDQzLTg4ZGEtNDYxMC1iMzc5LTJkMDgwNjMxOWFlZQBGAAAAAABEDW9nKs69TKQcVqQURj8YBwBR2HR2eO7pSpNdD9cc70l+AAAAAAFKAABR2HR2eO7pSpNdD9cc70l+AACK2OeJAAA=", // "Source": 1, - "SourceId": e.sourceId, + "SourceId": e.docId, // "Description": "teste pp", "SourceName": e.sourceName, // "CreateDate": "2024-05-24 16:41", diff --git a/src/app/services/Repositorys/Agenda/model/eventDTOOutput.ts b/src/app/services/Repositorys/Agenda/model/eventDTOOutput.ts index 33e88224a..65f19a2b0 100644 --- a/src/app/services/Repositorys/Agenda/model/eventDTOOutput.ts +++ b/src/app/services/Repositorys/Agenda/model/eventDTOOutput.ts @@ -1,7 +1,8 @@ import { z } from 'zod'; export const AttachmentInputDTOSchema = z.object({ - sourceId: z.string().nullable(), + id: z.string().nullable(), + docId: z.number().nullable(), sourceName: z.string().nullable(), description: z.string().nullable(), applicationId: z.number().int(), diff --git a/src/app/services/Repositorys/Agenda/utils.ts b/src/app/services/Repositorys/Agenda/utils.ts index d2dd34f09..9561b0a13 100644 --- a/src/app/services/Repositorys/Agenda/utils.ts +++ b/src/app/services/Repositorys/Agenda/utils.ts @@ -26,24 +26,6 @@ export class Utils { } } - editeEventCalendarUserId(CalendarName,postEvent) { - - let CalendarNameOwnerName = this.eventService.detectCalendarNameByCalendarId(postEvent.CalendarId) - if(this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Oficial'] && this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Pessoal']) { - - return this.eventService.calendarNamesType[CalendarName]['OwnerId'] - - } else if (this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Oficial']) { - return this.eventService.calendarNamesType[CalendarName]['OwnerId'] - - } else if (this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Pessoal']) { - return this.eventService.calendarNamesType[CalendarName]['OwnerId'] - - } else { - return this.eventService.calendarNamesType[CalendarName]['OwnerId'] - } - } - selectedCalendarOwner(CalendarName) { let selectedCalendar = this.eventService.calendarNamesType[CalendarName]?.['RoleId']; @@ -79,12 +61,13 @@ export class Utils { } documentAdded(documents:any[]) { + console.log('added doc create event',documents) return documents.map((e) => { return { - sourceId: e.Id, + docId: parseInt(e.Id), sourceName: e.Assunto, description: "", - applicationId: parseInt(e.ApplicationType.toString()) + applicationId: parseInt(JSON.stringify(e.ApplicationType)) }; }); @@ -93,9 +76,9 @@ export class Utils { atendeesSeletedType(type) { var selectedType = { - 'true': 1, - 'false':2, - 'other':3, + 'true': 0, + 'false':1, + 'other':2, } return selectedType[type]; } diff --git a/src/app/shared/agenda/edit-event/edit-event.page.ts b/src/app/shared/agenda/edit-event/edit-event.page.ts index ad3bcfdee..7818b7389 100644 --- a/src/app/shared/agenda/edit-event/edit-event.page.ts +++ b/src/app/shared/agenda/edit-event/edit-event.page.ts @@ -27,17 +27,18 @@ import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda export class EditEventPage implements OnInit { stEvent: Event; - isRecurring:string; + isRecurring: string; isEventEdited: boolean; loadedEvent: Event; initCalendarName: string; eventBody: EventBody; - segment:string = "true"; + segment: string = "true"; eventAttendees: EventPerson[]; // minDate: string; - loadedEventAttachments: Attachment[]=[]; + loadedEventAttachments: Attachment[] = []; recurringTypes = []; selectedRecurringType: any; + deletedAttachmentsList = []; public date: any; public disabled = false; @@ -45,8 +46,8 @@ export class EditEventPage implements OnInit { public showSeconds = false; public touchUi = false; public enableMeridian = false; - public minDate = new Date().toISOString().slice(0,10) - public endMinDate = new Date(new Date().getTime() + 15 * 60000).toISOString().slice(0,10) + public minDate = new Date().toISOString().slice(0, 10) + public endMinDate = new Date(new Date().getTime() + 15 * 60000).toISOString().slice(0, 10) public maxDate: any; public stepHour = 1; public stepMinute = 15; @@ -57,7 +58,7 @@ export class EditEventPage implements OnInit { @Input() taskParticipants: EventPerson[]; @Input() taskParticipantsCc: EventPerson[]; - @Input() profile:string; + @Input() profile: string; @Input() selectedSegment: string; @Input() postEvent: Event; @Output() clearContact = new EventEmitter(); @@ -89,12 +90,13 @@ export class EditEventPage implements OnInit { public stepMinutes = [1, 5, 10, 15, 20, 25]; public stepSeconds = [1, 5, 10, 15, 20, 25]; - private participantsPipe = new ParticipantsPipe() + private participantsPipe = new ParticipantsPipe() sesseionStora = SessionStore CalendarNameOwnerName = '' CalendarNamesOptions = [] allDayCheck: boolean = false; + addedAttachmentsList = []; constructor( private modalController: ModalController, @@ -107,19 +109,19 @@ export class EditEventPage implements OnInit { private domSanitizeService: DomSanitizerService, private agendaDataRepository: AgendaDataRepositoryService ) { - + } ngOnInit() { console.log(this.postEvent) this._postEvent = this.postEvent this.allDayCheck = this.postEvent.IsAllDayEvent; - if(!this.restoreTemporaryData()) { + if (!this.restoreTemporaryData()) { // clear - if(this._postEvent) { - if( this._postEvent.Body){ - if(typeof(this._postEvent.Body.Text) == 'string'){ + if (this._postEvent) { + if (this._postEvent.Body) { + if (typeof (this._postEvent.Body.Text) == 'string') { this._postEvent.Body.Text = this._postEvent.Body.Text.replace(/<[^>]+>/g, ''); } } @@ -127,18 +129,18 @@ export class EditEventPage implements OnInit { - for(const index in this._postEvent.Attendees) { - const user = this._postEvent.Attendees[index] + for (const index in this._postEvent.Attendees) { + const user = this._postEvent.Attendees[index] + + const userData = this.contactsService.constacts.find(e => user.EmailAddress == e.EmailAddress) + if (userData) { + this._postEvent.Attendees[index].UserType = userData.UserType + } else { + console.log('user not set') + } - const userData = this.contactsService.constacts.find(e => user.EmailAddress == e.EmailAddress) - if(userData) { - this._postEvent.Attendees[index].UserType = userData.UserType - } else { - console.log('user not set') } - } - if (this._postEvent.Attendees != null) { const result = this.participantsPipe.transform(this._postEvent.Attendees) this.taskParticipants = result.taskParticipants @@ -175,8 +177,8 @@ export class EditEventPage implements OnInit { } myInterval = setInterval(() => { - document.querySelectorAll('.ngx-mat-timepicker input').forEach((e :any) => { - if(e) { + document.querySelectorAll('.ngx-mat-timepicker input').forEach((e: any) => { + if (e) { e.disabled = true; } }) @@ -196,7 +198,7 @@ export class EditEventPage implements OnInit { } getRecurrenceTypes() { - this.eventsService.getRecurrenceTypes().subscribe(res=>{ + this.eventsService.getRecurrenceTypes().subscribe(res => { this.recurringTypes = res; }); @@ -204,12 +206,12 @@ export class EditEventPage implements OnInit { runValidation() { - this.validateFrom = true + this.validateFrom = true } injectValidation() { - if (typeof(this._postEvent.EventRecurrence.Type) == 'number') { + if (typeof (this._postEvent.EventRecurrence.Type) == 'number') { const str: any = this._postEvent.EventRecurrence.Type.toString() this._postEvent.EventRecurrence.Type = str } @@ -226,13 +228,13 @@ export class EditEventPage implements OnInit { Categories: new FormControl(this._postEvent.Category, [ Validators.required ]), - dateOccurrence: new FormControl(this._postEvent.EventRecurrence.Type.toString() == '-1' ? ['ok']: this._postEvent.EventRecurrence.LastOccurrence && new Date(this._postEvent.EventRecurrence.LastOccurrence).getTime() > new Date(this._postEvent.EndDate).getTime() ? 'ok': null, [ + dateOccurrence: new FormControl(this._postEvent.EventRecurrence.Type.toString() == '-1' ? ['ok'] : this._postEvent.EventRecurrence.LastOccurrence && new Date(this._postEvent.EventRecurrence.LastOccurrence).getTime() > new Date(this._postEvent.EndDate).getTime() ? 'ok' : null, [ Validators.required ]), participantes: new FormControl(this.taskParticipants, [ // Validators.required ]), - Date: new FormControl( true,[ + Date: new FormControl(true, [ Validators.required ]), @@ -242,7 +244,7 @@ export class EditEventPage implements OnInit { openInicio() { let input: any = document.querySelector('#new-inicio') - if(input) { + if (input) { input.click() } @@ -250,14 +252,14 @@ export class EditEventPage implements OnInit { openFim() { let input: any = document.querySelector('#new-fim') - if(input) { + if (input) { input.click() } } openLastOccurrence() { let input: any = document.querySelector('#last-occurrence') - if(input) { + if (input) { input.click() } } @@ -267,7 +269,7 @@ export class EditEventPage implements OnInit { const minutes = date.getMinutes(); date.setSeconds(0); - if(minutes % 15 != 0) { + if (minutes % 15 != 0) { if (minutes > 45) { date.setMinutes(60) @@ -284,39 +286,39 @@ export class EditEventPage implements OnInit { return date } - roundTimeQuarterHourPlus15(date:Date) { + roundTimeQuarterHourPlus15(date: Date) { const _date = new Date(date); - const minutes = _date .getMinutes(); - _date .setMinutes(minutes + 15) + const minutes = _date.getMinutes(); + _date.setMinutes(minutes + 15) return _date } - onSelectedRecurringChanged(ev:any){ + onSelectedRecurringChanged(ev: any) { this.calculetedLastOccurrence(ev); - if(ev.length > 1){ + if (ev.length > 1) { this._postEvent.EventRecurrence.Type = ev.filter(data => data != '-1'); } - if(ev.length == 0){ + if (ev.length == 0) { this._postEvent.EventRecurrence.Type = "-1"; } } - calculetedLastOccurrence(type:number){ + calculetedLastOccurrence(type: number) { var valor; var opcao: boolean; if (type == 0) { valor = 7; opcao = true; - } else if(type == 1){ + } else if (type == 1) { valor = 30; opcao = true; - } else if(type == 2){ + } else if (type == 2) { valor = 1; opcao = false; - }else if(type == 3){ + } else if (type == 3) { valor = 5; opcao = false; } @@ -324,7 +326,7 @@ export class EditEventPage implements OnInit { } - defineLastOccurrence(valor:number, opcao:boolean){ + defineLastOccurrence(valor: number, opcao: boolean) { var time = new Date(this._postEvent.EndDate); if (opcao == true) { time.setDate(time.getDate() + valor); @@ -342,17 +344,108 @@ export class EditEventPage implements OnInit { } - save_v2() { + atendeesSeletedType(type) { + var selectedType = { + 'true': 1, + 'false': 2, + 'other': 3, + } + return selectedType[type]; + } + + documentAdded(documents: any[]) { + console.log('document added', documents) + return documents.map((element) => { + return { + docId: parseInt(element.SourceId), + sourceName: element.SourceName, + description: "", + applicationId: parseInt(element.ApplicationId) + }; + }); + + } + + attendeesAdded(taskParticipants: any[]) { + return taskParticipants.map((e) => { + return { + name: e.Name, + emailAddress: e.EmailAddress, + attendeeType: this.atendeesSeletedType(JSON.stringify(e.IsRequired)), + wxUserId: e.wxUserId, + } + }); + } + + async save_v2() { this.injectValidation() this.runValidation() if (this.Form.invalid) { return false } + + /* this._postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc); + console.log('1',this._postEvent.Attendees) + console.log('2',this.postEvent.Attendees) + if (JSON.stringify(this._postEvent.Attendees) === JSON.stringify(this.postEvent.Attendees)) { + console.log(true) + } else { + console.log(false) + } + return */ + + this._postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc); this.showLoader = true; - this.agendaDataRepository.updateEvent(this._postEvent.EventId, this._postEvent,this._postEvent.CalendarName,this.loadedEventAttachments); - this.showLoader = false; - this.httpErrorHandle.httpsSucessMessagge('Editar evento') + + try { + + this.agendaDataRepository.updateEvent(this._postEvent.EventId, this._postEvent, this._postEvent.CalendarName, this.loadedEventAttachments).subscribe((value) => { + console.log(value) + }, ((error) => { + console.log('edit event error: ', error) + })); + + this.agendaDataRepository.addEventAttendee(this._postEvent.EventId, { attendees: this.attendeesAdded(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, { "attachments": this.documentAdded(this._postEvent.Attachments) }).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) + })); + } + + + this.clearPostEvent.emit(); + this.deleteTemporaryData(); + this.showLoader = false; + this.close(); + + + this.httpErrorHandle.httpsSucessMessagge('Editar evento') + + } catch (error) { + this.httpErrorHandle.httpStatusHandle(error) + console.log('edit: ', error) + } } @@ -361,7 +454,7 @@ export class EditEventPage implements OnInit { this.injectValidation() this.runValidation() - if(this.Form.invalid) { + if (this.Form.invalid) { return false } @@ -370,22 +463,22 @@ export class EditEventPage implements OnInit { this._postEvent.Location = /* this.domSanitizeService.sanitizeInput( */this._postEvent.Location/* ) */; this._postEvent.Body.Text = /* this.domSanitizeService.sanitizeInput( */this._postEvent.Body.Text/* ) */; - if(!this._postEvent.EventRecurrence.hasOwnProperty('Type')) { + if (!this._postEvent.EventRecurrence.hasOwnProperty('Type')) { this._postEvent.EventRecurrence.Type = '-1' } else { } - if(this._postEvent.EventRecurrence.Type == undefined) { + if (this._postEvent.EventRecurrence.Type == undefined) { this._postEvent.EventRecurrence.Type = '-1' } this.showLoader = true; try { - if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + if (this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { await this.eventsService.editEvent(this._postEvent, 2, 3, this._postEvent.CalendarId).toPromise() - if(this.initCalendarName != this._postEvent.CalendarName) { + if (this.initCalendarName != this._postEvent.CalendarName) { let body = { "EventId": this._postEvent.EventId, "CalendarDestinationName": this._postEvent.CalendarName, @@ -393,14 +486,14 @@ export class EditEventPage implements OnInit { try { await this.eventsService.changeAgenda(body).toPromise(); - } catch (e) {} + } catch (e) { } } this.showLoader = false; this.httpErrorHandle.httpsSucessMessagge('Editar evento') } else { console.log(this._postEvent, 2, 3, this._postEvent.CalendarId) await this.eventsService.editEvent(this._postEvent, 2, 3, this._postEvent.CalendarId).toPromise() - if(this.initCalendarName != this._postEvent.CalendarName) { + if (this.initCalendarName != this._postEvent.CalendarName) { let body = { "EventId": this._postEvent.EventId, "CalendarDestinationName": this._postEvent.CalendarName, @@ -408,14 +501,14 @@ export class EditEventPage implements OnInit { try { await this.eventsService.changeAgenda(body).toPromise(); - } catch (e) {} + } catch (e) { } } this.showLoader = false; this.httpErrorHandle.httpsSucessMessagge('Editar evento') } - } catch(error) { + } catch (error) { this.showLoader = false this.httpErrorHandle.httpStatusHandle(error) } @@ -431,14 +524,14 @@ export class EditEventPage implements OnInit { async saveDocument() { - + console.log('save document', this.loadedEventAttachments) try { - for( let e of this.loadedEventAttachments) { + for (let e of this.loadedEventAttachments) { const id: any = e.Id const remove = e['remove'] - if ( id == 'add') { + if (id == 'add') { //data.selected const DocumentToSave = { SourceTitle: e.SourceName, @@ -453,7 +546,7 @@ export class EditEventPage implements OnInit { // await this.attachmentsService.setEventAttachmentById(DocumentToSave).toPromise(); - } else if(remove) { + } else if (remove) { await this.attachmentsService.deleteEventAttachmentById(e.Id).toPromise() } } @@ -498,9 +591,9 @@ export class EditEventPage implements OnInit { restoreTemporaryData(): boolean { - const restoredData = window['temp.path:/home/agenda/edit-event.component.ts'] + const restoredData = window['temp.path:/home/agenda/edit-event.component.ts'] - if(JSON.stringify(restoredData) != "{}" && undefined != restoredData){ + if (JSON.stringify(restoredData) != "{}" && undefined != restoredData) { this._postEvent = restoredData.postEvent this.eventBody = restoredData.eventBody this.segment = restoredData.segment @@ -513,15 +606,16 @@ export class EditEventPage implements OnInit { } - deleteTemporaryData(){ + deleteTemporaryData() { window['temp.path:/home/agenda/edit-event.component.ts'] = {} } - async getAttachments(eventId: string){ - if(this._postEvent.HasAttachments) { + async getAttachments(eventId: string) { + if (this._postEvent.HasAttachments) { let rest: any; try { rest = this.attachmentsService.getAttachmentsById(eventId).toPromise() + console.log('GetAttachment', rest) } catch (error) { console.error('getAttchment', error) } @@ -533,10 +627,11 @@ export class EditEventPage implements OnInit { const id: any = this.loadedEventAttachments[index].Id - if(id == 'add') { - this.loadedEventAttachments = this.loadedEventAttachments.filter((e,i)=> i!=index) + if (id == 'add') { + this.loadedEventAttachments = this.loadedEventAttachments.filter((e, i) => i != index) } else { this.loadedEventAttachments[index]['remove'] = true + this.deletedAttachmentsList.push(id) } } @@ -553,15 +648,16 @@ export class EditEventPage implements OnInit { } }); - modal.onDidDismiss().then( async (res) => { - if(res) { + modal.onDidDismiss().then(async (res) => { + if (res) { const data = res.data; + console.log(data) const ApplicationIdDocumentToSave: any = { SourceName: data.selected.Assunto, ParentId: this._postEvent.EventId, SourceId: data.selected.Id, - Stakeholders: data.selected.EntidadeOrganicaNome | data.selected.Stakeholders, + Stakeholders: data.selected.EntidadeOrganicaNome | data.selected.Stakeholders, ApplicationId: data.selected.ApplicationType.toString(), CreateDate: data.selected.Data, Id: 'add', @@ -572,6 +668,7 @@ export class EditEventPage implements OnInit { } this.loadedEventAttachments.push(ApplicationIdDocumentToSave) + this.addedAttachmentsList.push(ApplicationIdDocumentToSave) } }); @@ -584,7 +681,7 @@ export class EditEventPage implements OnInit { setTimeout(() => { - if(this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Oficial'] && this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Pessoal']) { + if (this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Oficial'] && this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Pessoal']) { this.CalendarNamesOptions = ['Oficial', 'Pessoal'] diff --git a/src/app/shared/agenda/new-event/new-event.page.ts b/src/app/shared/agenda/new-event/new-event.page.ts index 73876f171..644fac968 100644 --- a/src/app/shared/agenda/new-event/new-event.page.ts +++ b/src/app/shared/agenda/new-event/new-event.page.ts @@ -163,7 +163,7 @@ export class NewEventPage implements OnInit { ngOnInit() { - console.log(' INTERVENIENTES',this.taskParticipants) + console.log(' INTERVENIENTES', this.taskParticipants) this.changeProfileService.registerCallback(() => { this.initializeData() }) @@ -193,7 +193,7 @@ export class NewEventPage implements OnInit { } }) } - console.log('Attendes',this.taskParticipants) + console.log('Attendes', this.taskParticipants) this.taskParticipants = removeDuplicate(this.taskParticipants); this.taskParticipantsCc = removeDuplicate(this.taskParticipantsCc); @@ -526,7 +526,12 @@ export class NewEventPage implements OnInit { this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc); this.postEvent.IsAllDayEvent = this.allDayCheck; - this.agendaDataRepository.createEvent(this.postEvent,this.CalendarName,this.documents); + this.agendaDataRepository.createEvent(this.postEvent, this.CalendarName, this.documents).subscribe((value) => { + console.log(value) + }, ((error) => { + console.log('create event error: ', error) + })); + loader.remove(); this.afterSave(); this.hhtpErrorHandle.httpsSucessMessagge('new event') @@ -539,7 +544,7 @@ export class NewEventPage implements OnInit { if (this.Form.invalid) { - if(new Date(this.postEvent.StartDate).getTime() < new Date(this.postEvent.EndDate).getTime()) { + if (new Date(this.postEvent.StartDate).getTime() < new Date(this.postEvent.EndDate).getTime()) { this.toastService._badRequest("Data de inicio menor que a data de fim") } @@ -1042,7 +1047,7 @@ export class NewEventPage implements OnInit { } async fetchContacts(filter: string) { -console.log(this.loggeduser.Profile) + console.log(this.loggeduser.Profile) if (this.loggeduser.Profile == 'PR') { this.contactsService.getContacts(filter).subscribe(result => { if (this.eventPersons != null) { @@ -1063,7 +1068,7 @@ console.log(this.loggeduser.Profile) this.contacts = filterLoggedUserEmail; this.taskParticipants.push(this.contacts[0]); - this.setIntervenient.emit(this.taskParticipants); + this.setIntervenient.emit(this.taskParticipants); console.log('Attendes Email', this.taskParticipants) } ); @@ -1075,13 +1080,13 @@ console.log(this.loggeduser.Profile) this.postEvent.IsAllDayEvent = this.allDayCheck; this.postEvent.StartDate = this.setAlldayTime(this.postEvent.StartDate) this.postEvent.EndDate = this.setAlldayTimeEndDate(this.postEvent.EndDate) - + console.log('Recurso ativado!!'); } else { this.postEvent.IsAllDayEvent = this.allDayCheck; this.postEvent.EndDate = this.setAlldayTimeEndDateNotAlday(this.postEvent.EndDate) console.log('Recurso desativado'); - + } } diff --git a/src/app/shared/agenda/view-event/view-event.page.ts b/src/app/shared/agenda/view-event/view-event.page.ts index 00a7fa7de..84e265f71 100644 --- a/src/app/shared/agenda/view-event/view-event.page.ts +++ b/src/app/shared/agenda/view-event/view-event.page.ts @@ -170,7 +170,12 @@ export class ViewEventPage implements OnInit { } deleteEvent_v2() { - this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId) + console.log(this.loadedEvent.EventId) + this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId).subscribe(() => { + console.log() + },((error) => { + console.log('delete event error: ',error) + })) } async deleteEvent() {