@gravitee/ui-particles-angular 16.4.0 → 16.4.1-fix-apim-12804-16-x-4170031

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.
@@ -3275,6 +3275,9 @@ class GioFormJsonSchemaComponent {
3275
3275
  this.touched = false;
3276
3276
  this.isValid$ = new ReplaySubject(1); // Wait JsonSchema to be loaded to check if it's valid
3277
3277
  this.stateChanges$ = new Subject();
3278
+ this.isWritingValue = false;
3279
+ this.isStable = false;
3280
+ this.isUpdatingParent = false;
3278
3281
  if (ngControl) {
3279
3282
  // Setting the value accessor directly (instead of using
3280
3283
  // the providers `NG_VALUE_ACCESSOR`) to avoid running into a circular import.
@@ -3321,9 +3324,9 @@ class GioFormJsonSchemaComponent {
3321
3324
  // Sync control value with default value (without emit event) as long as the component is not ready
3322
3325
  // When formly is initialised, it emits several values as it builds up step by step.
3323
3326
  this.formGroup.valueChanges
3324
- .pipe(distinctUntilChanged(isEqual), tap(value => {
3325
- this.ngControl?.control?.reset(value, { emitEvent: false });
3326
- }), takeUntil(this.ready), takeUntil(this.unsubscribe$))
3327
+ .pipe(distinctUntilChanged(isEqual), filter(() => !this.isWritingValue && this.isStable), tap(value => {
3328
+ this.syncValueToParent(value);
3329
+ }), takeUntil(this.unsubscribe$))
3327
3330
  .subscribe();
3328
3331
  // Avoid ExpressionChangedAfterItHasBeenCheckedError on project
3329
3332
  this.changeDetectorRef.markForCheck();
@@ -3381,7 +3384,22 @@ class GioFormJsonSchemaComponent {
3381
3384
  }
3382
3385
  // From ControlValueAccessor
3383
3386
  writeValue(value) {
3387
+ if (this.isUpdatingParent)
3388
+ return;
3389
+ this.isWritingValue = true;
3390
+ this.isStable = false;
3384
3391
  this.model = cloneDeep(value) ?? {};
3392
+ setTimeout(() => {
3393
+ this.isWritingValue = false;
3394
+ this.isStable = true;
3395
+ this.syncValueToParent(this.formGroup.value);
3396
+ this.changeDetectorRef.markForCheck();
3397
+ }, 0);
3398
+ }
3399
+ syncValueToParent(value) {
3400
+ this.isUpdatingParent = true;
3401
+ this.ngControl?.control?.setValue(value, { emitEvent: false });
3402
+ this.isUpdatingParent = false;
3385
3403
  }
3386
3404
  // From ControlValueAccessor
3387
3405
  registerOnChange(fn) {
@@ -4753,10 +4771,41 @@ const toCronExpression = (cronDisplay) => {
4753
4771
  const toCronDescription = (cronExpression) => {
4754
4772
  throwIfInvalid(cronExpression);
4755
4773
  if (!isEmpty(cronExpression)) {
4756
- return Cronstrue.toString(cronExpression);
4774
+ return Cronstrue.toString(expandMisleadingSteps(cronExpression));
4757
4775
  }
4758
4776
  return '';
4759
4777
  };
4778
+ /**
4779
+ * Expand step values (like *\/50) that don't evenly divide the field range
4780
+ * into explicit value lists (like 0,50) so that cronstrue generates an accurate description.
4781
+ *
4782
+ * For example, *\/50 in the minutes field means "at every minute divisible by 50" (i.e. 0 and 50),
4783
+ * NOT "every 50 minutes". Without this fix, cronstrue would display "Every 50 minutes" which is misleading.
4784
+ *
4785
+ * See: https://github.com/bradymholt/cRonstrue/issues/360
4786
+ */
4787
+ const expandMisleadingSteps = (cronExpression) => {
4788
+ const parts = cronExpression.trim().split(/\s+/);
4789
+ // Field ranges: [seconds, minutes, hours, day-of-month, month, day-of-week]
4790
+ const fieldRanges = [60, 60, 24, undefined, undefined, undefined];
4791
+ const expandedParts = parts.map((part, index) => {
4792
+ const range = fieldRanges[index];
4793
+ if (range === undefined)
4794
+ return part;
4795
+ const match = part.match(/^\*\/(\d+)$/);
4796
+ if (!match)
4797
+ return part;
4798
+ const step = parseInt(match[1], 10);
4799
+ if (step <= 0 || range % step === 0)
4800
+ return part;
4801
+ const values = [];
4802
+ for (let v = 0; v < range; v += step) {
4803
+ values.push(v);
4804
+ }
4805
+ return values.join(',');
4806
+ });
4807
+ return expandedParts.join(' ');
4808
+ };
4760
4809
  /**
4761
4810
  * Simple validation to ensure that the cron expression has 6 parts.
4762
4811
  * Note : The full cron expression validation is done by the backend.