From dc7bbea25cc20b8f563e0fb078077d85023e9e61 Mon Sep 17 00:00:00 2001 From: daniele-pecora Date: Fri, 11 Dec 2020 15:44:48 +0100 Subject: [PATCH 1/2] add support for array items with different schema definitions fix #373 --- projects/schema-form/package.json | 2 +- .../schema-form/src/lib/model/arrayproperty.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) 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; } From 86b04eb87b7933afaa4dcb55b3a80e4c417b713d Mon Sep 17 00:00:00 2001 From: daniele-pecora Date: Fri, 11 Dec 2020 15:58:03 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) 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.