import { EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core'; import { FormGroup, FormArray, FormBuilder } from '@angular/forms'; import { DynamicSelectFieldConfig } from '../../dynamic-select/dynamic-select-field.component'; import { ActionTemplate } from '../step-builder-action/step-builder-action.component'; import * as i0 from "@angular/core"; export declare type LoopType = 'for' | 'while'; /** * Interface for data profile option * Based on TestData model structure */ export interface DataProfileOption { id: number | string; name: string; /** Array of data sets - length determines available loop indices */ data?: any[]; /** Optional: direct data length if data array is not provided */ dataLength?: number; } export interface LoopFormData { selectedLoopType: LoopType; loopType: LoopType; selectOption?: string; dataProfile?: string | number; loopStart?: number | string; loopEnd?: number | string; runTime?: string; whileTemplate?: any; event?: any; advancedSettingsVariables?: any[]; } export declare class StepBuilderLoopComponent implements OnInit, OnChanges { private fb; /** Currently selected loop type */ loopType: LoopType; /** Options for the select option dropdown */ selectOptions: any[]; /** Options for the data profile dropdown - accepts DataProfileOption objects */ dataProfileOptions: DataProfileOption[]; /** Indicates if more data profiles are available for loading */ hasMoreDataProfiles: boolean; /** Loading state for data profiles */ isLoadingDataProfiles: boolean; /** True while parent is creating the step (API in progress); show loader on Create Step button */ isCreatingStep: boolean; /** Function to handle variable processing or custom logic. Can be passed from parent component. */ setWhileTemplateVariables: (variables: ActionTemplate) => any; /** Function to handle advanced settings variables. Can be passed from parent component. */ setAdvancedSettingsVariables: (template: ActionTemplate, testStep?: any) => any[]; /** Centralised HTML grammar computation function. Pass StepBuilderService.computeHtmlGrammar from the host app. */ computeHtmlGrammarFn?: (template: any, variables: any[]) => string; /** Emit when step is created */ createStep: EventEmitter; /** Emit when cancelled */ cancelled: EventEmitter; /** Emit when loop type changes */ loopTypeChange: EventEmitter; /** Emit when more data profiles need to be loaded */ loadMoreDataProfiles: EventEmitter; /** Emit when data profile search query changes */ searchDataProfiles: EventEmitter; whileTemplates: any[]; whileSearchPlaceholder: string; whileSearchValue: string; elementOptions: any[]; hasMoreElements: boolean; isLoadingElements: boolean; screenNameOptions: { id?: number; name: string; }[]; hasMoreScreenNames: boolean; isLoadingScreenNames: boolean; parameterOptions: any[]; hasMoreParameters: boolean; isLoadingParameters: boolean; environmentOptions: { id: string; name: string; value: string; environment: string; }[]; hasMoreEnvironments: boolean; isLoadingEnvironments: boolean; defaultTestDataProfileId?: number; defaultTestDataStartIndex?: number; defaultTestDataEndIndex?: number; isInsideForLoopStep: boolean; hasTestDataProfile: boolean; /** When true, header and button show edit/update wording (same as action step builder in debug). */ isDebug: boolean; /** Existing step when editing; used with isDebug to determine edit mode. */ testStep?: any; get isEditMode(): boolean; loadMoreElements: EventEmitter; searchElements: EventEmitter; searchElementsByScreenName: EventEmitter<{ screenNameId: number; searchTerm?: string; }>; createElement: EventEmitter; searchScreenName: EventEmitter; loadMoreScreenNames: EventEmitter; createScreenNameRequest: EventEmitter; cancelElementForm: EventEmitter; searchParameters: EventEmitter; loadMoreParameters: EventEmitter; searchEnvironments: EventEmitter; loadMoreEnvironments: EventEmitter; redirectToParameter: EventEmitter; redirectToEnvironment: EventEmitter; selectedWhileTemplate: any; selectedWhileDescription: string; selectedWhileMetadata: string; selectedLoopType: LoopType; whileChangeTemplateSignal: number; whileCancelChangeTemplateSignal: number; whileIsChangingTemplate: boolean; onWhileChangeTemplate(): void; onWhileCancelChangeTemplate(): void; loopForm: FormGroup; advancedExpanded: boolean; advancedSettingsVariables: any[]; advancedVariablesForm: FormArray; selectOptionConfig: DynamicSelectFieldConfig; dataProfileConfig: DynamicSelectFieldConfig; loopStartConfig: DynamicSelectFieldConfig; loopEndConfig: DynamicSelectFieldConfig; private selectedDataProfile; private startArray; private endArray; constructor(fb: FormBuilder); ngOnInit(): void; ngOnChanges(changes: SimpleChanges): void; /** * Resolve loop step values from step (same fallbacks as test-case-details: dataMapJson, dataMapBean.for_loop). */ private getLoopStepValue; /** * Pre-fill the form from an existing step (edit mode). Debug only — only runs when isDebug is true. * Uses same fallbacks as test-case-details (dataMapJson, dataMapBean.for_loop) and explicitly * setValue on controls so dropdowns bind (patchValue can be ignored by dynamic-select in some timing cases). */ private patchFormFromTestStep; /** * Initialize advanced settings variables for loop steps. * For loops, we currently support the same generic advanced flag: shouldSkip. */ private initAdvancedSettingsVariables; /** * Build reactive form for advanced settings variables (mirrors action step behavior). */ private buildAdvancedVariablesForm; private updateConfigs; private convertDataProfileOptionsToSelectOptions; /** * When a default test data profile is provided (e.g., testCase.testDataId) and the user is * creating a FOR loop at the root level, auto-select it and disable the dropdown. */ private applyDefaultDataProfile; private setDataProfileDisabled; /** * Handle data profile selection and update loop start/end options */ private onDataProfileChange; /** * Calculate loop indices based on selected data profile */ private updateLoopIndicesFromProfile; /** * Handle loop start change and update end options */ private onLoopStartChange; /** * Get display name for a 1-based row index from the selected profile's data array (data[index-1].name). * Returns null if no name. Matches loop-step edit mode behavior. */ private getDataRowNameForOneBasedIndex; /** * Build label for a loop index option: "setName (n)" when row has name, else "Step (n)". * Matches loop-step edit mode dropdown display. */ private getLoopIndexOptionLabel; /** * Update loop start and end config options */ private updateLoopIndexOptions; onLoopTypeChange(type: string | LoopType): void; /** * Toggle visibility of the Advanced settings section. */ toggleAdvanced(): void; /** * Handle advanced boolean variable change (e.g. shouldSkip). */ onAdvancedVariableBooleanChange(variableName: string, value: boolean): void; /** * Handle advanced non-boolean value changes (kept generic for future use, e.g. str_list). */ onAdvancedVariableValueChange(variableName: string, value: any): void; onCancel(): void; isFormValid(): boolean; onCreateStep(): void; createWhileStep(event: any): void; /** * Handle search event for data profiles */ onSearchDataProfiles(query: string): void; /** * Handle loadMore event for data profiles */ onLoadMoreDataProfiles(event: { key: string; query: string; }): void; /** * Update data profile config when loading state or hasMore changes */ private updateDataProfileConfig; private resetForm; onWhileSearchChange(event: any): void; onWhileSearchSubmit(event: any): void; onWhileSearchCleared(): void; filterWhileTemplates(query: string): void; selectWhileTemplate(template: any): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; }