Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
6a42580f
Commit
6a42580f
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
wip, converted param
parent
3dd1af3b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-plugin/ui/controls/parameters.tsx
+14
-2
14 additions, 2 deletions
src/mol-plugin/ui/controls/parameters.tsx
src/mol-util/param-definition.ts
+7
-2
7 additions, 2 deletions
src/mol-util/param-definition.ts
with
21 additions
and
4 deletions
src/mol-plugin/ui/controls/parameters.tsx
+
14
−
2
View file @
6a42580f
...
@@ -47,6 +47,7 @@ function controlFor(param: PD.Any): ValueControl {
...
@@ -47,6 +47,7 @@ function controlFor(param: PD.Any): ValueControl {
case
'
select
'
:
return
SelectControl
;
case
'
select
'
:
return
SelectControl
;
case
'
text
'
:
return
TextControl
;
case
'
text
'
:
return
TextControl
;
case
'
interval
'
:
return
IntervalControl
;
case
'
interval
'
:
return
IntervalControl
;
case
'
converted
'
:
return
ConvertedControl
;
case
'
group
'
:
throw
Error
(
'
Must be handled separately
'
);
case
'
group
'
:
throw
Error
(
'
Must be handled separately
'
);
case
'
mapped
'
:
throw
Error
(
'
Must be handled separately
'
);
case
'
mapped
'
:
throw
Error
(
'
Must be handled separately
'
);
}
}
...
@@ -143,7 +144,6 @@ export class SelectControl extends React.PureComponent<ValueControlProps<PD.Sele
...
@@ -143,7 +144,6 @@ export class SelectControl extends React.PureComponent<ValueControlProps<PD.Sele
}
}
}
}
export
class
MultiSelectControl
extends
React
.
PureComponent
<
ValueControlProps
<
PD
.
MultiSelect
<
any
>>>
{
export
class
MultiSelectControl
extends
React
.
PureComponent
<
ValueControlProps
<
PD
.
MultiSelect
<
any
>>>
{
onChange
=
(
e
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
onChange
=
(
e
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
const
value
=
Array
.
from
(
e
.
target
.
options
).
filter
(
option
=>
option
.
selected
).
map
(
option
=>
option
.
value
);
const
value
=
Array
.
from
(
e
.
target
.
options
).
filter
(
option
=>
option
.
selected
).
map
(
option
=>
option
.
value
);
...
@@ -152,7 +152,6 @@ export class MultiSelectControl extends React.PureComponent<ValueControlProps<PD
...
@@ -152,7 +152,6 @@ export class MultiSelectControl extends React.PureComponent<ValueControlProps<PD
}
}
render
()
{
render
()
{
// return <span>multiselect TODO</span>;
return
<
select
multiple
value
=
{
this
.
props
.
value
||
''
}
onChange
=
{
this
.
onChange
}
>
return
<
select
multiple
value
=
{
this
.
props
.
value
||
''
}
onChange
=
{
this
.
onChange
}
>
{
this
.
props
.
param
.
options
.
map
(([
value
,
label
])
=>
<
option
key
=
{
label
}
value
=
{
value
}
>
{
label
}
</
option
>)
}
{
this
.
props
.
param
.
options
.
map
(([
value
,
label
])
=>
<
option
key
=
{
label
}
value
=
{
value
}
>
{
label
}
</
option
>)
}
</
select
>;
</
select
>;
...
@@ -181,6 +180,19 @@ export class ColorControl extends React.PureComponent<ValueControlProps<PD.Color
...
@@ -181,6 +180,19 @@ export class ColorControl extends React.PureComponent<ValueControlProps<PD.Color
}
}
}
}
export
class
ConvertedControl
extends
React
.
PureComponent
<
ValueControlProps
<
PD
.
Converted
<
any
,
any
>>>
{
onChange
=
(
v
:
any
)
=>
{
console
.
log
(
'
onChange
'
,
v
)
this
.
props
.
onChange
(
this
.
props
.
param
.
toValue
(
v
));
}
render
()
{
const
Control
:
ValueControl
=
controlFor
(
this
.
props
.
param
.
param
as
PD
.
Any
);
return
<
Control
value
=
{
this
.
props
.
param
.
fromValue
(
this
.
props
.
value
)
}
param
=
{
this
.
props
.
param
}
onChange
=
{
this
.
onChange
}
onEnter
=
{
this
.
props
.
onEnter
}
isEnabled
=
{
this
.
props
.
isEnabled
}
/>
}
}
type
GroupWrapperProps
=
{
name
:
string
,
value
:
PD
.
Group
<
any
>
[
'
defaultValue
'
],
param
:
PD
.
Group
<
any
>
,
onChange
:
ParamOnChange
,
onEnter
?:
()
=>
void
,
isEnabled
?:
boolean
}
type
GroupWrapperProps
=
{
name
:
string
,
value
:
PD
.
Group
<
any
>
[
'
defaultValue
'
],
param
:
PD
.
Group
<
any
>
,
onChange
:
ParamOnChange
,
onEnter
?:
()
=>
void
,
isEnabled
?:
boolean
}
export
class
GroupControl
extends
React
.
PureComponent
<
GroupWrapperProps
>
{
export
class
GroupControl
extends
React
.
PureComponent
<
GroupWrapperProps
>
{
change
(
value
:
PD
.
Mapped
<
any
>
[
'
defaultValue
'
]
)
{
change
(
value
:
PD
.
Mapped
<
any
>
[
'
defaultValue
'
]
)
{
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/param-definition.ts
+
7
−
2
View file @
6a42580f
...
@@ -117,12 +117,17 @@ export namespace ParamDefinition {
...
@@ -117,12 +117,17 @@ export namespace ParamDefinition {
};
};
}
}
export
interface
Converted
<
T
,
C
>
extends
Base
<
T
>
{
export
interface
Converted
<
T
,
C
>
extends
Base
<
C
>
{
type
:
'
converted
'
,
type
:
'
converted
'
,
convertedControl
:
Base
<
C
>
,
param
:
Base
<
C
>
,
/** converts from prop value to display value */
fromValue
(
v
:
T
):
C
,
fromValue
(
v
:
T
):
C
,
/** converts from display value to prop value */
toValue
(
v
:
C
):
T
toValue
(
v
:
C
):
T
}
}
export
function
Converted
<
T
,
C
>
(
param
:
Base
<
C
>
,
fromValue
:
Converted
<
T
,
C
>
[
'
fromValue
'
],
toValue
:
Converted
<
T
,
C
>
[
'
toValue
'
]):
Converted
<
T
,
C
>
{
return
{
type
:
'
converted
'
,
param
,
defaultValue
:
param
.
defaultValue
,
fromValue
,
toValue
,
label
:
param
.
label
,
description
:
param
.
description
};
}
export
type
Any
=
Value
<
any
>
|
Select
<
any
>
|
MultiSelect
<
any
>
|
Boolean
|
Text
|
Color
|
Numeric
|
Interval
|
LineGraph
|
Group
<
any
>
|
Mapped
<
any
>
|
Converted
<
any
,
any
>
export
type
Any
=
Value
<
any
>
|
Select
<
any
>
|
MultiSelect
<
any
>
|
Boolean
|
Text
|
Color
|
Numeric
|
Interval
|
LineGraph
|
Group
<
any
>
|
Mapped
<
any
>
|
Converted
<
any
,
any
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment