Skip to content

Commit

Permalink
fix(modelbuilder) now properly show the type kind in read-only mode
Browse files Browse the repository at this point in the history
Signed-off-by: jeromesimeon <[email protected]>
jeromesimeon committed Sep 28, 2021
1 parent d899bd3 commit 00492e8
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/ui-concerto/src/components/fields.js
Original file line number Diff line number Diff line change
@@ -233,6 +233,7 @@ export const ConcertoDropdown = ({
id,
readOnly,
value,
text,
onFieldValueChange,
options,
}) => !readOnly ? (
@@ -245,7 +246,7 @@ export const ConcertoDropdown = ({
options={options}
/>
) : (
<Input type="text" readOnly value={value} key={`input-${id}`} />
<Input type="text" readOnly value={text} key={`input-${id}`} />
);

const BinaryField = ({ className, children }) => (
@@ -261,4 +262,4 @@ export const MonetaryAmount = ({ children }) => (

export const Duration = ({ children }) => (
<BinaryField className="duration">{children}</BinaryField>
);
);
3 changes: 3 additions & 0 deletions packages/ui-concerto/src/modelBuilderVisitor.js
Original file line number Diff line number Diff line change
@@ -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 (
<div className='mbObjectDeclaration' key={declaration.getName().toLowerCase()}>
<div>{name.accept(this, parameters)}</div>
@@ -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 }) => ({

0 comments on commit 00492e8

Please sign in to comment.