@sumaris-net/ngx-components 18.21.2 → 18.21.3

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.
@@ -3164,13 +3164,18 @@ class SharedFormGroupValidators {
3164
3164
  };
3165
3165
  }
3166
3166
  static requiredIf(fieldName, anotherFieldToCheck, opts) {
3167
- const isEmpty = opts?.isEmpty || ((control) => isNilOrBlank(control.value));
3168
- const predicate = opts?.predicate || ((control) => isNotNilOrBlank(control.value));
3167
+ const isEmpty = opts?.isEmpty || ((control) => isNilOrBlank(control?.value));
3168
+ const predicate = opts?.predicate || ((control) => isNotNilOrBlank(control?.value));
3169
3169
  return (group) => {
3170
3170
  const control = group.get(fieldName);
3171
+ // Workaround - When control is missing (can occur when form has been upgrade, but the validator is still on the form group)
3172
+ if (!control) {
3173
+ console.warn(`Unable to find control '${fieldName}' used by ShareFormGroupValidators.requiredIf validator!`);
3174
+ return null;
3175
+ }
3171
3176
  const anotherControl = anotherFieldToCheck instanceof AbstractControl ? anotherFieldToCheck : group.get(anotherFieldToCheck);
3172
3177
  if (!anotherControl)
3173
- throw new Error('Unable to find field to check!');
3178
+ throw new Error(`Unable to find control ${typeof anotherFieldToCheck === 'string' ? anotherFieldToCheck + ' ' : ''}used by ShareFormGroupValidators.requiredIf validator!`);
3174
3179
  if (isEmpty(control) && predicate(anotherControl)) {
3175
3180
  const error = { required: true };
3176
3181
  control.setErrors(error);
@@ -36564,8 +36569,7 @@ class AppPropertiesForm extends AppForm {
36564
36569
  equals: (v1, v2) => (v1?.key || v1) === (v2?.key || v2),
36565
36570
  displayWith: (value) => {
36566
36571
  // DEBUG
36567
- if (this.debug)
36568
- console.debug('[app-properties-form] Displaying value', value);
36572
+ //if (this.debug) console.debug('[app-properties-form] Displaying value', value);
36569
36573
  // Value is an object (a Property)
36570
36574
  if (value && typeof value === 'object') {
36571
36575
  return value.value;