Skip to content

Commit

Permalink
Hide required behavior properties in the object editor (#6889)
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H authored Aug 28, 2024
1 parent c7fcf48 commit d4bd5fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ export default function EventsBasedBehaviorPropertiesEditor({
>
<SelectField
margin="none"
disabled={
property.getType() === 'Behavior' &&
!property.isHidden()
}
value={
property.isHidden()
? 'Hidden'
Expand Down
1 change: 1 addition & 0 deletions newIDE/app/src/PropertiesEditor/PropertiesMapToSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const createField = (
property.getExtraInfo().size() > 0 ? property.getExtraInfo().at(0) : '';
return {
name,
isHiddenWhenThereOnlyOneChoice: true,
valueType: 'string',
getChoices: () => {
return !object || behaviorType === ''
Expand Down
24 changes: 14 additions & 10 deletions newIDE/app/src/PropertiesEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export type PrimitiveValueField =
label: string,
labelIsUserDefined?: boolean,
|}>,
isHiddenWhenThereOnlyOneChoice?: boolean,
...ValueFieldCommonProperties,
|}
| {|
Expand Down Expand Up @@ -450,16 +451,19 @@ const PropertiesEditor = ({
(field: ValueField) => {
if (!field.getChoices || !field.getValue) return;

const children = field
.getChoices()
.map(({ value, label, labelIsUserDefined }) => (
<SelectOption
key={value}
value={value}
label={label}
shouldNotTranslate={labelIsUserDefined}
/>
));
const choices = field.getChoices();
if (choices.length < 2 && field.isHiddenWhenThereOnlyOneChoice) {
return;
}

const children = choices.map(({ value, label, labelIsUserDefined }) => (
<SelectOption
key={value}
value={value}
label={label}
shouldNotTranslate={labelIsUserDefined}
/>
));

if (field.valueType === 'number') {
const { setValue } = field;
Expand Down

0 comments on commit d4bd5fc

Please sign in to comment.