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
@@ -365,7 +365,7 @@
<ion-footer class="ion-no-border">
<ion-toolbar class="width-100 d-flex justify-space-between 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>
@@ -16,6 +16,7 @@ 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';
@Component({
selector: 'app-edit-event',
@@ -103,10 +104,14 @@ export class EditEventPage implements OnInit {
public ThemeService: ThemeService,
private httpErrorHandle: HttpErrorHandle,
private contactsService: ContactsService,
private domSanitizeService: DomSanitizerService
) {}
private domSanitizeService: DomSanitizerService,
private agendaDataRepository: AgendaDataRepositoryService
) {
}
ngOnInit() {
console.log(this.postEvent)
this._postEvent = this.postEvent
this.allDayCheck = this.postEvent.IsAllDayEvent;
if(!this.restoreTemporaryData()) {
@@ -337,6 +342,19 @@ export class EditEventPage implements OnInit {
}
save_v2() {
this.injectValidation()
this.runValidation()
if (this.Form.invalid) {
return false
}
this.showLoader = true;
this.agendaDataRepository.updateEvent(this._postEvent.EventId, this._postEvent,this._postEvent.CalendarName,this.loadedEventAttachments);
this.showLoader = false;
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
}
async save() {
@@ -418,7 +418,7 @@
<ion-toolbar class="footer-toolbar">
<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>
@@ -8,7 +8,7 @@ import { ModalController } from '@ionic/angular';
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchList } from "src/app/models/search-document";
import { EventAttachment } from 'src/app/models/attachment.model';
import { EventAttachment, EventAttachment_v2 } from 'src/app/models/attachment.model';
import { ToastService } from 'src/app/services/toast.service';
import { LoginUserRespose } from 'src/app/models/user.model';
@@ -37,6 +37,8 @@ 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 { ChangeProfileService } from 'src/app/services/change-profile.service';
import { EventInputDTO } from 'src/app/services/Repositorys/Agenda/agendaDataModels';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -151,6 +153,7 @@ export class NewEventPage implements OnInit {
private contactsService: ContactsService,
private domSanitazerService: DomSanitizerService,
private changeProfileService: ChangeProfileService,
private agendaDataRepository: AgendaDataRepositoryService
) {
this.dateAdapter.setLocale('pt');
this.loggeduser = SessionStore.user;
@@ -507,6 +510,28 @@ 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
}
let 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.afterSave();
this.hhtpErrorHandle.httpsSucessMessagge('new event')
}
async save() {
this.injectValidation()
@@ -19,6 +19,7 @@ import { NavigationExtras, Router } from '@angular/router';
import { EventController } from 'src/app/controller/event'
import { DateService } from 'src/app/services/date.service';
import { EventList } from 'src/app/models/agenda/AgendaEventList';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
@Component({
selector: 'app-view-event',
templateUrl: './view-event.page.html',
@@ -65,7 +66,8 @@ export class ViewEventPage implements OnInit {
public ThemeService: ThemeService,
private httpErrorHandle: HttpErrorHandle,
private router: Router,
private dateService: DateService
private dateService: DateService,
private agendaDataRepository: AgendaDataRepositoryService
) {
this.isEventEdited = false;
this.loadedEvent = new Event();
@@ -129,6 +131,7 @@ export class ViewEventPage implements OnInit {
this.eventsService.getEvent(this.eventId).subscribe(res => {
res = this.dateService.fixDate(res as any)
console.log('loaded event', res)
this.loadedEvent = res;
this.setTimeZone()
@@ -181,7 +184,7 @@ export class ViewEventPage implements OnInit {
{
text: 'Sim',
handler: () => {
this.deleteEvent();
this.deleteEvent_v2();
}
},
{
@@ -195,6 +198,10 @@ export class ViewEventPage implements OnInit {
});
}
deleteEvent_v2() {
this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId)
}
async deleteEvent() {
if (this.loadedEvent.IsRecurring) {