From eafba32426d6a2a64f70f31562e2e45b57a90449 Mon Sep 17 00:00:00 2001 From: kaur-mananjeet Date: Thu, 27 Nov 2025 14:51:26 +0530 Subject: [PATCH] Edit list sweep points on inputChange and fix list popup position while editing points --- .../main-sweep/list/list.component.html | 6 ++--- .../main-sweep/list/list.component.ts | 27 +++++++++++++++++-- .../main-sweep/main-sweep.component.html | 2 ++ .../main-sweep/main-sweep.component.ts | 17 +++++++++--- .../main-sweep/step/step.component.html | 2 ++ .../main-sweep/step/step.component.ts | 23 +++++++++++++++- 6 files changed, 67 insertions(+), 10 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/list/list.component.html b/script-gen-ui/src/app/components/main-sweep/list/list.component.html index ad130f6..981ed92 100644 --- a/script-gen-ui/src/app/components/main-sweep/list/list.component.html +++ b/script-gen-ui/src/app/components/main-sweep/list/list.component.html @@ -1,4 +1,4 @@ -
+

List

@@ -12,7 +12,7 @@

List

[(ngModel)]="noOfPointsOrSteps" name="noOfPointsOrSteps" *ngIf="noOfPointsOrSteps !== undefined && noOfPointsOrSteps !== null" - (keydown.enter)="emitStepsOrPoints()" + (inputChange)="emitStepsOrPoints()" [disabled]="!isNoOfPointsOrSteps" >
@@ -39,7 +39,7 @@

List

[unit]="sweep.list[i].unit" automationID= "point-{{(i + 1)}}-{{sweep.chanName}}" [(ngModel)]="sweep.list[i].value" - (keydown.enter)="onEnter()" + (inputChange)="onChange()" style="width: 95%" [disabled]="!sweep.isDeviceValid" > diff --git a/script-gen-ui/src/app/components/main-sweep/list/list.component.ts b/script-gen-ui/src/app/components/main-sweep/list/list.component.ts index 80197e3..2d999ca 100644 --- a/script-gen-ui/src/app/components/main-sweep/list/list.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/list/list.component.ts @@ -4,6 +4,9 @@ import { Input, Output, OnChanges, + AfterViewInit, + ViewChild, + ElementRef, } from '@angular/core'; import { DragDropModule } from '@angular/cdk/drag-drop'; import { ParameterFloat } from '../../../model/sweep_data/SweepTimingConfig'; @@ -28,7 +31,8 @@ import { InputNumericComponent } from '../../controls/input-numeric/input-numeri templateUrl: './list.component.html', styleUrl: './list.component.scss', }) -export class ListComponent implements OnChanges { +export class ListComponent implements OnChanges, AfterViewInit { + @ViewChild('listPopUp', { static: false }) listPopUp: ElementRef | undefined; @Input() noOfPointsOrSteps: number | undefined; @Input() isNoOfPointsOrSteps = true; @Input() listsWithNames: { @@ -36,10 +40,12 @@ export class ListComponent implements OnChanges { list: ParameterFloat[]; isDeviceValid: boolean; }[] = []; + @Input() savedListPosition: { left: number; top: number } | null = null; @Output() closeList = new EventEmitter(); @Output() listOfPoints = new EventEmitter< { chanName: string; list: ParameterFloat[] }[] >(); + @Output() listPositionChange = new EventEmitter<{ left: number; top: number }>(); @Output() updatedStepsOrPoints = new EventEmitter(); rowIndices: number[] = []; @@ -50,6 +56,13 @@ export class ListComponent implements OnChanges { : []; } + ngAfterViewInit(): void { + if (this.listPopUp && this.savedListPosition) { + this.listPopUp.nativeElement.style.left = `${this.savedListPosition.left}px`; + this.listPopUp.nativeElement.style.top = `${this.savedListPosition.top}px`; + } + } + ngOnChanges() { console.log('listsWithNames:', this.listsWithNames); if (this.listsWithNames.length > 0) { @@ -63,15 +76,25 @@ export class ListComponent implements OnChanges { } onClose() { + this.captureListPosition(); this.closeList.emit(); } - onEnter() { + onChange() { + this.captureListPosition(); this.listOfPoints.emit(this.listsWithNames); } emitStepsOrPoints() { // emitting points or steps + this.captureListPosition(); this.updatedStepsOrPoints.emit(this.noOfPointsOrSteps); } + + captureListPosition() { + if (this.listPopUp) { + const rect = this.listPopUp.nativeElement.getBoundingClientRect(); + this.listPositionChange.emit({ left: rect.left, top: rect.top }); + } + } } diff --git a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html index 7a15b95..40f0523 100644 --- a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html +++ b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html @@ -208,6 +208,8 @@

