@stemy/ngx-dynamic-form 19.9.31 → 19.9.32

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.
@@ -40,10 +40,8 @@ function defineFormControl(target, propertyKey, cb) {
40
40
  const fields = ReflectUtils.getMetadata("dynamicFormFields", target) || new Set();
41
41
  const existing = ReflectUtils.getMetadata("dynamicFormField", target, propertyKey);
42
42
  const builder = (fb, opts, path) => {
43
- const data = ObjectUtils.isFunction(existing) ? existing(fb, opts, path) : {
44
- priority: Number.MAX_SAFE_INTEGER
45
- };
46
- return ObjectUtils.assign(data, cb(fb, opts, path) || {});
43
+ const data = ObjectUtils.isFunction(existing) ? existing(fb, opts, path) : {};
44
+ return ObjectUtils.assign(cb(fb, opts, path) || {}, data);
47
45
  };
48
46
  fields.add(propertyKey);
49
47
  ReflectUtils.defineMetadata("dynamicFormField", builder, target, propertyKey);
@@ -805,7 +803,6 @@ class DynamicFormBuilderService {
805
803
  setFieldProp(target, "options", options instanceof Observable
806
804
  ? options
807
805
  : controlValues(root).pipe(combineLatestWith(this.language), switchMap(async (a, b) => {
808
- console.log(a, b, "????", target.key, target.formControl?.value);
809
806
  const results = await factory(target, this.injector) || [];
810
807
  return this.fixSelectOptions(target, results);
811
808
  })));
@@ -1206,6 +1203,12 @@ class DynamicFormSchemaService {
1206
1203
  return !field ? [] : options.customize(field, property, schema);
1207
1204
  }
1208
1205
  async getFormFieldForProp(property, options, parent) {
1206
+ // First check property references, because a dynamic schema can be a type of object which we use for editor
1207
+ const refs = await this.openApi.getReferences(property, options.schema);
1208
+ if (refs.length > 0) {
1209
+ return this.getFormGroupConfig(property, options, parent);
1210
+ }
1211
+ // Then check the property type
1209
1212
  switch (property.type) {
1210
1213
  case "object":
1211
1214
  return this.getFormEditorConfig(property, options, parent);
@@ -1233,10 +1236,6 @@ class DynamicFormSchemaService {
1233
1236
  if (property.format == "date" || property.format == "date-time") {
1234
1237
  return this.getFormDatepickerConfig(property, options, parent);
1235
1238
  }
1236
- const refs = await this.openApi.getReferences(property, options.schema);
1237
- if (refs.length > 0) {
1238
- return this.getFormGroupConfig(property, options, parent);
1239
- }
1240
1239
  if (this.checkIsEditorProperty(property)) {
1241
1240
  return this.getFormEditorConfig(property, options, parent);
1242
1241
  }
@@ -1329,7 +1328,7 @@ class DynamicFormSchemaService {
1329
1328
  break;
1330
1329
  }
1331
1330
  const sub = property.type == "array" ? property.items || property : property;
1332
- const input = this.builder.createFormInput(property.id, {
1331
+ return this.builder.createFormInput(property.id, {
1333
1332
  ...this.getFormFieldData(property, options),
1334
1333
  type,
1335
1334
  autocomplete: property.autocomplete,
@@ -1343,7 +1342,6 @@ class DynamicFormSchemaService {
1343
1342
  indeterminate: property.indeterminate,
1344
1343
  suffix: property.suffix
1345
1344
  }, parent, options);
1346
- return input;
1347
1345
  }
1348
1346
  getFormTextareaConfig(property, options, parent) {
1349
1347
  return this.builder.createFormInput(property.id, {