Skip to content

Commit b49785e

Browse files
martinRenoupre-commit-ci[bot]trungleduc
authored
Generate dropdowns for operands on operator properties (#371)
* Generate dropdowns for operands on operator properties * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update packages/base/src/panelview/objectproperties.tsx Co-authored-by: Duc Trung Le <[email protected]> * Fix type --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Duc Trung Le <[email protected]>
1 parent dabfb28 commit b49785e

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

packages/base/src/panelview/objectproperties.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,37 @@ class ObjectPropertiesReact extends React.Component<IProps, IStates> {
288288
};
289289

290290
render(): React.ReactNode {
291+
// Fill form schema with available objects
292+
const form_schema = this.state.schema;
293+
if (form_schema) {
294+
const allObjects = this.props.cpModel.jcadModel
295+
?.getAllObject()
296+
.reduce((all: string[], o) => {
297+
o.name !== this.state.selectedObject && all.push(o.name);
298+
return all;
299+
}, []);
300+
for (const prop in form_schema['properties']) {
301+
const fcType = form_schema['properties'][prop]['fcType'];
302+
if (fcType) {
303+
const propDef = form_schema['properties'][prop];
304+
switch (fcType) {
305+
case 'App::PropertyLink':
306+
propDef['enum'] = allObjects;
307+
break;
308+
case 'App::PropertyLinkList':
309+
propDef['items']['enum'] = allObjects;
310+
break;
311+
default:
312+
}
313+
}
314+
}
315+
}
316+
291317
return this.state.schema && this.state.selectedObjectData ? (
292318
<ObjectPropertiesForm
293319
parentType="panel"
294320
filePath={`${this.state.filePath}::panel`}
295-
schema={this.state.schema}
321+
schema={form_schema}
296322
sourceData={this.state.selectedObjectData}
297323
syncData={(properties: { [key: string]: any }) => {
298324
this.syncObjectProperties(this.state.selectedObject, properties);

0 commit comments

Comments
 (0)