Skip to content
Snippets Groups Projects
Commit 8e0ca6ba authored by Daniel Nemergut's avatar Daniel Nemergut
Browse files

Merge branch 'ws2903-sort-tiles-and-planes-checkboxes' into 'development'

WS-2903 Sort tiles and planes checkboxes

See merge request !29
parents e027596a 39662da6
No related branches found
No related tags found
2 merge requests!32Merge 2.4.4 UI to main,!29WS-2903 Sort tiles and planes checkboxes
...@@ -72,7 +72,9 @@ export class ExecutionDetailComponent implements OnInit, OnDestroy, OnChanges { ...@@ -72,7 +72,9 @@ export class ExecutionDetailComponent implements OnInit, OnDestroy, OnChanges {
} }
if (this.canSelectPlanes()) { if (this.canSelectPlanes()) {
this.jobService.getPlanes(job.job_id).subscribe((response: object) => { this.jobService.getPlanes(job.job_id).subscribe((response: object) => {
this.planeKeys = Object.keys(response); // Sort the returned planes before making form controls from them
this.planeKeys = Object.keys(response)
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
for (const controlName in this.planesFormGroup.controls) { for (const controlName in this.planesFormGroup.controls) {
this.planesFormGroup.removeControl(controlName); this.planesFormGroup.removeControl(controlName);
} }
...@@ -87,11 +89,16 @@ export class ExecutionDetailComponent implements OnInit, OnDestroy, OnChanges { ...@@ -87,11 +89,16 @@ export class ExecutionDetailComponent implements OnInit, OnDestroy, OnChanges {
} }
refreshTiles(newTiles: Tile[]) { refreshTiles(newTiles: Tile[]) {
this.tiles = new Map<string, Tile>(newTiles.map(tile => {return [tile.name, tile]})); // Sort newTiles by name before they're stored on this component
for (const controlName in this.tilesFormGroup.controls) { this.tiles = new Map<string, Tile>(
this.tilesFormGroup.removeControl(controlName); newTiles
} .sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }))
Array.from(this.tiles.keys()).forEach(tile => this.tilesFormGroup.addControl(tile, new FormControl(true))); .map(tile => [tile.name, tile])
);
for (const controlName in this.tilesFormGroup.controls) {
this.tilesFormGroup.removeControl(controlName);
}
Array.from(this.tiles.keys()).forEach(tile => this.tilesFormGroup.addControl(tile, new FormControl(true)));
} }
copyToClipboard(text: string): void { copyToClipboard(text: string): void {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment