ng-configcat-publicapi-ui 5.6.3 → 5.6.4

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.
@@ -35,7 +35,7 @@ import { config, edit } from 'ace-builds/src-min-noconflict/ace';
35
35
  import 'ace-builds/src-noconflict/mode-json';
36
36
  import 'ace-builds/src-noconflict/theme-tomorrow';
37
37
  import 'ace-builds/src-noconflict/theme-github_dark';
38
- import { moveItemInArray, CdkDropList, CdkDrag, CdkDragHandle } from '@angular/cdk/drag-drop';
38
+ import { CdkDropList, CdkDrag, CdkDragHandle } from '@angular/cdk/drag-drop';
39
39
  import { MatDivider } from '@angular/material/divider';
40
40
  import { MatCheckbox } from '@angular/material/checkbox';
41
41
  import { CdkCopyToClipboard, Clipboard } from '@angular/cdk/clipboard';
@@ -2326,6 +2326,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImpor
2326
2326
  }]
2327
2327
  }], propDecorators: { selectedItem: [{ type: i0.Input, args: [{ isSignal: true, alias: "appDeselect", required: false }] }] } });
2328
2328
 
2329
+ // When moving items in a formArray, we should not do it via the recommended way on the angular dragndrop documentations.
2330
+ // It recommends a simple moveItemInArray(formArray.controls). But doing that will not fire change events, etc.
2331
+ // This item is working on the FormArray's recommended way to push, remove items - do it directly on the FormArray.
2332
+ // It is not an array, so we cannot call moveItemInArray on it, but it has methods to modify the array.
2333
+ function moveItemInFormArray(formArray, previousIndex, currentIndex) {
2334
+ if (previousIndex === currentIndex)
2335
+ return;
2336
+ const draggedItem = formArray.at(previousIndex);
2337
+ formArray.removeAt(previousIndex);
2338
+ // Insert at the drop index. CDK's currentIndex is the intended insertion position
2339
+ // after removal, inserting at event.currentIndex places the control in the
2340
+ // position equivalent to the CDK moveItemInArray behavior.
2341
+ formArray.insert(currentIndex, draggedItem);
2342
+ formArray.markAsDirty();
2343
+ }
2344
+
2329
2345
  class RolloutRulesComponent {
2330
2346
  constructor() {
2331
2347
  this.dialog = inject(MatDialog);
@@ -2375,9 +2391,7 @@ class RolloutRulesComponent {
2375
2391
  this.formGroup().controls.rolloutRules.markAsDirty();
2376
2392
  }
2377
2393
  onDrop(event) {
2378
- const rolloutRules = this.formGroup().controls.rolloutRules.controls;
2379
- moveItemInArray(rolloutRules, event.previousIndex, event.currentIndex);
2380
- this.formGroup().markAsDirty();
2394
+ moveItemInFormArray(this.formGroup().controls.rolloutRules, event.previousIndex, event.currentIndex);
2381
2395
  }
2382
2396
  attributeChanged(eventTarget, comparisonAttribute) {
2383
2397
  const event = eventTarget.value;
@@ -4566,8 +4580,7 @@ class VariationsDialogComponent {
4566
4580
  });
4567
4581
  }
4568
4582
  dropTable(event) {
4569
- moveItemInArray(this.formGroup.controls.predefinedVariations.controls, event.previousIndex, event.currentIndex);
4570
- this.formGroup.controls.predefinedVariations.markAsDirty();
4583
+ moveItemInFormArray(this.formGroup.controls.predefinedVariations, event.previousIndex, event.currentIndex);
4571
4584
  this.setDataSource();
4572
4585
  }
4573
4586
  getColorIndex(row, index) {
@@ -6596,9 +6609,7 @@ class EvaluationFormulaComponent {
6596
6609
  return true;
6597
6610
  }
6598
6611
  onDrop(event) {
6599
- const targetingRules = this.formGroup().controls.targetingRules.controls;
6600
- moveItemInArray(targetingRules, event.previousIndex, event.currentIndex);
6601
- this.formGroup().markAsDirty();
6612
+ moveItemInFormArray(this.formGroup().controls.targetingRules, event.previousIndex, event.currentIndex);
6602
6613
  this.recalcAddButtons.emit();
6603
6614
  }
6604
6615
  isDragDisabled(targetingRule) {
@@ -7457,7 +7468,7 @@ class FeatureFlagItemComponent extends BaseComponent {
7457
7468
  return dialogRef.afterClosed();
7458
7469
  }
7459
7470
  canDeactivate() {
7460
- return !this.formGroup?.dirty;
7471
+ return !this.formGroupDirty();
7461
7472
  }
7462
7473
  viewVariations(event) {
7463
7474
  if (!this.canDeactivate()) {