@stemy/ngx-dynamic-form 13.2.2 → 13.2.4

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.
@@ -607,7 +607,32 @@ class DynamicFormService extends DynamicFormService$1 {
607
607
  }
608
608
  return Array.isArray(res) ? res : [res];
609
609
  };
610
- return this.getFormModelForSchemaDef(this.schemas[name], customizeModels);
610
+ const schema = this.schemas[name];
611
+ const controls = await this.getFormModelForSchemaDef(schema, customizeModels);
612
+ // Check if we have controls to customize
613
+ if (!controls || controls.length == 0) {
614
+ return [];
615
+ }
616
+ // If we have then lets create a root wrapper that contains them
617
+ const config = { id: "root", group: [...controls] };
618
+ const root = await customizeModels({
619
+ id: "root",
620
+ type: "object",
621
+ properties: schema.properties
622
+ }, schema, DynamicFormGroupModel, config);
623
+ // Check if the customized root wrapper returned an array
624
+ if (Array.isArray(root)) {
625
+ controls.length = 0;
626
+ for (const model of root) {
627
+ if (model instanceof DynamicFormGroupModel) {
628
+ controls.push(...model.group);
629
+ }
630
+ else {
631
+ controls.push(model);
632
+ }
633
+ }
634
+ }
635
+ return controls.filter(t => null !== t);
611
636
  }
612
637
  async getFormModelForSchemaDef(schema, customizeModels) {
613
638
  if (!schema)
@@ -800,14 +825,14 @@ class DynamicFormService extends DynamicFormService$1 {
800
825
  let target = control;
801
826
  let model = selectModel;
802
827
  if (path.startsWith("$root")) {
803
- path = path.substr(5);
828
+ path = path.substring(5);
804
829
  while (target.parent) {
805
830
  target = target.parent;
806
831
  }
807
832
  model = root;
808
833
  }
809
834
  while (path.startsWith(".")) {
810
- path = path.substr(1);
835
+ path = path.substring(1);
811
836
  if (target.parent) {
812
837
  target = target.parent;
813
838
  }