Bladeren bron

ParamDefinition.Group.isFlat support

David Sehnal 6 jaren geleden
bovenliggende
commit
4e6861e89b

+ 4 - 4
src/mol-plugin/state/actions/basic.ts

@@ -30,20 +30,20 @@ const DownloadStructure = StateAction.build({
             'pdbe-updated': PD.Group({
                 id: PD.Text('1cbs', { label: 'Id' }),
                 supportProps: PD.Boolean(false)
-            }, { isExpanded: true }),
+            }, { isFlat: true }),
             'rcsb': PD.Group({
                 id: PD.Text('1tqn', { label: 'Id' }),
                 supportProps: PD.Boolean(false)
-            }, { isExpanded: true }),
+            }, { isFlat: true }),
             'bcif-static': PD.Group({
                 id: PD.Text('1tqn', { label: 'Id' }),
                 supportProps: PD.Boolean(false)
-            }, { isExpanded: true }),
+            }, { isFlat: true }),
             'url': PD.Group({
                 url: PD.Text(''),
                 isBinary: PD.Boolean(false),
                 supportProps: PD.Boolean(false)
-            }, { isExpanded: true })
+            }, { isFlat: true })
         }, {
             options: [
                 ['pdbe-updated', 'PDBe Updated'],

+ 7 - 1
src/mol-plugin/ui/controls/parameters.tsx

@@ -284,6 +284,12 @@ export class GroupControl extends React.PureComponent<ParamProps<PD.Group<any>>,
         const params = this.props.param.params;
         const label = this.props.param.label || camelCaseToWords(this.props.name);
 
+        const controls = <ParameterControls params={params} onChange={this.onChangeParam} values={this.props.value} onEnter={this.props.onEnter} isDisabled={this.props.isDisabled} />;
+
+        if (this.props.param.isFlat) {
+            return controls;
+        }
+
         return <div className='msp-control-group-wrapper'>
             <div className='msp-control-group-header'>
                 <button className='msp-btn msp-btn-block' onClick={this.toggleExpanded}>
@@ -292,7 +298,7 @@ export class GroupControl extends React.PureComponent<ParamProps<PD.Group<any>>,
                 </button>
             </div>
             {this.state.isExpanded && <div className='msp-control-offset' style={{ display: this.state.isExpanded ? 'block' : 'none' }}>
-                <ParameterControls params={params} onChange={this.onChangeParam} values={this.props.value} onEnter={this.props.onEnter} isDisabled={this.props.isDisabled} />
+                {controls}
             </div>
             }
         </div>

+ 4 - 2
src/mol-util/param-definition.ts

@@ -141,11 +141,13 @@ export namespace ParamDefinition {
     export interface Group<T> extends Base<T> {
         type: 'group',
         params: Params,
-        isExpanded?: boolean
+        isExpanded?: boolean,
+        isFlat?: boolean
     }
-    export function Group<P extends Params>(params: P, info?: Info & { isExpanded?: boolean }): Group<Values<P>> {
+    export function Group<P extends Params>(params: P, info?: Info & { isExpanded?: boolean, isFlat?: boolean }): Group<Values<P>> {
         const ret = setInfo<Group<Values<P>>>({ type: 'group', defaultValue: getDefaultValues(params) as any, params }, info);
         if (info && info.isExpanded) ret.isExpanded = info.isExpanded;
+        if (info && info.isFlat) ret.isFlat = info.isFlat;
         return ret;
     }