feature[TW19341]: PLE Web Usability updates

- Modify get versions rest call to accept sort query parameter
- Update action service to use sort option
- Update cfg, cfg group and feature components to close subscription to dropdowns after dialog is closed
- Update edit cfg data type to reflect changes in api for config group

Change-Id: Id1962f3b074f0a097c1b25544cd888fbfde92b93
Signed-off-by: Audrey Denk <audrey.e.denk@boeing.com>
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsTeamWfEndpointApi.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsTeamWfEndpointApi.java
index 25b8ab7..d4e56e4 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsTeamWfEndpointApi.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsTeamWfEndpointApi.java
@@ -23,6 +23,7 @@
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import org.eclipse.osee.ats.api.version.IAtsVersion;
 import org.eclipse.osee.framework.core.data.UserId;
@@ -45,7 +46,7 @@
    @IdentityView
    @Path("{aiId}/version")
    @Produces({MediaType.APPLICATION_JSON})
-   Collection<IAtsVersion> getVersionsbyTeamDefinition(@PathParam("aiId") String aiId);
+   Collection<IAtsVersion> getVersionsbyTeamDefinition(@PathParam("aiId") String aiId, @QueryParam("sort") String sort);
 
    @GET
    @Path("{id}")
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsTeamWfEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsTeamWfEndpointImpl.java
index 48e3d00..28301d8 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsTeamWfEndpointImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsTeamWfEndpointImpl.java
@@ -85,13 +85,18 @@
    }
 
    @Override
-   public Collection<IAtsVersion> getVersionsbyTeamDefinition(String aiId) {
+   public Collection<IAtsVersion> getVersionsbyTeamDefinition(String aiId, String sort) {
       IAtsActionableItem ai = atsApi.getActionableItemService().getActionableItem(aiId);
       IAtsTeamDefinition impactedTeamDef = atsApi.getTeamDefinitionService().getImpactedTeamDef(ai);
       IAtsTeamDefinition teamDefHoldingVersions =
          atsApi.getTeamDefinitionService().getTeamDefinitionHoldingVersions(impactedTeamDef);
 
-      return atsApi.getVersionService().getVersions(teamDefHoldingVersions);
+      ArrayList<IAtsVersion> versionsList =
+         new ArrayList<>(atsApi.getVersionService().getVersions(teamDefHoldingVersions));
+      if ("true".equals(sort)) {
+         Collections.sort(versionsList);
+      }
+      return versionsList;
    }
 
    @Override
diff --git a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/applicability-table/applicability-table.component.ts b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/applicability-table/applicability-table.component.ts
index 9d9ea90..32a2814 100644
--- a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/applicability-table/applicability-table.component.ts
+++ b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/applicability-table/applicability-table.component.ts
@@ -5,7 +5,7 @@
 import { MatSort } from '@angular/material/sort';
 import { MatTableDataSource } from '@angular/material/table';
 import { BehaviorSubject, Subject } from 'rxjs';
-import { share } from 'rxjs/operators';
+import { share, take } from 'rxjs/operators';
 import { PlConfigCurrentBranchService } from '../../services/pl-config-current-branch.service';
 import { PlConfigUIStateService } from '../../services/pl-config-uistate.service';
 import { extendedFeature, trackableFeature } from '../../types/features/base';
@@ -123,7 +123,7 @@
       value.toLowerCase() === event.value.toLowerCase()
     ) > -1) {
       let body = feature.name + " = " + event.value;
-      this.currentBranchService.modifyConfiguration(featureId, body,this.sorter.groupList).subscribe((responses: response[]) => {
+      this.currentBranchService.modifyConfiguration(featureId, body,this.sorter.groupList).pipe(take(1)).subscribe((responses: response[]) => {
       });
     } else {
       this.uiStateService.error="Error: No matching applicability."
@@ -161,7 +161,7 @@
     })
     dialogRef.afterClosed().subscribe((result: PLEditFeatureData) => {
       if (result && result.editable) {
-        this.currentBranchService.modifyFeature(result.feature).subscribe((response: response) => {
+        this.currentBranchService.modifyFeature(result.feature).pipe(take(1)).subscribe((response: response) => {
         })
       }
     })
@@ -183,7 +183,7 @@
             configurationGroup: result.group && result.group || '',
             productApplicabilities:result.productApplicabilities||[]
           };
-          this.currentBranchService.editConfigurationDetails(body).subscribe((response) => { 
+          this.currentBranchService.editConfigurationDetails(body).pipe(take(1)).subscribe((response) => { 
           })
         }
       })
@@ -206,7 +206,7 @@
             id: result.configGroup.id,
             name: result.configGroup.name,
             configurations: cfgArray
-          }).subscribe();
+          }).pipe(take(1)).subscribe();
         }
       })
     }
