Fix Bug 2294: Incorrect notification in update descriptor
[osm/NG-UI.git] / src / app / osm-repositories / osm-repo-create-update / OsmRepoCreateUpdateComponent.ts
index e653e7c..16ecadd 100644 (file)
@@ -139,7 +139,6 @@ export class OsmRepoCreateUpdateComponent implements OnInit {
     if (this.osmrepoForm.invalid) {
       return;
     }
-    this.isLoadingResults = true;
     const modalData: MODALCLOSERESPONSEDATA = {
       message: 'Done'
     };
@@ -160,10 +159,11 @@ export class OsmRepoCreateUpdateComponent implements OnInit {
 
   /** This function used to add the osm repo @public */
   public addOsmRepo(apiURLHeader: APIURLHEADER, modalData: MODALCLOSERESPONSEDATA): void {
+    this.isLoadingResults = true;
     this.restService.postResource(apiURLHeader, this.osmrepoForm.value).subscribe(() => {
+      this.isLoadingResults = false;
       this.activeModal.close(modalData);
       this.notifierService.notify('success', this.translateService.instant('PAGE.OSMREPO.CREATEDSUCCESSFULLY'));
-      this.isLoadingResults = false;
     }, (error: ERRORDATA) => {
       this.isLoadingResults = false;
       this.restService.handleError(error, 'post');
@@ -172,10 +172,15 @@ export class OsmRepoCreateUpdateComponent implements OnInit {
 
   /** This function used to Edit the osm repo @public */
   public editOsmRepo(apiURLHeader: APIURLHEADER, modalData: MODALCLOSERESPONSEDATA): void {
+    if (!this.osmrepoForm.dirty) {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.TOPOLOGY.DATAEMPTY'));
+      return;
+    }
+    this.isLoadingResults = true;
     this.restService.patchResource(apiURLHeader, this.osmrepoForm.value).subscribe(() => {
-      this.activeModal.close(modalData);
-      this.notifierService.notify('success', this.translateService.instant('PAGE.OSMREPO.UPDATEDSUCCESSFULLY'));
       this.isLoadingResults = false;
+      this.notifierService.notify('success', this.translateService.instant('PAGE.OSMREPO.UPDATEDSUCCESSFULLY'));
+      this.activeModal.close(modalData);
     }, (error: ERRORDATA) => {
       this.isLoadingResults = false;
       this.restService.handleError(error, 'patch');