new api implementation

This commit is contained in:
Eudes Inácio
2024-05-29 15:43:37 +01:00
parent 08303ef8cf
commit 3769a7b8fe
12 changed files with 325 additions and 34 deletions
@@ -403,7 +403,7 @@
<ion-footer class="ion-no-border">
<ion-toolbar class="footer-toolbar px-20">
<ion-buttons slot="start">
<button class="btn-ok" fill="clear" color="#fff" (click)="save()">
<button class="btn-ok" fill="clear" color="#fff" (click)="save_v2()">
<ion-label>Gravar</ion-label>
</button>
</ion-buttons>
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, Platform } from '@ionic/angular';
import { EventAttachment } from 'src/app/models/attachment.model';
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';
@@ -27,6 +27,8 @@ 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';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -57,7 +59,7 @@ const MY_DATE_FORMAT = {
providers: [
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS },
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMAT }
{ provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMAT }
]
})
@@ -130,7 +132,8 @@ export class NewEventPage implements OnInit {
public TaskService: TaskService,
private contactsService: ContactsService,
private domSanitazerService: DomSanitizerService,
private dateAdapter: DateAdapter<Date>
private dateAdapter: DateAdapter<Date>,
private agendaDataRepository: AgendaDataRepositoryService
) {
this.loggeduser = SessionStore.user;
this.postEvent = new Event();
@@ -420,6 +423,29 @@ export class NewEventPage implements OnInit {
}
}
save_v2() {
this.injectValidation()
this.runValidation()
if (this.Form.invalid) {
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")
}
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.CalendarName,this.documents);
loader.remove()
this.modalController.dismiss();
this.hhtpErrorHandle.httpsSucessMessagge('new event')
}
async save() {
this.injectValidation()
@@ -532,6 +558,7 @@ export class NewEventPage implements OnInit {
}
//This method return calendar id
selectedCalendarId() {
if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.postEvent.CalendarName == 'Oficial') {
@@ -546,6 +573,21 @@ export class NewEventPage implements OnInit {
}
}
//This method return calendar onwner user id
selectedCalendarUserId() {
if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.postEvent.CalendarName == 'Oficial') {
return this.eventService.calendarNamesType[this.CalendarName]['OwnerId']
} else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal'] && this.postEvent.CalendarName == 'Pessoal') {
return this.eventService.calendarNamesType[this.CalendarName]['OwnerId']
} else {
return '11:11'
}
}
changeAgenda() {
setTimeout(() => {
@@ -900,13 +942,13 @@ export class NewEventPage implements OnInit {
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');
}
}