@mediusinc/mng-commons 5.2.0-rc.1 → 5.2.0-rc.2

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.
@@ -1872,7 +1872,7 @@ class FieldLookupEnumDescriptor extends FieldLookupDescriptor {
1872
1872
  this._optionEnumValues = Array.isArray(options)
1873
1873
  ? fromEnumValuesAsValueArray(this._enumModel.type, options, this._enumModel.nameAsValue, this._enumModel.i18nBaseKey ?? undefined)
1874
1874
  : fromEnumConstantsAsValueArray(this._enumModel.type, this._enumModel.nameAsValue, this._enumModel.i18nBaseKey ?? undefined);
1875
- this.withLookup(() => of(this._optionEnumValues));
1875
+ this.withLookup(() => this._optionEnumValues);
1876
1876
  this.withOptionsLabelProperty('title', this._enumModel.i18nBaseKey !== null);
1877
1877
  this.withOptionsDisabledProperty('disabled');
1878
1878
  }
@@ -2297,12 +2297,8 @@ class FieldInputDescriptor extends AFieldDescriptor {
2297
2297
  }
2298
2298
  asDatePicker(opts) {
2299
2299
  this._fieldType = FieldInputTypeEnum.Datepicker;
2300
- this._datePickerFormat = opts?.format;
2301
- this._datePickerMin = opts?.min;
2302
- this._datePickerMax = opts?.max;
2303
- this._datePickerShowTime = opts?.showTime;
2304
- this._datePickerShowSeconds = opts?.showSeconds;
2305
- this._datePickerValueAsDateObj = opts?.asDateObj;
2300
+ this.withDateValidation(opts);
2301
+ this.withDatePickerDisplay(opts);
2306
2302
  this.withDateValue({
2307
2303
  asDateObj: opts?.asDateObj,
2308
2304
  utc: opts?.utc,
@@ -2369,6 +2365,17 @@ class FieldInputDescriptor extends AFieldDescriptor {
2369
2365
  this._pattern = opts?.pattern;
2370
2366
  return this;
2371
2367
  }
2368
+ withDatePickerDisplay(opts) {
2369
+ this._datePickerFormat = opts?.format;
2370
+ this._datePickerShowTime = opts?.showTime;
2371
+ this._datePickerShowSeconds = opts?.showSeconds;
2372
+ return this;
2373
+ }
2374
+ withDateValidation(opts) {
2375
+ this._datePickerMin = opts?.min;
2376
+ this._datePickerMax = opts?.max;
2377
+ return this;
2378
+ }
2372
2379
  withInputTrim(trimOption = 'both') {
2373
2380
  this._inputTrim = trimOption;
2374
2381
  return this;
@@ -2567,6 +2574,9 @@ class EditorDescriptorInst {
2567
2574
  * @param field Field descriptor.
2568
2575
  */
2569
2576
  addFieldDescriptor(field) {
2577
+ if (this._fields.some(f => f.property === field.property)) {
2578
+ throw new CommonsInternalError(`Field '${field.property}' already exists.`);
2579
+ }
2570
2580
  this.createDefaultGroup();
2571
2581
  this._fields.push(field);
2572
2582
  this._currentGroup?.addField(field);
@@ -2577,9 +2587,7 @@ class EditorDescriptorInst {
2577
2587
  * @param property Model property name.
2578
2588
  */
2579
2589
  addField(property) {
2580
- const field = new FieldInputDescriptor(this, property);
2581
- this.addFieldDescriptor(field);
2582
- return field;
2590
+ return this.addFieldUnsafe(property);
2583
2591
  }
2584
2592
  /**
2585
2593
  * Adds field by the model property name (UNSAFE). Property is not checked on editor model.