Sfoglia il codice sorgente

added fieldLabels to param defs

Alexander Rose 6 anni fa
parent
commit
9d0815a258

+ 3 - 3
src/mol-plugin/ui/controls/parameters.tsx

@@ -344,9 +344,9 @@ export class Vec3Control extends React.PureComponent<ParamProps<PD.Vec3>, { isEx
     state = { isExpanded: false }
 
     components = {
-        0: PD.Numeric(0, void 0, { label: 'X' }),
-        1: PD.Numeric(0, void 0, { label: 'Y' }),
-        2: PD.Numeric(0, void 0, { label: 'Z' })
+        0: PD.Numeric(0, void 0, { label: (this.props.param.fieldLabels && this.props.param.fieldLabels.x) || 'X' }),
+        1: PD.Numeric(0, void 0, { label: (this.props.param.fieldLabels && this.props.param.fieldLabels.y) || 'Y' }),
+        2: PD.Numeric(0, void 0, { label: (this.props.param.fieldLabels && this.props.param.fieldLabels.z) || 'Z' })
     }
 
     change(value: PD.MultiSelect<any>['defaultValue']) {

+ 3 - 1
src/mol-util/param-definition.ts

@@ -14,13 +14,15 @@ export namespace ParamDefinition {
     export interface Info {
         label?: string,
         description?: string,
+        fieldLabels?: { [name: string]: string },
         isHidden?: boolean,
     }
 
     function setInfo<T extends Info>(param: T, info?: Info): T {
         if (!info) return param;
-        if (info.description) param.description = info.description;
         if (info.label) param.label = info.label;
+        if (info.description) param.description = info.description;
+        if (info.fieldLabels) param.fieldLabels = info.fieldLabels;
         if (info.isHidden) param.isHidden = info.isHidden;
         return param;
     }