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
9f803b22
Commit
9f803b22
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-plugin: state tree tweaks
parent
6769158e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-plugin/ui/state-tree.tsx
+33
-34
33 additions, 34 deletions
src/mol-plugin/ui/state-tree.tsx
with
33 additions
and
34 deletions
src/mol-plugin/ui/state-tree.tsx
+
33
−
34
View file @
9f803b22
...
@@ -58,22 +58,26 @@ class StateTreeNode extends PluginComponent<{ nodeRef: string, state: State }, {
...
@@ -58,22 +58,26 @@ class StateTreeNode extends PluginComponent<{ nodeRef: string, state: State }, {
});
});
}
}
toggleExpanded
=
(
e
:
React
.
MouseEvent
<
HTMLElement
>
)
=>
{
e
.
preventDefault
();
PluginCommands
.
State
.
ToggleExpanded
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
}
render
()
{
render
()
{
const
cellState
=
this
.
props
.
state
.
tree
.
cellStates
.
get
(
this
.
props
.
nodeRef
)
;
const
cellState
=
this
.
cellState
;
const
expander
=
<>
const
expander
=
<>
[
<
a
href
=
'#'
onClick
=
{
e
=>
{
[
<
a
href
=
'#'
onClick
=
{
this
.
toggleExpanded
}
>
{
cellState
.
isCollapsed
?
'
+
'
:
'
-
'
}
</
a
>
]
e
.
preventDefault
();
PluginCommands
.
State
.
ToggleExpanded
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
}
}
>
{
cellState
.
isCollapsed
?
'
+
'
:
'
-
'
}
</
a
>
]
</>;
</>;
const
children
=
this
.
props
.
state
.
tree
.
children
.
get
(
this
.
props
.
nodeRef
);
const
children
=
this
.
props
.
state
.
tree
.
children
.
get
(
this
.
props
.
nodeRef
);
return
<
div
>
return
<
div
>
{
children
.
size
===
0
?
void
0
:
expander
}
<
StateTreeNodeLabel
nodeRef
=
{
this
.
props
.
nodeRef
}
state
=
{
this
.
props
.
state
}
/>
{
children
.
size
===
0
?
void
0
:
expander
}
<
StateTreeNodeLabel
nodeRef
=
{
this
.
props
.
nodeRef
}
state
=
{
this
.
props
.
state
}
/>
{
cellState
.
isCollapsed
||
children
.
size
===
0
{
children
.
size
===
0
?
void
0
?
void
0
:
<
div
style
=
{
{
marginLeft
:
'
7px
'
,
paddingLeft
:
'
3px
'
,
borderLeft
:
'
1px solid #999
'
}
}
>
{
children
.
map
(
c
=>
<
StateTreeNode
state
=
{
this
.
props
.
state
}
nodeRef
=
{
c
!
}
key
=
{
c
}
/>)
}
</
div
>
:
<
div
style
=
{
{
marginLeft
:
'
7px
'
,
paddingLeft
:
'
3px
'
,
borderLeft
:
'
1px solid #999
'
,
display
:
cellState
.
isCollapsed
?
'
none
'
:
'
block
'
}
}
>
{
children
.
map
(
c
=>
<
StateTreeNode
state
=
{
this
.
props
.
state
}
nodeRef
=
{
c
!
}
key
=
{
c
}
/>)
}
</
div
>
}
}
</
div
>;
</
div
>;
}
}
...
@@ -92,58 +96,53 @@ class StateTreeNodeLabel extends PluginComponent<{ nodeRef: string, state: State
...
@@ -92,58 +96,53 @@ class StateTreeNodeLabel extends PluginComponent<{ nodeRef: string, state: State
let
isCurrent
=
this
.
is
(
this
.
props
.
state
.
behaviors
.
currentObject
.
value
);
let
isCurrent
=
this
.
is
(
this
.
props
.
state
.
behaviors
.
currentObject
.
value
);
this
.
subscribe
(
this
.
plugin
.
state
.
behavior
.
currentObject
,
e
=>
{
this
.
subscribe
(
this
.
plugin
.
state
.
behavior
.
currentObject
,
e
=>
{
let
update
=
false
;
if
(
this
.
is
(
e
))
{
if
(
this
.
is
(
e
))
{
if
(
!
isCurrent
)
{
if
(
!
isCurrent
)
{
isCurrent
=
true
;
isCurrent
=
true
;
update
=
true
;
this
.
forceUpdate
()
;
}
}
}
else
if
(
isCurrent
)
{
}
else
if
(
isCurrent
)
{
isCurrent
=
false
;
isCurrent
=
false
;
update
=
true
;
// have to check the node wasn't remove
}
if
(
e
.
state
.
tree
.
transforms
.
has
(
this
.
props
.
nodeRef
))
this
.
forceUpdate
();
if
(
update
&&
e
.
state
.
tree
.
transforms
.
has
(
this
.
props
.
nodeRef
))
{
this
.
forceUpdate
();
}
}
});
});
}
}
setCurrent
=
(
e
:
React
.
MouseEvent
<
HTMLElement
>
)
=>
{
e
.
preventDefault
();
PluginCommands
.
State
.
SetCurrentObject
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
}
remove
=
(
e
:
React
.
MouseEvent
<
HTMLElement
>
)
=>
{
e
.
preventDefault
();
PluginCommands
.
State
.
RemoveObject
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
}
toggleVisible
=
(
e
:
React
.
MouseEvent
<
HTMLElement
>
)
=>
{
e
.
preventDefault
();
PluginCommands
.
State
.
ToggleVisibility
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
}
render
()
{
render
()
{
const
n
=
this
.
props
.
state
.
tree
.
transforms
.
get
(
this
.
props
.
nodeRef
)
!
;
const
n
=
this
.
props
.
state
.
tree
.
transforms
.
get
(
this
.
props
.
nodeRef
)
!
;
const
cell
=
this
.
props
.
state
.
cells
.
get
(
this
.
props
.
nodeRef
)
!
;
const
cell
=
this
.
props
.
state
.
cells
.
get
(
this
.
props
.
nodeRef
)
!
;
const
isCurrent
=
this
.
is
(
this
.
props
.
state
.
behaviors
.
currentObject
.
value
);
const
isCurrent
=
this
.
is
(
this
.
props
.
state
.
behaviors
.
currentObject
.
value
);
const
remove
=
<>
[
<
a
href
=
'#'
onClick
=
{
e
=>
{
const
remove
=
<>
[
<
a
href
=
'#'
onClick
=
{
this
.
remove
}
>
X
</
a
>
]
</>
e
.
preventDefault
();
PluginCommands
.
State
.
RemoveObject
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
}
}
>
X
</
a
>
]
</>
let
label
:
any
;
let
label
:
any
;
if
(
cell
.
status
!==
'
ok
'
||
!
cell
.
obj
)
{
if
(
cell
.
status
!==
'
ok
'
||
!
cell
.
obj
)
{
const
name
=
(
n
.
transformer
.
definition
.
display
&&
n
.
transformer
.
definition
.
display
.
name
)
||
n
.
transformer
.
definition
.
name
;
const
name
=
(
n
.
transformer
.
definition
.
display
&&
n
.
transformer
.
definition
.
display
.
name
)
||
n
.
transformer
.
definition
.
name
;
label
=
<><
b
>
{
cell
.
status
}
</
b
>
<
a
href
=
'#'
onClick
=
{
e
=>
{
label
=
<><
b
>
{
cell
.
status
}
</
b
>
<
a
href
=
'#'
onClick
=
{
this
.
setCurrent
}
>
{
name
}
</
a
>
:
<
i
>
{
cell
.
errorText
}
</
i
></>;
e
.
preventDefault
();
PluginCommands
.
State
.
SetCurrentObject
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
}
}
>
{
name
}
</
a
>
:
<
i
>
{
cell
.
errorText
}
</
i
></>;
}
else
{
}
else
{
const
obj
=
cell
.
obj
as
PluginStateObject
.
Any
;
const
obj
=
cell
.
obj
as
PluginStateObject
.
Any
;
label
=
<><
a
href
=
'#'
onClick
=
{
e
=>
{
label
=
<><
a
href
=
'#'
onClick
=
{
this
.
setCurrent
}
>
{
obj
.
label
}
</
a
>
{
obj
.
description
?
<
small
>
{
obj
.
description
}
</
small
>
:
void
0
}
</>;
e
.
preventDefault
();
PluginCommands
.
State
.
SetCurrentObject
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
}
}
>
{
obj
.
label
}
</
a
>
{
obj
.
description
?
<
small
>
{
obj
.
description
}
</
small
>
:
void
0
}
</>;
}
}
const
cellState
=
this
.
props
.
state
.
tree
.
cellStates
.
get
(
this
.
props
.
nodeRef
);
const
cellState
=
this
.
props
.
state
.
tree
.
cellStates
.
get
(
this
.
props
.
nodeRef
);
const
visibility
=
<>
[
<
a
href
=
'#'
onClick
=
{
this
.
toggleVisible
}
>
{
cellState
.
isHidden
?
'
H
'
:
'
V
'
}
</
a
>
]
</>;
if
(
!
cellState
)
console
.
log
(
'
missing state
'
,
this
.
props
.
nodeRef
,
this
.
props
.
state
.
tree
,
this
.
props
.
state
.
tree
.
transforms
.
has
(
this
.
props
.
nodeRef
));
const
visibility
=
<>
[
<
a
href
=
'#'
onClick
=
{
e
=>
{
e
.
preventDefault
();
PluginCommands
.
State
.
ToggleVisibility
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
}
}
>
{
cellState
.
isHidden
?
'
H
'
:
'
V
'
}
</
a
>
]
</>;
return
<>
return
<>
{
remove
}{
visibility
}
{
isCurrent
?
<
b
>
{
label
}
</
b
>
:
label
}
{
remove
}{
visibility
}
{
isCurrent
?
<
b
>
{
label
}
</
b
>
:
label
}
...
...
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