X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Fprojects%2Fproject-create-update%2FProjectCreateUpdateComponent.ts;h=af6388df3f0a2cb0dc202813e487408592ec49de;hb=382448fed3f9d4d4cf9ac614e1275208d18b752f;hp=5eb2d5d0d7f8408edd7a80e63895e8b4b9e94fc2;hpb=2e02e7d676dc5a87e2d68437f30b6e41037ea7a4;p=osm%2FNG-UI.git diff --git a/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts b/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts index 5eb2d5d..af6388d 100644 --- a/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts +++ b/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts @@ -18,6 +18,7 @@ /** * @file Project Add Modal */ +import { isNullOrUndefined } from 'util'; import { Component, Injector, Input, OnInit } from '@angular/core'; import { AbstractControl, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; @@ -30,7 +31,6 @@ import { ProjectData, ProjectDetails, QUOTAITEM, QUOTA_ITEMS } from 'ProjectMode import { ProjectService } from 'ProjectService'; import { RestService } from 'RestService'; import { SharedService } from 'SharedService'; -import { isNullOrUndefined } from 'util'; /** * Creating component @@ -164,6 +164,12 @@ export class ProjectCreateUpdateComponent implements OnInit { message: 'Done' }; this.sharedService.cleanForm(this.projectForm); + for (const data of this.quotaItems) { + if (this.getFormControl(data.value).value > data.maxValue) { + this.notifierService.notify('error', this.translateService.instant('PAGE.PROJECT.QUOTALIMIT')); + break; + } + } if (!this.projectForm.invalid) { if (userType === 'Add') { this.createProject(); @@ -207,6 +213,10 @@ export class ProjectCreateUpdateComponent implements OnInit { } /** Edit project @public */ public editProject(): void { + if (!this.projectForm.dirty) { + this.notifierService.notify('warning', this.translateService.instant('PAGE.TOPOLOGY.DATAEMPTY')); + return; + } this.isLoadingResults = true; const apiURLHeader: APIURLHEADER = { url: environment.PROJECTS_URL + '/' + this.projectRef @@ -220,6 +230,7 @@ export class ProjectCreateUpdateComponent implements OnInit { this.isLoadingResults = false; this.projectService.setHeaderProjects(); this.notifierService.notify('success', this.translateService.instant('PAGE.PROJECT.UPDATEDSUCCESSFULLY')); + this.activeModal.close(this.modalData); }, (error: ERRORDATA): void => { this.restService.handleError(error, 'patch'); this.isLoadingResults = false; @@ -239,6 +250,7 @@ export class ProjectCreateUpdateComponent implements OnInit { /** Used to get the AbstractControl of controlName passed @private */ private getFormControl(controlName: string): AbstractControl { + // eslint-disable-next-line security/detect-object-injection return this.projectForm.controls[controlName]; }