diff --git a/CHANGELOG.md b/CHANGELOG.md index 4007ec97..563cc121 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 2.5.10 (2020-12-03) +- fix #373: add support for array items with different schema definitions + +# 2.5.9 (2020-12-03) +- fix #370: handle non existing fields in visibleIf - oneOf and allOf as null value. + # 2.5.8 (2020-11-12) - fix #367: Fix boolean negative visiblityIf condition. Add array support for $EXP$ as visibilityIf condition. diff --git a/projects/schema-form/package.json b/projects/schema-form/package.json index a742c667..906ed03b 100644 --- a/projects/schema-form/package.json +++ b/projects/schema-form/package.json @@ -1,6 +1,6 @@ { "name": "ngx-schema-form", - "version": "2.5.9", + "version": "2.5.10", "repository": { "type": "git", "url": "git+https://github.com/guillotinaweb/ngx-schema-form" diff --git a/projects/schema-form/src/lib/model/arrayproperty.ts b/projects/schema-form/src/lib/model/arrayproperty.ts index 9398ec59..77ba1b38 100644 --- a/projects/schema-form/src/lib/model/arrayproperty.ts +++ b/projects/schema-form/src/lib/model/arrayproperty.ts @@ -27,7 +27,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 > (this.properties).length) { + itemSchema = itemSchema[(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); (this.properties).push(newProperty); return newProperty; }