@sumaris-net/ngx-components 0.25.19 → 0.25.20

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.
@@ -3128,23 +3128,22 @@
3128
3128
  };
3129
3129
  };
3130
3130
  SharedFormGroupValidators.dateMaxDuration = function (startDateField, endDateField, maxDuration, durationUnit) {
3131
+ var maxDurationError = { dateMaxDuration: true };
3131
3132
  return function (group) {
3132
- var endField = group.get(endDateField);
3133
3133
  var startDate = fromDateISOString(group.get(startDateField).value);
3134
+ var endField = group.get(endDateField);
3134
3135
  var endDate = fromDateISOString(endField.value);
3135
3136
  if (isNotNil(startDate) && isNotNil(endDate) && Math.abs(startDate.diff(endDate, durationUnit)) > maxDuration) {
3137
+ console.log('TODO error !');
3136
3138
  // Update end field
3137
- var endFieldErrors = endField.errors || {};
3138
- endFieldErrors['dateMaxDuration'] = true;
3139
- endField.setErrors(endFieldErrors);
3140
3139
  endField.markAsTouched({ onlySelf: true });
3140
+ endField.markAsPending();
3141
+ endField.setErrors(Object.assign(Object.assign({}, endField.errors), maxDurationError));
3141
3142
  // Return the error (should be apply to the parent form)
3142
- return { dateMaxDuration: true };
3143
+ return maxDurationError;
3143
3144
  }
3144
3145
  // OK: remove the existing on the end field
3145
- else {
3146
- SharedValidators.clearError(endField, 'dateMaxDuration');
3147
- }
3146
+ SharedValidators.clearError(endField, 'dateMaxDuration');
3148
3147
  return null;
3149
3148
  };
3150
3149
  };