From 369370aed5060bd87440ffe008c9c26c2e0063d2 Mon Sep 17 00:00:00 2001 From: Droxx Date: Tue, 11 Jul 2023 13:12:56 +0200 Subject: [PATCH] feat: support maxItems & minItems in Vue array renderer Disable add and remove buttons in Vue array renderer according to 'maxItems' and 'minItems' when the 'restrict' UI Schema option is set. Also all array buttons are now disabled if the overall control is disabled. --- .../src/examples/arrays-with-detail.ts | 3 ++ .../src/examples/arrays-with-sorting.ts | 4 +++ .../src/array/ArrayListElement.vue | 6 ++++ .../src/array/ArrayListRenderer.vue | 33 +++++++++++++++++-- .../unit/array/ArrayListRenderer.spec.ts | 22 +++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/packages/examples/src/examples/arrays-with-detail.ts b/packages/examples/src/examples/arrays-with-detail.ts index c830d55ec..a21c40853 100644 --- a/packages/examples/src/examples/arrays-with-detail.ts +++ b/packages/examples/src/examples/arrays-with-detail.ts @@ -32,6 +32,8 @@ export const schema = { occupation: { type: 'string' }, comments: { type: 'array', + minItems: 2, + maxItems: 8, items: { type: 'object', properties: { @@ -58,6 +60,7 @@ export const uischema = { scope: '#/properties/comments', options: { showSortButtons: true, + restrict: true, detail: { type: 'VerticalLayout', elements: [ diff --git a/packages/examples/src/examples/arrays-with-sorting.ts b/packages/examples/src/examples/arrays-with-sorting.ts index ee6932ade..9891c2d94 100644 --- a/packages/examples/src/examples/arrays-with-sorting.ts +++ b/packages/examples/src/examples/arrays-with-sorting.ts @@ -30,6 +30,8 @@ export const schema = { properties: { comments: { type: 'array', + minItems: 2, + maxItems: 8, items: { type: 'object', properties: { @@ -64,6 +66,7 @@ export const uischema = { scope: '#/properties/comments', options: { showSortButtons: true, + restrict: true, }, }, ], @@ -81,6 +84,7 @@ export const uischemaWithSorting = { scope: '#/properties/comments', options: { showSortButtons: true, + restrict: true, }, }, ], diff --git a/packages/vue/vue-vanilla/src/array/ArrayListElement.vue b/packages/vue/vue-vanilla/src/array/ArrayListElement.vue index 62e8da464..01df843f5 100644 --- a/packages/vue/vue-vanilla/src/array/ArrayListElement.vue +++ b/packages/vue/vue-vanilla/src/array/ArrayListElement.vue @@ -19,6 +19,7 @@ ↓