From 00492e8cbaf2888d81f81ccbb3fc676256cb8bf8 Mon Sep 17 00:00:00 2001 From: jeromesimeon Date: Wed, 28 Jul 2021 11:21:53 -0400 Subject: [PATCH] fix(modelbuilder) now properly show the type kind in read-only mode Signed-off-by: jeromesimeon --- packages/ui-concerto/src/components/fields.js | 5 +++-- packages/ui-concerto/src/modelBuilderVisitor.js | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/ui-concerto/src/components/fields.js b/packages/ui-concerto/src/components/fields.js index 0b7541e..7ab772a 100644 --- a/packages/ui-concerto/src/components/fields.js +++ b/packages/ui-concerto/src/components/fields.js @@ -233,6 +233,7 @@ export const ConcertoDropdown = ({ id, readOnly, value, + text, onFieldValueChange, options, }) => !readOnly ? ( @@ -245,7 +246,7 @@ export const ConcertoDropdown = ({ options={options} /> ) : ( - + ); const BinaryField = ({ className, children }) => ( @@ -261,4 +262,4 @@ export const MonetaryAmount = ({ children }) => ( export const Duration = ({ children }) => ( {children} -); +); \ No newline at end of file diff --git a/packages/ui-concerto/src/modelBuilderVisitor.js b/packages/ui-concerto/src/modelBuilderVisitor.js index 41631fe..3e8d18a 100644 --- a/packages/ui-concerto/src/modelBuilderVisitor.js +++ b/packages/ui-concerto/src/modelBuilderVisitor.js @@ -157,6 +157,8 @@ class ModelBuilderVisitor extends ReactFormVisitor { }, key); }; + // For read only, we also need the alternative text for the Input component if it exists + const altText = declarationTypes.find(({ value: declValue }) => declValue === value.$class); return (
{name.accept(this, parameters)}
@@ -166,6 +168,7 @@ class ModelBuilderVisitor extends ReactFormVisitor { id={`${key}.$class`} key={key} value={value.$class} + text={altText ? altText.text : value.$class} readOnly={parameters.disabled} onFieldValueChange={onFieldValueChange} options={declarationTypes.map(({ value, text }) => ({