Skip to content

Commit

Permalink
fix: set labelProperty if available
Browse files Browse the repository at this point in the history
  • Loading branch information
ingmar-stipriaan committed Dec 28, 2023
1 parent c243cc5 commit 5f71e66
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/prefabs/checkboxGroupInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ const beforeCreate = ({

let relationalProperties;
let modelProperty;
let labelPropertyId: string | undefined;
if (!(modelRelationResponse.loading || modelRelationResponse.error)) {
if (modelRelationResponse.data) {
relationalProperties = modelRelationResponse.data.model.properties;
labelPropertyId = modelRelationResponse.data.model.labelBy;
modelProperty = relationalProperties.find(
(property) => property.name === 'id',
);
Expand Down Expand Up @@ -289,6 +291,21 @@ const beforeCreate = ({
],
}),
);
if (labelPropertyId) {
setOption(
newPrefab.structure[0],
'labelProperty',
(originalOption: any) => {
return {
...originalOption,
value: {
id: labelPropertyId,
type: 'PROPERTY',
},
};
},
);
}
}
if (validate()) {
if (
Expand Down

0 comments on commit 5f71e66

Please sign in to comment.