@sumaris-net/ngx-components 2.1.4-rc2 → 2.1.4-rc3

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.
@@ -4631,20 +4631,29 @@ class AppFormArray extends UntypedFormArray {
4631
4631
  add(value, options) {
4632
4632
  return pushValueInArray(this, this.createControl, this.equals, this.isEmpty, value, options);
4633
4633
  }
4634
- push(value, options) {
4635
- return pushValueInArray(this, () => this.createControl(value), this.equals, this.isEmpty, value, options);
4636
- }
4637
- removeAt(index) {
4634
+ removeAt(index, options) {
4638
4635
  // Do not remove if last criterion
4639
4636
  if (!this._allowEmptyArray && this.length === 1) {
4640
- return clearValueInArray(this, this.isEmpty, index);
4637
+ this.clearAt(index, options);
4641
4638
  }
4642
4639
  else {
4643
- return removeValueInArray(this, this.isEmpty, index);
4640
+ super.removeAt(index, options);
4644
4641
  }
4645
4642
  }
4646
- clearAt(index) {
4647
- return clearValueInArray(this, this.isEmpty, index);
4643
+ clearAt(index, options) {
4644
+ const control = this.at(index);
4645
+ if (this.isEmpty(control.value))
4646
+ return; // skip (not need to clear)
4647
+ if (control instanceof UntypedFormGroup) {
4648
+ copyEntity2Form({}, control, options);
4649
+ }
4650
+ else if (control instanceof UntypedFormArray) {
4651
+ control.setValue([], options);
4652
+ }
4653
+ else {
4654
+ control.setValue(null, options);
4655
+ }
4656
+ this.markAsDirty();
4648
4657
  }
4649
4658
  isLast(index) {
4650
4659
  return (this.length - 1) === index;