mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Improve validation
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
import { AlertController, AnimationController, ModalController, NavParams } from '@ionic/angular';
|
||||
import { Attachment } from 'src/app/models/attachment.model';
|
||||
@@ -18,6 +19,10 @@ import { SearchPage } from '../../search/search.page';
|
||||
})
|
||||
export class EditEventPage implements OnInit {
|
||||
|
||||
|
||||
Form: FormGroup;
|
||||
validateFrom = false
|
||||
|
||||
postEvent: Event;
|
||||
isRecurring:string;
|
||||
isEventEdited: boolean;
|
||||
@@ -115,7 +120,45 @@ export class EditEventPage implements OnInit {
|
||||
this.router.navigate(['/home',this.caller]);
|
||||
}
|
||||
|
||||
|
||||
runValidation() {
|
||||
this.validateFrom = true
|
||||
}
|
||||
|
||||
injectValidation() {
|
||||
|
||||
this.Form = new FormGroup({
|
||||
Subject: new FormControl(this.postEvent.Subject, [
|
||||
Validators.required,
|
||||
// Validators.minLength(4)
|
||||
]),
|
||||
Location: new FormControl(this.postEvent.Location, [
|
||||
Validators.required,
|
||||
]),
|
||||
CalendarName: new FormControl(this.postEvent.CalendarName, [
|
||||
Validators.required
|
||||
]),
|
||||
Categories: new FormControl(this.postEvent.Categories[0], [
|
||||
Validators.required
|
||||
]),
|
||||
IsRecurring: new FormControl(this.postEvent.IsRecurring, [
|
||||
Validators.required
|
||||
]),
|
||||
// participantes: new FormControl(this.taskParticipantsCc.concat(this.taskParticipants), [
|
||||
// Validators.required
|
||||
// ]),
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
save() {
|
||||
|
||||
this.injectValidation()
|
||||
this.runValidation()
|
||||
|
||||
if(this.Form.invalid) return false
|
||||
|
||||
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc)
|
||||
try{
|
||||
this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => {
|
||||
|
||||
Reference in New Issue
Block a user