Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue: Disable ArrayListRenderer add if control.data.length exceeds or is equal to maxItems #2154

Merged
15 changes: 14 additions & 1 deletion packages/vue/vue-vanilla/src/array/ArrayListRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
:class="styles.arrayList.addButton"
type="button"
@click="addButtonClick"
>
:disabled="!control.enabled ||
(arraySchema !== undefined &&
arraySchema.maxItems !== undefined &&
control.data !== undefined &&
control.data.length >= arraySchema.maxItems)"
>
Droxx marked this conversation as resolved.
Show resolved Hide resolved
+
</button>
<label :class="styles.arrayList.label">
Expand Down Expand Up @@ -50,6 +55,8 @@ import {
rankWith,
ControlElement,
schemaTypeIs,
Resolve,
JsonSchema
} from '@jsonforms/core';
import { defineComponent } from 'vue';
import {
Expand Down Expand Up @@ -77,6 +84,12 @@ const controlRenderer = defineComponent({
noData(): boolean {
return !this.control.data || this.control.data.length === 0;
},
arraySchema(): JsonSchema | undefined {
return Resolve.schema(
this.control.rootSchema,
Droxx marked this conversation as resolved.
Show resolved Hide resolved
this.control.uischema.scope,
this.control.rootSchema);
}
},
methods: {
composePaths,
Expand Down