Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
a33693f4
Commit
a33693f4
authored
Feb 02, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retrieve node, caret, label by querySelector && add leafClick
parent
6267341c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
24 deletions
+32
-24
TreeView.js
remix-debugger/src/ui/TreeView.js
+32
-24
No files found.
remix-debugger/src/ui/TreeView.js
View file @
a33693f4
...
@@ -43,9 +43,6 @@ class TreeView {
...
@@ -43,9 +43,6 @@ class TreeView {
this
.
extractData
=
opts
.
extractData
||
this
.
extractDataDefault
this
.
extractData
=
opts
.
extractData
||
this
.
extractDataDefault
this
.
formatSelf
=
opts
.
formatSelf
||
this
.
formatSelfDefault
this
.
formatSelf
=
opts
.
formatSelf
||
this
.
formatSelfDefault
this
.
view
=
null
this
.
view
=
null
this
.
nodes
=
{}
this
.
labels
=
{}
this
.
carets
=
{}
}
}
render
(
json
,
expand
)
{
render
(
json
,
expand
)
{
...
@@ -70,36 +67,37 @@ class TreeView {
...
@@ -70,36 +67,37 @@ class TreeView {
return
this
.
formatData
(
key
,
data
,
children
,
expand
,
keyPath
)
return
this
.
formatData
(
key
,
data
,
children
,
expand
,
keyPath
)
}
}
renderProperties
(
json
,
expand
)
{
renderProperties
(
json
,
expand
,
key
)
{
key
=
key
||
''
var
children
=
Object
.
keys
(
json
).
map
((
innerkey
)
=>
{
var
children
=
Object
.
keys
(
json
).
map
((
innerkey
)
=>
{
return
this
.
renderObject
(
json
[
innerkey
],
json
,
innerkey
,
expand
,
innerkey
)
return
this
.
renderObject
(
json
[
innerkey
],
json
,
innerkey
,
expand
,
innerkey
)
})
})
return
yo
`<ul class="
${
css
.
ul_tv
}
">
${
children
}
</ul>`
return
yo
`<ul
key=
${
key
}
class="
${
css
.
ul_tv
}
">
${
children
}
</ul>`
}
}
formatData
(
key
,
data
,
children
,
expand
,
keyPath
)
{
formatData
(
key
,
data
,
children
,
expand
,
keyPath
)
{
var
self
=
this
var
self
=
this
var
li
=
yo
`<li class=
${
css
.
li_tv
}
></li>`
var
li
=
yo
`<li class=
${
css
.
li_tv
}
></li>`
var
caret
=
yo
`<div class="fa fa-caret-right
${
css
.
caret_tv
}
"></div>`
var
caret
=
yo
`<div class="fa fa-caret-right
caret
${
css
.
caret_tv
}
"></div>`
var
label
=
yo
`
var
label
=
yo
`
<div class=
${
css
.
label_tv
}
>
<div
key=
${
key
}
class=
${
css
.
label_tv
}
>
${
caret
}
${
caret
}
<span>
${
self
.
formatSelf
(
key
,
data
,
li
)}
</span>
<span>
${
self
.
formatSelf
(
key
,
data
,
li
)}
</span>
</div>`
</div>`
li
.
appendChild
(
label
)
li
.
appendChild
(
label
)
if
(
data
.
children
)
{
if
(
data
.
children
)
{
var
list
=
yo
`<ul class=
${
css
.
ul_tv
}
>
${
children
}
</ul>`
var
list
=
yo
`<ul key=
${
key
}
class=
${
css
.
ul_tv
}
>
${
children
}
</ul>`
this
.
nodes
[
keyPath
]
=
list
this
.
labels
[
keyPath
]
=
label
this
.
carets
[
keyPath
]
=
caret
list
.
style
.
display
=
'none'
list
.
style
.
display
=
'none'
caret
.
className
=
list
.
style
.
display
===
'none'
?
'fa fa-caret-right'
:
'fa fa-caret-down'
caret
.
className
=
list
.
style
.
display
===
'none'
?
`fa fa-caret-right caret
${
css
.
caret_tv
}
`
:
`fa fa-caret-down caret
${
css
.
caret_tv
}
`
label
.
onclick
=
function
()
{
label
.
onclick
=
function
()
{
self
.
expand
(
keyPath
)
self
.
expand
(
keyPath
)
}
}
li
.
appendChild
(
list
)
li
.
appendChild
(
list
)
}
else
{
}
else
{
caret
.
style
.
visibility
=
'hidden'
caret
.
style
.
visibility
=
'hidden'
label
.
onclick
=
function
()
{
self
.
event
.
trigger
(
'leafClick'
,
[
key
,
data
,
label
])
}
}
}
return
li
return
li
}
}
...
@@ -113,25 +111,35 @@ class TreeView {
...
@@ -113,25 +111,35 @@ class TreeView {
}
}
expand
(
path
)
{
expand
(
path
)
{
if
(
this
.
labels
[
path
])
{
var
caret
=
this
.
caretAt
(
path
)
this
.
carets
[
path
].
className
=
this
.
carets
[
path
].
className
===
'fa fa-caret-right'
?
'fa fa-caret-down'
:
'fa fa-caret-right'
var
node
=
this
.
nodeAt
(
path
)
this
.
nodes
[
path
].
style
.
display
=
this
.
nodes
[
path
].
style
.
display
===
'none'
?
'block'
:
'none'
if
(
node
)
{
this
.
event
.
trigger
(
'nodeClick'
,
[
path
,
this
.
nodes
[
path
]])
node
.
style
.
display
=
node
.
style
.
display
===
'none'
?
'block'
:
'none'
caret
.
className
=
node
.
style
.
display
===
'none'
?
`fa fa-caret-right caret
${
css
.
caret_tv
}
`
:
`fa fa-caret-down caret
${
css
.
caret_tv
}
`
this
.
event
.
trigger
(
'nodeClick'
,
[
path
,
node
])
}
}
caretAt
(
path
)
{
var
label
=
this
.
labelAt
(
path
)
if
(
label
)
{
return
label
.
querySelector
(
'.caret'
)
}
}
}
}
labelAt
(
path
)
{
return
this
.
view
.
querySelector
(
`div[key="
${
path
}
"]`
)
}
nodeAt
(
path
)
{
nodeAt
(
path
)
{
return
this
.
nodes
[
path
]
return
this
.
view
.
querySelector
(
`ul[key="
${
path
}
"]`
)
}
}
updateNode
(
path
,
newNode
)
{
updateNodeFromJSON
(
path
,
jsonTree
,
expand
)
{
var
newTree
=
this
.
renderProperties
(
jsonTree
,
expand
,
path
)
var
current
=
this
.
nodeAt
(
path
)
var
current
=
this
.
nodeAt
(
path
)
if
(
current
)
{
if
(
current
&&
current
.
parentElement
)
{
var
parent
=
current
.
parentNode
current
.
parentElement
.
replaceChild
(
newTree
,
current
)
if
(
parent
)
{
parent
.
replaceChild
(
newNode
,
current
)
this
.
nodes
[
path
]
=
newNode
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment