@sumaris-net/ngx-components 2.2.1-rc10 → 2.2.1-rc12

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.
@@ -4175,7 +4175,7 @@ function disableControls(form, paths, opts) {
4175
4175
  });
4176
4176
  }
4177
4177
  function addValueInArray(arrayControl, createControl, equals, isEmpty, value, options) {
4178
- options = options || { emitEvent: true };
4178
+ const disabled = arrayControl.disabled;
4179
4179
  let hasChanged = false;
4180
4180
  let index = -1;
4181
4181
  // Search if value already exists
@@ -4195,11 +4195,17 @@ function addValueInArray(arrayControl, createControl, equals, isEmpty, value, op
4195
4195
  }
4196
4196
  else {
4197
4197
  const control = createControl(value);
4198
- arrayControl.push(control);
4198
+ // Apply parent disabled state, before to push it into the array
4199
+ // This is need to avoid parent form to be enabled
4200
+ if (disabled && control.enabled)
4201
+ control.disable({ emitEvent: false });
4202
+ else if (!disabled && control.disabled)
4203
+ control.enable({ emitEvent: false });
4204
+ arrayControl.push(control, options);
4199
4205
  hasChanged = true;
4200
4206
  }
4201
4207
  if (hasChanged) {
4202
- if (isNil(options.emitEvent) || options.emitEvent) {
4208
+ if (!options || options.emitEvent !== false) {
4203
4209
  // Mark array control dirty
4204
4210
  if (!isEmpty(value)) {
4205
4211
  arrayControl.markAsDirty();
@@ -4626,7 +4632,7 @@ class AppFormArray extends UntypedFormArray {
4626
4632
  * @param options
4627
4633
  */
4628
4634
  setValue(values, options) {
4629
- if (this.options?.allowReuseItem === false) {
4635
+ if (this.options?.allowReuseControls === false) {
4630
4636
  const disabled = this.disabled;
4631
4637
  // Clean all
4632
4638
  this.resize(0, { emitEvent: options?.emitEvent });
@@ -4648,7 +4654,7 @@ class AppFormArray extends UntypedFormArray {
4648
4654
  }
4649
4655
  }
4650
4656
  patchValue(values, options) {
4651
- if (this.options?.allowReuseItem === false) {
4657
+ if (this.options?.allowReuseControls === false) {
4652
4658
  const disabled = this.disabled;
4653
4659
  // Clean all
4654
4660
  this.resize(0, { emitEvent: options?.emitEvent });
@@ -4708,7 +4714,6 @@ class AppFormArray extends UntypedFormArray {
4708
4714
  /**
4709
4715
  * @param value
4710
4716
  * @param options
4711
- * @deprecated Use push() instead
4712
4717
  */
4713
4718
  add(value, options) {
4714
4719
  addValueInArray(this, this.createControl, this.equals, this.isEmpty, value, options);