Skip to content

Commit 02a7e43

Browse files
TSP-1373-Edit List Sweep points without hitting 'Enter' (#52)
When editing list sweep points, no need to hit 'enter' key to apply the changes. Also, list popup position for step and sweep is preserved if it was dragged and moved within the script gen UI window.
1 parent 7634c51 commit 02a7e43

File tree

6 files changed

+67
-10
lines changed

6 files changed

+67
-10
lines changed

script-gen-ui/src/app/components/main-sweep/list/list.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="sweep-list-popup" cdkDrag cdkDragBoundary="body">
1+
<div #listPopUp class="sweep-list-popup" cdkDrag cdkDragBoundary="body">
22
<div class="sweep-list-popup-content">
33
<div class="sweep-list-popup-header" cdkDragHandle>
44
<h3 style="margin: 0">List</h3>
@@ -12,7 +12,7 @@ <h3 style="margin: 0">List</h3>
1212
[(ngModel)]="noOfPointsOrSteps"
1313
name="noOfPointsOrSteps"
1414
*ngIf="noOfPointsOrSteps !== undefined && noOfPointsOrSteps !== null"
15-
(keydown.enter)="emitStepsOrPoints()"
15+
(inputChange)="emitStepsOrPoints()"
1616
[disabled]="!isNoOfPointsOrSteps"
1717
></app-input-numeric>
1818
</div>
@@ -39,7 +39,7 @@ <h3 style="margin: 0">List</h3>
3939
[unit]="sweep.list[i].unit"
4040
automationID= "point-{{(i + 1)}}-{{sweep.chanName}}"
4141
[(ngModel)]="sweep.list[i].value"
42-
(keydown.enter)="onEnter()"
42+
(inputChange)="onChange()"
4343
style="width: 95%"
4444
[disabled]="!sweep.isDeviceValid"
4545
></app-input-plain>

script-gen-ui/src/app/components/main-sweep/list/list.component.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import {
44
Input,
55
Output,
66
OnChanges,
7+
AfterViewInit,
8+
ViewChild,
9+
ElementRef,
710
} from '@angular/core';
811
import { DragDropModule } from '@angular/cdk/drag-drop';
912
import { ParameterFloat } from '../../../model/sweep_data/SweepTimingConfig';
@@ -28,18 +31,21 @@ import { InputNumericComponent } from '../../controls/input-numeric/input-numeri
2831
templateUrl: './list.component.html',
2932
styleUrl: './list.component.scss',
3033
})
31-
export class ListComponent implements OnChanges {
34+
export class ListComponent implements OnChanges, AfterViewInit {
35+
@ViewChild('listPopUp', { static: false }) listPopUp: ElementRef | undefined;
3236
@Input() noOfPointsOrSteps: number | undefined;
3337
@Input() isNoOfPointsOrSteps = true;
3438
@Input() listsWithNames: {
3539
chanName: string;
3640
list: ParameterFloat[];
3741
isDeviceValid: boolean;
3842
}[] = [];
43+
@Input() savedListPosition: { left: number; top: number } | null = null;
3944
@Output() closeList = new EventEmitter<void>();
4045
@Output() listOfPoints = new EventEmitter<
4146
{ chanName: string; list: ParameterFloat[] }[]
4247
>();
48+
@Output() listPositionChange = new EventEmitter<{ left: number; top: number }>();
4349
@Output() updatedStepsOrPoints = new EventEmitter<number>();
4450

4551
rowIndices: number[] = [];
@@ -50,6 +56,13 @@ export class ListComponent implements OnChanges {
5056
: [];
5157
}
5258

59+
ngAfterViewInit(): void {
60+
if (this.listPopUp && this.savedListPosition) {
61+
this.listPopUp.nativeElement.style.left = `${this.savedListPosition.left}px`;
62+
this.listPopUp.nativeElement.style.top = `${this.savedListPosition.top}px`;
63+
}
64+
}
65+
5366
ngOnChanges() {
5467
console.log('listsWithNames:', this.listsWithNames);
5568
if (this.listsWithNames.length > 0) {
@@ -63,15 +76,25 @@ export class ListComponent implements OnChanges {
6376
}
6477

6578
onClose() {
79+
this.captureListPosition();
6680
this.closeList.emit();
6781
}
6882

69-
onEnter() {
83+
onChange() {
84+
this.captureListPosition();
7085
this.listOfPoints.emit(this.listsWithNames);
7186
}
7287

7388
emitStepsOrPoints() {
7489
// emitting points or steps
90+
this.captureListPosition();
7591
this.updatedStepsOrPoints.emit(this.noOfPointsOrSteps);
7692
}
93+
94+
captureListPosition() {
95+
if (this.listPopUp) {
96+
const rect = this.listPopUp.nativeElement.getBoundingClientRect();
97+
this.listPositionChange.emit({ left: rect.left, top: rect.top });
98+
}
99+
}
77100
}

script-gen-ui/src/app/components/main-sweep/main-sweep.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ <h3>Step</h3>
208208
(showStepListChange)="
209209
onShowStepListChange($event.stepId, $event.value)
210210
"
211+
(stepListPositionChange)="onStepListPositionChange($event)"
212+
[savedStepListPosition]="getStepListPosition(stepChannel.start_stop_channel.common_chan_attributes.uuid)"
211213
></app-step>
212214
</div>
213215
</div>

script-gen-ui/src/app/components/main-sweep/main-sweep.component.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/consistent-generic-constructors */
12
import {
23
Component,
34
ViewChildren,
@@ -92,7 +93,7 @@ export class MainSweepComponent implements OnChanges {
9293
if (this.activeComponent !== component || this.activeIndex !== index) {
9394
this.isScrolled = false;
9495
}
95-
96+
9697
this.activeComponent = component;
9798
this.activeIndex = index;
9899
console.log(`Active Component: ${component}, Index: ${index}`);
@@ -128,7 +129,7 @@ export class MainSweepComponent implements OnChanges {
128129
}[] = [];
129130

130131
showStepListStates: Record<string, boolean> = {}; // step list pop up box boolean tracking
131-
132+
stepListPositions: Map<string, { left: number; top: number }> = new Map(); // step list positions
132133
@Input() sweepConfig: SweepConfig | undefined;
133134

134135
isBiasExpanded = false;
@@ -147,12 +148,12 @@ export class MainSweepComponent implements OnChanges {
147148
// Handle the change in sweepConfig here if needed
148149
this.updateAll();
149150
console.log('sweepConfig updated:', this.sweepConfig);
150-
151+
151152
// Re-scroll to active plot after data updates if there's an active component
152153
if (this.activeComponent !== null && this.activeIndex !== null) {
153154
setTimeout(() => {
154155
this.scrollToPlotInPlotContainer(this.activeComponent!, this.activeIndex!);
155-
}, 10);
156+
}, 10);
156157
}
157158
}
158159
}
@@ -283,6 +284,14 @@ export class MainSweepComponent implements OnChanges {
283284
this.showStepListStates[stepId] = value;
284285
}
285286

287+
onStepListPositionChange(data: { stepId: string; position: { left: number; top: number } }) {
288+
this.stepListPositions.set(data.stepId, data.position);
289+
}
290+
291+
getStepListPosition(stepId: string): { left: number; top: number } | null {
292+
return this.stepListPositions.get(stepId) || null;
293+
}
294+
286295
listOfSweepPointsUpdate(
287296
points: { chanName: string; list: ParameterFloat[] }[]
288297
) {

script-gen-ui/src/app/components/main-sweep/step/step.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ <h3>
193193
[listsWithNames]="stepListsWithNames"
194194
[noOfPointsOrSteps]="stepPoints?.value"
195195
[isNoOfPointsOrSteps]="selectedDeviceOption?.isValid ?? false"
196+
[savedListPosition]="stepListPosition"
196197
(closeList)="closeStepListPopup()"
197198
(listOfPoints)="listOfStepPointsUpdate($event)"
198199
(updatedStepsOrPoints)="stepPointsUpdatefromList($event)"
200+
(listPositionChange)="onStepListPositionChange($event)">
199201
></app-list>
200202
</div>
201203
</div>

script-gen-ui/src/app/components/main-sweep/step/step.component.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,18 @@ export class StepComponent implements OnChanges {
7070

7171
@Input() listStep = false; // list checkbox
7272
@Input() showStepList = false; //edit list popup
73+
@Input() savedStepListPosition: { left: number; top: number } | null = null;
7374
@Output() showStepListChange = new EventEmitter<{
7475
stepId: string;
7576
value: boolean;
76-
}>(); //storing the value main-sweep since this will be reloaded after changes
77+
}>();
78+
//storing the value main-sweep since this will be reloaded after changes
79+
@Output() stepListPositionChange = new EventEmitter<{
80+
stepId: string;
81+
position: { left: number; top: number };
82+
}>();
7783
list: ParameterFloat[] = []; // list of points
84+
stepListPosition: { left: number; top: number } | null = null;
7885

7986
@Input() stepChannel: StepChannel | undefined;
8087
@Input() stepGlobalParameters: StepGlobalParameters | undefined;
@@ -155,6 +162,11 @@ export class StepComponent implements OnChanges {
155162
}
156163

157164
this.updateStepListsWithNames();
165+
166+
// Use saved position if available
167+
if (this.savedStepListPosition) {
168+
this.stepListPosition = this.savedStepListPosition;
169+
}
158170
}
159171
}
160172

@@ -282,4 +294,13 @@ export class StepComponent implements OnChanges {
282294
this.submitStepGlobalParamsData();
283295
}
284296
}
297+
298+
onStepListPositionChange(position: { left: number; top: number }) {
299+
this.stepListPosition = position;
300+
console.log('Step List Position Changed:', position);
301+
this.stepListPositionChange.emit({
302+
stepId: this.uuid,
303+
position: position,
304+
});
305+
}
285306
}

0 commit comments

Comments
 (0)