Skip to content

Commit

Permalink
Merge pull request #375 from guillotinaweb/fix_373_2.4.x
Browse files Browse the repository at this point in the history
add support for array items with different schema definitions fix #373
  • Loading branch information
ebrehault authored Dec 11, 2020
2 parents 95b5053 + f0af7fb commit cd952a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.4.11 (2020-12-03)
- fix #373: add support for array items with different schema definitions

# 2.4.10 (2020-12-03)
- fix #370: handle non existing fields in visibleIf - oneOf and allOf as null value.

# 2.4.9 (2020-11-12)
- fix #367: Fix boolean negative visiblityIf condition. Add array support for $EXP$ as visibilityIf condition.

Expand Down
2 changes: 1 addition & 1 deletion projects/schema-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-schema-form",
"version": "2.4.10",
"version": "2.4.11",
"repository": {
"type": "git",
"url": "git+https://github.com/guillotinaweb/ngx-schema-form"
Expand Down
14 changes: 13 additions & 1 deletion projects/schema-form/src/lib/model/arrayproperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ export class ArrayProperty extends PropertyGroup {
}

private addProperty() {
let newProperty = this.formPropertyFactory.createProperty(this.schema.items, this);
let itemSchema = this.schema.items
if (Array.isArray(this.schema.items)) {
const itemSchemas = this.schema.items as object[]
if (itemSchemas.length > (<FormProperty[]>this.properties).length) {
itemSchema = itemSchema[(<FormProperty[]>this.properties).length]
} else if (this.schema.additionalItems) {
itemSchema = this.schema.additionalItems
} else {
// souldn't add new items since schema is undefined for the item at its position
return null
}
}
let newProperty = this.formPropertyFactory.createProperty(itemSchema, this);
(<FormProperty[]>this.properties).push(newProperty);
return newProperty;
}
Expand Down

0 comments on commit cd952a9

Please sign in to comment.