Fix Bug 2294: Incorrect notification in update descriptor
[osm/NG-UI.git] / src / app / users / project-role / ProjectRoleComponent.ts
index 600cecd..0c1121b 100644 (file)
@@ -141,7 +141,6 @@ export class ProjectRoleComponent implements OnInit {
 
     /** Handle FormArray Controls @public */
     public getControls(): AbstractControl[] {
-        // tslint:disable-next-line:no-backbone-get-set-outside-model
         return (this.projectRoleForm.get('project_role_mappings') as FormArray).controls;
     }
 
@@ -185,7 +184,6 @@ export class ProjectRoleComponent implements OnInit {
     /** Set all roles and project values to the form @public */
     public loadMapping(): void {
         this.userDetails.project_role_mappings.forEach((data: ProjectRoleMappings): void => {
-            // tslint:disable-next-line:no-backbone-get-set-outside-model
             this.projectRoleFormArray = this.projectRoleForm.get('project_role_mappings') as FormArray;
             this.projectRoleFormArray.push(this.projectRoleParamsBuilder);
         });
@@ -212,6 +210,10 @@ export class ProjectRoleComponent implements OnInit {
             this.projectRoleMap.project_role_mappings.push({ project: res.project_name, role: res.role_name });
         });
         if (this.projectRoleMap.project_role_mappings.length !== 0) {
+            if (!this.projectRoleForm.dirty) {
+                this.notifierService.notify('warning', this.translateService.instant('PAGE.TOPOLOGY.DATAEMPTY'));
+                return;
+            }
             this.isLoadingResults = true;
             this.restService.patchResource(apiURLHeader, this.projectRoleMap).subscribe((result: {}): void => {
                 this.isLoadingResults = false;
@@ -229,7 +231,6 @@ export class ProjectRoleComponent implements OnInit {
 
     /** Add extra mapping and set empty project and roles @public */
     public addMapping(): void {
-        // tslint:disable-next-line:no-backbone-get-set-outside-model
         this.projectRoleFormArray = this.projectRoleForm.get('project_role_mappings') as FormArray;
         this.projectRoleFormArray.push(this.projectRoleParamsBuilder);
     }