@cqa-lib/cqa-ui 1.1.395 → 1.1.396

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31143,7 +31143,7 @@ class TemplateVariablesFormComponent {
31143
31143
  this.cdr.markForCheck();
31144
31144
  }
31145
31145
  ngOnChanges(changes) {
31146
- var _a, _b, _c;
31146
+ var _a, _b, _c, _d;
31147
31147
  if (changes['templateVariables'] || changes['variablesForm'] || changes['elementOptions'] ||
31148
31148
  changes['hasMoreElements'] || changes['isLoadingElements'] ||
31149
31149
  changes['parameterOptions'] || changes['hasMoreParameters'] || changes['isLoadingParameters'] ||
@@ -31378,24 +31378,26 @@ class TemplateVariablesFormComponent {
31378
31378
  this.cdr.markForCheck();
31379
31379
  }
31380
31380
  }
31381
- // If parameter options changed and we have default values, try to initialize them.
31382
- // IMPORTANT: only do this on the FIRST time parameterOptions arrive, otherwise every
31383
- // search (which also updates parameterOptions) would re-run initializeTestDataVariables()
31384
- // and reset the test-data type dropdown back to 'plain-text'.
31381
+ // Re-run initializeTestDataVariables whenever parameterOptions changes and there are still
31382
+ // variables that need initialization (have profileId but missing profile name or dataSet).
31383
+ // We do NOT use firstChange here because the saved profile may arrive in a second API call
31384
+ // (id@<profileId>) after the initial paginated list, so firstChange would miss it.
31385
+ // The inner some() guard ensures we only re-run when variables are still incomplete,
31386
+ // preventing unnecessary re-runs on user search updates.
31385
31387
  if (changes['parameterOptions'] &&
31386
- changes['parameterOptions'].firstChange &&
31387
31388
  this.parameterOptions.length > 0 &&
31388
- ((this.defaultTestDataProfileId && this.defaultTestDataStartIndex != null) ||
31389
- (
31390
- // Check if any variable has selectedTestDataProfileId but is missing selectedTestDataProfile or selectedDataSet
31391
- // This happens when loading a saved step - setTemplateVariables sets the ID, but we need parameterOptions to set the name and data set
31392
- (_b = this.templateVariables) === null || _b === void 0 ? void 0 : _b.some(v => this.needsDataTypeDropdown(v) &&
31393
- v.dataType === 'parameter' &&
31394
- v.selectedTestDataProfileId != null &&
31395
- (!v.selectedTestDataProfile || !v.selectedDataSet))) ||
31389
+ (
31390
+ // Check if any variable has selectedTestDataProfileId but is missing selectedTestDataProfile or selectedDataSet
31391
+ // This happens when loading a saved step - setTemplateVariables sets the ID, but we need parameterOptions to set the name and data set
31392
+ ((_b = this.templateVariables) === null || _b === void 0 ? void 0 : _b.some(v => this.needsDataTypeDropdown(v) &&
31393
+ v.dataType === 'parameter' &&
31394
+ v.selectedTestDataProfileId != null &&
31395
+ (!v.selectedTestDataProfile || !v.selectedDataSet))) ||
31396
+ (this.defaultTestDataProfileId && this.defaultTestDataStartIndex != null &&
31397
+ ((_c = this.templateVariables) === null || _c === void 0 ? void 0 : _c.some(v => this.needsDataTypeDropdown(v) && v.dataType === 'parameter' && !v.selectedTestDataProfile))) ||
31396
31398
  // The extra uninitialized-variable check below is debug-only: only run it in debug mode
31397
31399
  // to avoid double-initialising variables in non-debug step-builder flows.
31398
- (this.isDebug && ((_c = this.templateVariables) === null || _c === void 0 ? void 0 : _c.some(v => this.needsDataTypeDropdown(v) && v.dataType === 'parameter' && !v.selectedTestDataProfile))))) {
31400
+ (this.isDebug && ((_d = this.templateVariables) === null || _d === void 0 ? void 0 : _d.some(v => this.needsDataTypeDropdown(v) && v.dataType === 'parameter' && !v.selectedTestDataProfile))))) {
31399
31401
  console.log("parameterOptions InitializeTestDataVariables", changes['parameterOptions']);
31400
31402
  // Re-initialize to set default values now that parameterOptions are available
31401
31403
  this.initializeTestDataVariables();
@@ -31606,14 +31608,22 @@ class TemplateVariablesFormComponent {
31606
31608
  // For environment type, parse the value to extract environment and parameter
31607
31609
  if (dataType === 'environment') {
31608
31610
  // Environment values are in format *|parameterName|
31609
- // We need to find which environment this parameter belongs to
31610
31611
  const paramName = rawValue;
31611
31612
  if (paramName) {
31612
- // Find the environment that contains this parameter
31613
- const envOption = this.environmentOptions.find(env => env.name === paramName);
31613
+ // If we have a saved environmentId, use it for an exact match (env-{id}-{param})
31614
+ // to avoid selecting the wrong environment when multiple environments share param names.
31615
+ let envOption;
31616
+ if (variable.selectedEnvironmentId != null) {
31617
+ const exactId = `env-${variable.selectedEnvironmentId}-${paramName}`;
31618
+ envOption = this.environmentOptions.find(env => env.id === exactId);
31619
+ }
31620
+ // Fallback: match by param name only (legacy / first-time save)
31621
+ if (!envOption) {
31622
+ envOption = this.environmentOptions.find(env => env.name === paramName);
31623
+ }
31614
31624
  if (envOption) {
31615
31625
  variable.selectedEnvironment = envOption.environment;
31616
- // Extract and store environment ID
31626
+ // Extract and store environment ID from the option id
31617
31627
  const idMatch = envOption.id.match(/env-(\d+)-/);
31618
31628
  if (idMatch && idMatch[1]) {
31619
31629
  variable.selectedEnvironmentId = parseInt(idMatch[1], 10);