From 382104d058467abc1326bb3d5ccf09234d908a76 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Fri, 2 Jul 2021 16:05:21 +0100 Subject: [PATCH] Improve --- src/app/guards/login.guard.spec.ts | 16 +++++ src/app/guards/login.guard.ts | 25 ++++++++ src/app/home/home-routing.module.ts | 26 ++++---- src/app/index/index-routing.module.ts | 4 +- .../chat/new-group/contacts/contacts.page.ts | 2 +- .../book-meeting-modal.page.html | 2 - .../book-meeting-modal.page.ts | 40 +++++++++++- .../expedient-task-modal.page.html | 61 ++++++++++++++++--- .../expedient-task-modal.page.scss | 3 + .../expedient-task-modal.page.ts | 48 ++++++++++++++- .../agenda/edit-event/edit-event.page.ts | 2 +- .../shared/agenda/new-event/new-event.page.ts | 2 +- .../chat/new-group/contacts/contacts.page.ts | 3 +- .../edit-event.page.spec.ts | 10 +-- src/global.scss | 7 +++ 15 files changed, 212 insertions(+), 39 deletions(-) create mode 100644 src/app/guards/login.guard.spec.ts create mode 100644 src/app/guards/login.guard.ts diff --git a/src/app/guards/login.guard.spec.ts b/src/app/guards/login.guard.spec.ts new file mode 100644 index 000000000..38aefa049 --- /dev/null +++ b/src/app/guards/login.guard.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { LoginGuard } from './login.guard'; + +describe('LoginGuard', () => { + let guard: LoginGuard; + + beforeEach(() => { + TestBed.configureTestingModule({}); + guard = TestBed.inject(LoginGuard); + }); + + it('should be created', () => { + expect(guard).toBeTruthy(); + }); +}); diff --git a/src/app/guards/login.guard.ts b/src/app/guards/login.guard.ts new file mode 100644 index 000000000..b73610840 --- /dev/null +++ b/src/app/guards/login.guard.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@angular/core'; +import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class LoginGuard implements CanActivate { + constructor( private router:Router) { + + } + canActivate( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + + if(window.location.pathname == '/' && localStorage.getItem('UserData') != null ) { + this.router.navigate(['/home/events']); + return false + } else { + + return true + } + } + +} diff --git a/src/app/home/home-routing.module.ts b/src/app/home/home-routing.module.ts index 6a3858af9..fe1d52417 100644 --- a/src/app/home/home-routing.module.ts +++ b/src/app/home/home-routing.module.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { AuthGuard } from '../guards/auth.guard'; import { HomeGuard } from '../guards/home.guard'; +import { LoginGuard } from '../guards/login.guard'; import { GroupMessagesPage } from '../pages/chat/group-messages/group-messages.page'; import { MessagesPage } from '../pages/chat/messages/messages.page'; import { UserDataResolver } from '../resolvers/userData.resolver'; @@ -12,7 +13,6 @@ const routes: Routes = [ { path: 'home', component: HomePage, - /* canActivate: [HomeGuard], */ resolve: { userData: UserDataResolver }, @@ -79,16 +79,17 @@ const routes: Routes = [ ], }, - { - path: 'login', - children: [ - { - path:'', - loadChildren: ()=> import('../pages/login/login.module').then(m => m.LoginPageModule) - }, - ], + // { + // path: 'login', + // children: [ + // { + // path:'', + // loadChildren: ()=> import('../pages/login/login.module').then(m => m.LoginPageModule) + // }, + // ], + // canActivate: [LoginGuard] - }, + // }, { path: 'agenda', children: [ @@ -338,11 +339,6 @@ const routes: Routes = [ ], canActivate: [AuthGuard] - }, - { - path: '', - redirectTo: '/home/events', - pathMatch: 'full', } ]; diff --git a/src/app/index/index-routing.module.ts b/src/app/index/index-routing.module.ts index 3f55beadb..6d90f05c2 100644 --- a/src/app/index/index-routing.module.ts +++ b/src/app/index/index-routing.module.ts @@ -1,6 +1,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { IndexGuard } from '../guards/index.guard'; +import { LoginGuard } from '../guards/login.guard'; import { IndexPage } from './index.page'; const routes: Routes = [ @@ -15,7 +16,8 @@ const routes: Routes = [ }, */ { path: '', - loadChildren: ()=> import('../pages/login/login.module').then(m => m.LoginPageModule) + loadChildren: ()=> import('../pages/login/login.module').then(m => m.LoginPageModule), + canActivate: [LoginGuard] }, ] } diff --git a/src/app/pages/chat/new-group/contacts/contacts.page.ts b/src/app/pages/chat/new-group/contacts/contacts.page.ts index b2d114651..850e1a4cf 100644 --- a/src/app/pages/chat/new-group/contacts/contacts.page.ts +++ b/src/app/pages/chat/new-group/contacts/contacts.page.ts @@ -17,7 +17,7 @@ export class ContactsPage implements OnInit { headers: HttpHeaders; options:any; - contacts: Contact[] = [ + contacts = [ { first: 'Ana', last: 'Manuel', diff --git a/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.html b/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.html index eeec4d60b..b7a5cff9d 100644 --- a/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.html +++ b/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.html @@ -263,9 +263,7 @@ - -
diff --git a/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts b/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts index 51a31a44f..85e72fbce 100644 --- a/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts +++ b/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts @@ -14,7 +14,7 @@ import { User } from 'src/app/models/user.model'; import { AuthService } from 'src/app/services/auth.service'; import { AttendeesPageModal } from 'src/app/pages/events/attendees/attendees.page'; import { ToastService } from 'src/app/services/toast.service'; -import { FormControl } from '@angular/forms'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; import * as _moment from 'moment'; import * as _rollupMoment from 'moment'; import { NgxMatDateFormats } from '@angular-material-components/datetime-picker'; @@ -63,6 +63,10 @@ export class BookMeetingModalPage implements OnInit { public dateControlStart = new FormControl(moment("DD MM YYYY hh")); public dateControlEnd = new FormControl(moment("DD MM YYYY hh")); + Form: FormGroup; + validateFrom = false + + showLoader = false get dateStart () { @@ -157,8 +161,40 @@ export class BookMeetingModalPage implements OnInit { window.history.back(); } + + runValidation() { + this.validateFrom = true + } + + injectValidation() { + + this.Form = new FormGroup({ + Subject: new FormControl(this.postData.Subject, [ + Validators.required, + // Validators.minLength(4) + ]), + Location: new FormControl(this.postData.Location, [ + Validators.required, + ]), + CalendarName: new FormControl(this.postData.CalendarName, [ + Validators.required + ]) + // participantes: new FormControl(this.taskParticipantsCc.concat(this.taskParticipants), [ + // Validators.required + // ]), + + }) + } + + async saveTask(){ - // issue12323423 + + this.injectValidation() + this.runValidation() + + if(this.Form.invalid) return false + + let Attendees = this.taskParticipants.concat(this.taskParticipantsCc); this.eventBody={ diff --git a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.html b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.html index 7983b307f..7563a0b3a 100644 --- a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.html +++ b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.html @@ -4,10 +4,22 @@ {{modalTitle[taskType]}} -
+ +
+
+
+
+ Campo obrigatório. +
+
+ O campo deve ter pelo menos 4 caracteres. +
+
+
+
@@ -16,18 +28,29 @@
-
+
+ +
+
+
+ Campo obrigatório. +
+
+ O campo deve ter pelo menos 4 caracteres. +
+
+
-
+
Urgentíssimo (8 horas para a execução da tarefa) - + Normal (4 dias para a execução da tarefa) Urgente (2 dias para a execução da tarefa) @@ -54,12 +77,24 @@
+ +
+
+
+ Campo obrigatório. +
+
+ O campo deve ter pelo menos 4 caracteres. +
+
+
+
-
+
+ class="width-100 d-none d-md-block" + appearance="none"> {{type.Description}} @@ -81,6 +117,18 @@
+ +
+
+
+ Campo obrigatório. +
+
+ O campo deve ter pelo menos 4 caracteres. +
+
+
+
@@ -155,7 +203,6 @@
-
{ - let component: EditEventPage; - let fixture: ComponentFixture; + let component: EditEventToApproveComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ EditEventPage ], + declarations: [ EditEventToApproveComponent ], imports: [IonicModule.forRoot()] }).compileComponents(); - fixture = TestBed.createComponent(EditEventPage); + fixture = TestBed.createComponent(EditEventToApproveComponent); component = fixture.componentInstance; fixture.detectChanges(); })); diff --git a/src/global.scss b/src/global.scss index 5237adf0d..1d64dd900 100644 --- a/src/global.scss +++ b/src/global.scss @@ -1013,3 +1013,10 @@ ngx-mat-datetime-content{ } } + + +// angular material inputs + +.mat-form-field-infix, .mat-form-field-wrapper { + padding: 0px !important; +} \ No newline at end of file