diff --git a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/configuration-dropdown/configuration-dropdown.component.ts b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/configuration-dropdown/configuration-dropdown.component.ts
index c3e3182..46525ad 100644
--- a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/configuration-dropdown/configuration-dropdown.component.ts
+++ b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/configuration-dropdown/configuration-dropdown.component.ts
@@ -1,7 +1,7 @@
 import { Component, OnInit } from '@angular/core';
 import { MatDialog } from '@angular/material/dialog';
 import { Observable } from 'rxjs';
-import { share } from 'rxjs/operators';
+import { share, take } from 'rxjs/operators';
 import { PlConfigBranchService } from '../../services/pl-config-branch-service.service';
 import { PlConfigCurrentBranchService } from '../../services/pl-config-current-branch.service';
 import { PlConfigUIStateService } from '../../services/pl-config-uistate.service';
@@ -33,7 +33,7 @@
   }
 
   deleteConfig(config: {id:string , name:string}) {
-    this.currentBranchService.deleteConfiguration(config.id).subscribe((response: response[]) => {
+    this.currentBranchService.deleteConfiguration(config.id).pipe(take(1)).subscribe((response: response[]) => {
       this.uiStateService.deleteReqConfig = config.name;
     })
   }
@@ -50,11 +50,11 @@
         let body: editConfiguration = {
           ...result.currentConfig,
           copyFrom: result.copyFrom.id && result.copyFrom.id || '',
-          configurationGroup: result.group && result.group || '',
+          configurationGroup: result.group.id && result.group.id || '',
           productApplicabilities:result.productApplicabilities||[]
         };
         apiRequest = this.currentBranchService.editConfigurationDetails(body);
-        apiRequest.subscribe((response:response) => {
+        apiRequest.pipe(take(1)).subscribe((response:response) => {
         }); 
       }
     });
@@ -65,7 +65,7 @@
       currentBranch: this.branchId?.toString(),
       copyFrom: { id: '0', name: '', hasFeatureApplicabilities:false, productApplicabilities:[] },
       title: '',
-      group: '',
+      group: { id: '0', name: ''},
       productApplicabilities:[],
     }
     const dialogRef = this.dialog.open(AddConfigurationDialogComponent, {
@@ -74,7 +74,7 @@
     });
     dialogRef.afterClosed().subscribe((result) => {
       if (result) {
-        this.currentBranchService.addConfiguration({ name: result.title, copyFrom: result.copyFrom.id, configurationGroup: result.group.id, productApplicabilities:result.productApplicabilities }).subscribe((response: response) => {
+        this.currentBranchService.addConfiguration({ name: result.title, copyFrom: result.copyFrom.id, configurationGroup: result.group.id, productApplicabilities:result.productApplicabilities }).pipe(take(1)).subscribe((response: response) => {
         });
       }
     })
@@ -94,7 +94,7 @@
           copyFrom: result.ConfigurationToCopyFrom.id && result.ConfigurationToCopyFrom.id || '',
           configurationGroup: result.group && result.group || ''
         };
-        this.currentBranchService.editConfigurationDetails(body).subscribe((response:response) => {
+        this.currentBranchService.editConfigurationDetails(body).pipe(take(1)).subscribe((response:response) => {
         }); 
       }
     })
diff --git a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/configuration-group-dropdown/configuration-group-dropdown.component.ts b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/configuration-group-dropdown/configuration-group-dropdown.component.ts
index 147569f..d478a12 100644
--- a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/configuration-group-dropdown/configuration-group-dropdown.component.ts
+++ b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/configuration-group-dropdown/configuration-group-dropdown.component.ts
@@ -1,6 +1,6 @@
 import { Component, OnInit } from '@angular/core';
 import { MatDialog } from '@angular/material/dialog';
-import { share } from 'rxjs/operators';
+import { share, take } from 'rxjs/operators';
 import { PlConfigCurrentBranchService } from '../../services/pl-config-current-branch.service';
 import { PlConfigUIStateService } from '../../services/pl-config-uistate.service';
 import { cfgGroup } from '../../types/pl-config-branch';
