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
404815b9
Commit
404815b9
authored
Jan 23, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
track display status
parent
5aa7bf8a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
TreeView.js
src/ui/TreeView.js
+13
-14
No files found.
src/ui/TreeView.js
View file @
404815b9
...
...
@@ -16,10 +16,11 @@ class TreeView {
this
.
cssLabel
=
ui
.
formatCss
(
opts
.
css
||
{},
style
.
label
)
this
.
cssUl
=
ui
.
formatCss
(
opts
.
css
||
{},
style
.
cssUl
)
this
.
cssLi
=
ui
.
formatCss
(
opts
.
css
||
{},
style
.
cssLi
)
this
.
keyPaths
=
{}
}
render
(
json
)
{
var
view
=
this
.
renderProperties
(
json
,
tru
e
)
var
view
=
this
.
renderProperties
(
json
,
fals
e
)
if
(
!
this
.
view
)
{
this
.
view
=
view
}
...
...
@@ -28,43 +29,41 @@ class TreeView {
update
(
json
)
{
if
(
this
.
view
)
{
yo
.
update
(
this
.
view
,
this
.
render
(
json
),
{
onBeforeElUpdated
:
(
fromEl
,
toEl
)
=>
{
toEl
.
style
.
display
=
fromEl
.
style
.
display
toEl
.
className
=
fromEl
.
className
return
true
}})
yo
.
update
(
this
.
view
,
this
.
render
(
json
))
}
}
renderObject
(
item
,
parent
,
key
,
expand
)
{
renderObject
(
item
,
parent
,
key
,
expand
,
keyPath
)
{
var
data
=
this
.
extractData
(
item
,
parent
,
key
)
var
children
=
(
data
.
children
||
[]).
map
((
child
,
index
)
=>
{
return
this
.
renderObject
(
child
.
value
,
data
,
child
.
key
,
expand
)
return
this
.
renderObject
(
child
.
value
,
data
,
child
.
key
,
expand
,
keyPath
+
'_'
+
child
.
key
)
})
return
this
.
formatDataInternal
(
key
,
data
,
children
,
expand
)
return
this
.
formatDataInternal
(
key
,
data
,
children
,
expand
,
keyPath
)
}
renderProperties
(
json
,
expand
)
{
var
children
=
Object
.
keys
(
json
).
map
((
innerkey
)
=>
{
return
this
.
renderObject
(
json
[
innerkey
],
json
,
innerkey
,
expand
)
return
this
.
renderObject
(
json
[
innerkey
],
json
,
innerkey
,
expand
,
innerkey
)
})
return
yo
`<ul style=
${
this
.
cssUl
}
>
${
children
}
</ul>`
}
formatDataInternal
(
key
,
data
,
children
,
expand
)
{
formatDataInternal
(
key
,
data
,
children
,
expand
,
keyPath
)
{
var
label
=
yo
`<span style=
${
this
.
cssLabel
}
><label style=
${
ui
.
formatCss
(
style
.
caret
)}
></label><span style=
${
ui
.
formatCss
(
style
.
data
)}
>
${
this
.
formatData
(
key
,
data
)}
</span></span>`
var
renderedChildren
=
''
if
(
children
.
length
)
{
renderedChildren
=
yo
`<ul style=
${
this
.
cssUl
}
>
${
children
}
</ul>`
renderedChildren
.
style
.
display
=
expand
?
'block'
:
'none'
label
.
firstElementChild
.
className
=
expand
?
'fa fa-caret-down'
:
'fa fa-caret-right'
renderedChildren
.
style
.
display
=
this
.
keyPaths
[
keyPath
]
?
this
.
keyPaths
[
keyPath
]
:
expand
?
'block'
:
'none'
label
.
firstElementChild
.
className
=
renderedChildren
.
style
.
display
===
'none'
?
'fa fa-caret-right'
:
'fa fa-caret-down'
var
self
=
this
label
.
onclick
=
function
()
{
this
.
firstElementChild
.
className
=
this
.
firstElementChild
.
className
===
'fa fa-caret-right'
?
'fa fa-caret-down'
:
'fa fa-caret-right'
var
list
=
this
.
parentElement
.
querySelector
(
'ul'
)
list
.
style
.
display
=
list
.
style
.
display
===
'none'
?
'block'
:
'none'
self
.
keyPaths
[
keyPath
]
=
list
.
style
.
display
}
}
return
yo
`<li
id=
${
key
+
(
new
Date
().
getUTCMilliseconds
())}
style=
${
this
.
cssLi
}
>
${
label
}${
renderedChildren
}
</li>`
return
yo
`<li style=
${
this
.
cssLi
}
>
${
label
}${
renderedChildren
}
</li>`
}
formatDataDefault
(
key
,
data
)
{
...
...
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