Step

(showStepListChange)=" onShowStepListChange($event.stepId, $event.value) " + (stepListPositionChange)="onStepListPositionChange($event)" + [savedStepListPosition]="getStepListPosition(stepChannel.start_stop_channel.common_chan_attributes.uuid)" >
diff --git a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.ts b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.ts index aadd2b4..1a04b19 100644 --- a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/consistent-generic-constructors */ import { Component, ViewChildren, @@ -92,7 +93,7 @@ export class MainSweepComponent implements OnChanges { if (this.activeComponent !== component || this.activeIndex !== index) { this.isScrolled = false; } - + this.activeComponent = component; this.activeIndex = index; console.log(`Active Component: ${component}, Index: ${index}`); @@ -128,7 +129,7 @@ export class MainSweepComponent implements OnChanges { }[] = []; showStepListStates: Record = {}; // step list pop up box boolean tracking - + stepListPositions: Map = new Map(); // step list positions @Input() sweepConfig: SweepConfig | undefined; isBiasExpanded = false; @@ -147,12 +148,12 @@ export class MainSweepComponent implements OnChanges { // Handle the change in sweepConfig here if needed this.updateAll(); console.log('sweepConfig updated:', this.sweepConfig); - + // Re-scroll to active plot after data updates if there's an active component if (this.activeComponent !== null && this.activeIndex !== null) { setTimeout(() => { this.scrollToPlotInPlotContainer(this.activeComponent!, this.activeIndex!); - }, 10); + }, 10); } } } @@ -283,6 +284,14 @@ export class MainSweepComponent implements OnChanges { this.showStepListStates[stepId] = value; } + onStepListPositionChange(data: { stepId: string; position: { left: number; top: number } }) { + this.stepListPositions.set(data.stepId, data.position); + } + + getStepListPosition(stepId: string): { left: number; top: number } | null { + return this.stepListPositions.get(stepId) || null; + } + listOfSweepPointsUpdate( points: { chanName: string; list: ParameterFloat[] }[] ) { diff --git a/script-gen-ui/src/app/components/main-sweep/step/step.component.html b/script-gen-ui/src/app/components/main-sweep/step/step.component.html index a269336..f086cbf 100644 --- a/script-gen-ui/src/app/components/main-sweep/step/step.component.html +++ b/script-gen-ui/src/app/components/main-sweep/step/step.component.html @@ -193,9 +193,11 @@

[listsWithNames]="stepListsWithNames" [noOfPointsOrSteps]="stepPoints?.value" [isNoOfPointsOrSteps]="selectedDeviceOption?.isValid ?? false" + [savedListPosition]="stepListPosition" (closeList)="closeStepListPopup()" (listOfPoints)="listOfStepPointsUpdate($event)" (updatedStepsOrPoints)="stepPointsUpdatefromList($event)" + (listPositionChange)="onStepListPositionChange($event)"> >

diff --git a/script-gen-ui/src/app/components/main-sweep/step/step.component.ts b/script-gen-ui/src/app/components/main-sweep/step/step.component.ts index 0380b0f..7695f4e 100644 --- a/script-gen-ui/src/app/components/main-sweep/step/step.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/step/step.component.ts @@ -70,11 +70,18 @@ export class StepComponent implements OnChanges { @Input() listStep = false; // list checkbox @Input() showStepList = false; //edit list popup + @Input() savedStepListPosition: { left: number; top: number } | null = null; @Output() showStepListChange = new EventEmitter<{ stepId: string; value: boolean; - }>(); //storing the value main-sweep since this will be reloaded after changes + }>(); + //storing the value main-sweep since this will be reloaded after changes + @Output() stepListPositionChange = new EventEmitter<{ + stepId: string; + position: { left: number; top: number }; + }>(); list: ParameterFloat[] = []; // list of points + stepListPosition: { left: number; top: number } | null = null; @Input() stepChannel: StepChannel | undefined; @Input() stepGlobalParameters: StepGlobalParameters | undefined; @@ -155,6 +162,11 @@ export class StepComponent implements OnChanges { } this.updateStepListsWithNames(); + + // Use saved position if available + if (this.savedStepListPosition) { + this.stepListPosition = this.savedStepListPosition; + } } } @@ -282,4 +294,13 @@ export class StepComponent implements OnChanges { this.submitStepGlobalParamsData(); } } + + onStepListPositionChange(position: { left: number; top: number }) { + this.stepListPosition = position; + console.log('Step List Position Changed:', position); + this.stepListPositionChange.emit({ + stepId: this.uuid, + position: position, + }); + } }