@@ -29,17 +29,17 @@
       minWidth: '60%'
     });
     dialogRef.afterClosed().subscribe((result:addCfgGroup) => {
-      this.currentBranchService.addConfigurationGroup({name:result.title}).subscribe((response) => {
+      this.currentBranchService.addConfigurationGroup({name:result.title}).pipe(take(1)).subscribe((response) => {
       })
     });
   }
   deleteGroup(id: string) {
-    this.currentBranchService.deleteConfigurationGroup(id).subscribe((response) => {
+    this.currentBranchService.deleteConfigurationGroup(id).pipe(take(1)).subscribe((response) => {
     })
   }
   synchronizeGroups(groups:cfgGroup[]) {
     groups.forEach((value) => {
-      this.currentBranchService.synchronizeGroup(value.id).subscribe((response) => {
+      this.currentBranchService.synchronizeGroup(value.id).pipe(take(1)).subscribe((response) => {
         if (response.success) {
           this.uiStateService.updateReqConfig = true;
         }
diff --git a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/feature-dropdown/feature-dropdown.component.ts b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/feature-dropdown/feature-dropdown.component.ts
index 3d4f77b..214d5b1 100644
--- a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/feature-dropdown/feature-dropdown.component.ts
+++ b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/components/feature-dropdown/feature-dropdown.component.ts
@@ -1,7 +1,7 @@
 import { Component, OnInit } from '@angular/core';
 import { MatDialog } from '@angular/material/dialog';
 import { Observable } from 'rxjs';
-import { share} from 'rxjs/operators';
+import { share, take} from 'rxjs/operators';
 import { PlConfigCurrentBranchService } from '../../services/pl-config-current-branch.service';
 import { PlConfigUIStateService } from '../../services/pl-config-uistate.service';
 import { trackableFeature } from '../../types/features/base';
@@ -37,7 +37,7 @@
   }
 
   deleteFeature(feature: trackableFeature) {
-    this.currentBranchService.deleteFeature(feature.id).subscribe((response: response) => {
+    this.currentBranchService.deleteFeature(feature.id).pipe(take(1)).subscribe((response: response) => {
       if (response.success) {
         this.uiStateService.updateReqConfig = true;
       }
@@ -56,7 +56,7 @@
     })
     dialogRef.afterClosed().subscribe((result: PLEditFeatureData) => {
       if (result) {
-        this.currentBranchService.modifyFeature(result.feature).subscribe((response: response) => {
+        this.currentBranchService.modifyFeature(result.feature).pipe(take(1)).subscribe((response: response) => {
         })
       }
     })
@@ -75,7 +75,7 @@
     });
     dialogRef.afterClosed().subscribe((result: PLAddFeatureData) => {
       if (result) {
-        this.currentBranchService.addFeature(result.feature).subscribe((response: response) => {
+        this.currentBranchService.addFeature(result.feature).pipe(take(1)).subscribe((response: response) => {
         }); 
       }
     });
diff --git a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/services/pl-config-action.service.ts b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/services/pl-config-action.service.ts
index 479691b..a6ccde8 100644
--- a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/services/pl-config-action.service.ts
+++ b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/services/pl-config-action.service.ts
@@ -32,7 +32,7 @@
     return this.http.post<transitionResponse>(apiURL+'/ats/action/transition', body);
   }
   public getVersions(arbId: string): Observable<targetedVersion[]> {
-    return this.http.get<targetedVersion[]>(apiURL+'/ats/teamwf/' + arbId + '/version');
+    return this.http.get<targetedVersion[]>(apiURL+'/ats/teamwf/' + arbId + '/version?sort=true');
   }
   public createBranch(body: newActionInterface): Observable<newActionResponse> {
     return this.http.post<newActionResponse>(apiURL+'/ats/action/branch', body);
diff --git a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/types/pl-edit-config-data.ts b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/types/pl-edit-config-data.ts
index a3887c8..e16b85f 100644
--- a/plugins/org.eclipse.osee.web/src/app/ple/plconfig/types/pl-edit-config-data.ts
+++ b/plugins/org.eclipse.osee.web/src/app/ple/plconfig/types/pl-edit-config-data.ts
@@ -1,4 +1,4 @@
-import { view } from "./pl-config-applicui-branch-mapping";
+import { ConfigGroup, view } from "./pl-config-applicui-branch-mapping";
 
 export class PLEditConfigData implements ConfigData {
     constructor(branch?: string,currentConfig?:view,ConfigurationToCopyFrom?:view, productApplicabilities?:string[], editable?:boolean) {
@@ -22,7 +22,7 @@
     currentBranch = '';
     currentConfig = { id: '', name: '' };
     copyFrom = { id: '', name: '', hasFeatureApplicabilities:false };
-    group = '';
+    group = { id: '', name: '' };
     editable: boolean = false;
 }
 export interface copyFrom {
@@ -34,6 +34,6 @@
 interface ConfigData {
     currentBranch: string | undefined,
     copyFrom: view
-    group: string
+    group: ConfigGroup
     productApplicabilities: string[];
 }
\ No newline at end of file