From 5d7fba694757edd7a07befa85176f2e0f9b1f2ff Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 13 May 2024 14:58:48 +0200 Subject: [PATCH] doc: add Text type to components Fix #911 --- lunatic-schema.json | 16 ++++++++++++++++ src/stories/loop/source-with-header.json | 9 +++++++-- src/type.source.ts | 7 ++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lunatic-schema.json b/lunatic-schema.json index 273a4ae46..a2f8895a9 100644 --- a/lunatic-schema.json +++ b/lunatic-schema.json @@ -347,6 +347,9 @@ }, { "$ref": "#/$defs/ComponentSummaryDefinition" + }, + { + "$ref": "#/$defs/ComponentText" } ] }, @@ -979,6 +982,19 @@ } ] }, + "ComponentText": { + "type": "object", + "properties": { + "componentType": { + "type": "string", + "const": "Text" + }, + "label": { + "$ref": "#/$defs/VTLExpression" + } + }, + "required": ["componentType", "label"] + }, "Variable": { "discriminator": { "propertyName": "variableType" diff --git a/src/stories/loop/source-with-header.json b/src/stories/loop/source-with-header.json index 4aa64e6d0..96dad9a16 100644 --- a/src/stories/loop/source-with-header.json +++ b/src/stories/loop/source-with-header.json @@ -16,8 +16,9 @@ "id": "loop-prenom", "componentType": "RosterForLoop", "header": [ - { "headerCell": true, "label": { "value": "Prénom", "type": "VTL" } }, - { "headerCell": true, "label": { "value": "Age", "type": "VTL" } } + { "headerCell": true, "label": { "value": "", "type": "TXT" } }, + { "headerCell": true, "label": { "value": "Prénom", "type": "TXT" } }, + { "headerCell": true, "label": { "value": "Age", "type": "TXT" } } ], "label": { "value": "\"Ajouter un individu\"", "type": "VTL|MD" }, "conditionFilter": { "value": "true", "type": "VTL" }, @@ -28,6 +29,10 @@ }, "page": "1", "components": [ + { + "componentType": "Text", + "label": { "value": "\"Individu \" || cast(GLOBAL_ITERATION_INDEX, string)", "type": "VTL" } + }, { "componentType": "Input", "conditionFilter": { "value": "true", "type": "VTL" }, diff --git a/src/type.source.ts b/src/type.source.ts index 1a3a0d991..631934c26 100644 --- a/src/type.source.ts +++ b/src/type.source.ts @@ -32,7 +32,8 @@ export type ComponentDefinition = | ComponentCheckboxOneDefinition | ComponentSuggesterDefinition | ComponentPairWiseLinksDefinition - | ComponentSummaryDefinition; + | ComponentSummaryDefinition + | ComponentText; export type ComponentInputDefinition = ComponentInputDefinition1 & { componentType: 'Input' | 'Textarea'; maxLength?: number; @@ -371,6 +372,10 @@ export interface ControlDefinition { export interface ResponseDefinition { name: string; } +export interface ComponentText { + componentType: 'Text'; + label: VTLExpression; +} export interface SuggesterDefinition { /** * Name of the list (will be used as storeName for suggester)