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
749e366c
Commit
749e366c
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added 'Invalid Option' to select control; tweaked assembly param
parent
573eedd7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-plugin/state/transforms/model.ts
+7
-6
7 additions, 6 deletions
src/mol-plugin/state/transforms/model.ts
src/mol-plugin/ui/controls/parameters.tsx
+1
-0
1 addition, 0 deletions
src/mol-plugin/ui/controls/parameters.tsx
src/mol-util/string.ts
+12
-0
12 additions, 0 deletions
src/mol-util/string.ts
with
20 additions
and
6 deletions
src/mol-plugin/state/transforms/model.ts
+
7
−
6
View file @
749e366c
...
@@ -14,6 +14,7 @@ import { compile } from 'mol-script/runtime/query/compiler';
...
@@ -14,6 +14,7 @@ import { compile } from 'mol-script/runtime/query/compiler';
import
{
MolScriptBuilder
}
from
'
mol-script/language/builder
'
;
import
{
MolScriptBuilder
}
from
'
mol-script/language/builder
'
;
import
{
StateObject
}
from
'
mol-state
'
;
import
{
StateObject
}
from
'
mol-state
'
;
import
{
PluginContext
}
from
'
mol-plugin/context
'
;
import
{
PluginContext
}
from
'
mol-plugin/context
'
;
import
{
stringToWords
}
from
'
mol-util/string
'
;
export
{
TrajectoryFromMmCif
}
export
{
TrajectoryFromMmCif
}
type
TrajectoryFromMmCif
=
typeof
TrajectoryFromMmCif
type
TrajectoryFromMmCif
=
typeof
TrajectoryFromMmCif
...
@@ -90,21 +91,21 @@ const StructureAssemblyFromModel = PluginStateTransform.BuiltIn({
...
@@ -90,21 +91,21 @@ const StructureAssemblyFromModel = PluginStateTransform.BuiltIn({
to
:
SO
.
Molecule
.
Structure
,
to
:
SO
.
Molecule
.
Structure
,
params
(
a
)
{
params
(
a
)
{
const
model
=
a
.
data
;
const
model
=
a
.
data
;
const
ids
=
model
.
symmetry
.
assemblies
.
map
(
a
=>
[
a
.
id
,
a
.
id
]
as
[
string
,
string
]);
const
ids
=
model
.
symmetry
.
assemblies
.
map
(
a
=>
[
a
.
id
,
`
${
a
.
id
}
:
${
stringToWords
(
a
.
details
)}
`
]
as
[
string
,
string
]);
return
{
id
:
PD
.
makeOptional
(
PD
.
Select
(
ids
.
length
?
ids
[
0
][
0
]
:
''
,
ids
,
{
label
:
'
Asm Id
'
,
description
:
'
Assembly Id
'
}))
};
if
(
!
ids
.
length
)
ids
.
push
([
'
deposited
'
,
'
Deposited
'
])
return
{
id
:
PD
.
Select
(
ids
[
0
][
0
],
ids
,
{
label
:
'
Asm Id
'
,
description
:
'
Assembly Id
'
})
};
}
}
})({
})({
apply
({
a
,
params
},
plugin
:
PluginContext
)
{
apply
({
a
,
params
},
plugin
:
PluginContext
)
{
return
Task
.
create
(
'
Build Assembly
'
,
async
ctx
=>
{
return
Task
.
create
(
'
Build Assembly
'
,
async
ctx
=>
{
let
id
=
(
params
.
id
||
''
).
trim
();
const
model
=
a
.
data
;
const
model
=
a
.
data
;
if
(
!
id
&&
model
.
symmetry
.
assemblies
.
length
)
id
=
model
.
symmetry
.
assemblies
[
0
]
.
id
;
const
id
=
params
.
id
;
const
asm
=
ModelSymmetry
.
findAssembly
(
model
,
id
);
const
asm
=
ModelSymmetry
.
findAssembly
(
model
,
id
);
if
(
id
&&
!
asm
)
throw
new
Error
(
`Assembly '
${
id
}
' not found`
);
if
(
id
!==
'
deposited
'
&&
!
asm
)
throw
new
Error
(
`Assembly '
${
id
}
' not found`
);
const
base
=
Structure
.
ofModel
(
model
);
const
base
=
Structure
.
ofModel
(
model
);
if
(
!
asm
)
{
if
(
!
asm
)
{
plugin
.
log
.
warn
(
`Model '
${
a
.
label
}
' has no assembly, returning de
fault
structure.`
);
plugin
.
log
.
warn
(
`Model '
${
a
.
label
}
' has no assembly, returning de
posited
structure.`
);
const
label
=
{
label
:
a
.
data
.
label
,
description
:
structureDesc
(
base
)
};
const
label
=
{
label
:
a
.
data
.
label
,
description
:
structureDesc
(
base
)
};
return
new
SO
.
Molecule
.
Structure
(
base
,
label
);
return
new
SO
.
Molecule
.
Structure
(
base
,
label
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/ui/controls/parameters.tsx
+
1
−
0
View file @
749e366c
...
@@ -203,6 +203,7 @@ export class SelectControl extends SimpleParam<PD.Select<string | number>> {
...
@@ -203,6 +203,7 @@ export class SelectControl extends SimpleParam<PD.Select<string | number>> {
}
}
renderControl
()
{
renderControl
()
{
return
<
select
value
=
{
this
.
props
.
value
||
''
}
onChange
=
{
this
.
onChange
}
disabled
=
{
this
.
props
.
isDisabled
}
>
return
<
select
value
=
{
this
.
props
.
value
||
''
}
onChange
=
{
this
.
onChange
}
disabled
=
{
this
.
props
.
isDisabled
}
>
{
!
this
.
props
.
param
.
options
.
some
(
e
=>
e
[
0
]
===
this
.
props
.
value
)
?
<
option
key
=
{
this
.
props
.
value
}
value
=
{
this
.
props
.
value
}
>
{
`Invalid Option '
${
this
.
props
.
value
}
'`
}
</
option
>
:
''
}
{
this
.
props
.
param
.
options
.
map
(([
value
,
label
])
=>
<
option
key
=
{
value
}
value
=
{
value
}
>
{
label
}
</
option
>)
}
{
this
.
props
.
param
.
options
.
map
(([
value
,
label
])
=>
<
option
key
=
{
value
}
value
=
{
value
}
>
{
label
}
</
option
>)
}
</
select
>;
</
select
>;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/string.ts
+
12
−
0
View file @
749e366c
...
@@ -25,4 +25,16 @@ export const upperCase = (str: string) => str.toUpperCase()
...
@@ -25,4 +25,16 @@ export const upperCase = (str: string) => str.toUpperCase()
/** Uppercase the first character of each word. */
/** Uppercase the first character of each word. */
export
function
capitalize
(
str
:
string
)
{
export
function
capitalize
(
str
:
string
)
{
return
str
.
toLowerCase
().
replace
(
/^
\w
|
\s\w
/g
,
upperCase
);
return
str
.
toLowerCase
().
replace
(
/^
\w
|
\s\w
/g
,
upperCase
);
}
export
function
splitSnakeCase
(
str
:
string
)
{
return
str
.
replace
(
/_/g
,
'
'
)
}
export
function
snakeCaseToWords
(
str
:
string
)
{
return
capitalize
(
splitSnakeCase
(
str
))
}
export
function
stringToWords
(
str
:
string
)
{
return
capitalize
(
splitCamelCase
(
splitSnakeCase
(
str
)))
}
}
\ No newline at end of file
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