|
|
@ -29,20 +29,27 @@ class DefaultView extends View{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
Object.keys(this.object.json).forEach(
|
|
|
|
Object.keys(this.object.json).forEach(key => {
|
|
|
|
key => this.root.appendChild(this.getNode(key))
|
|
|
|
let node = this.getNode(key);
|
|
|
|
)
|
|
|
|
if (node) this.root.appendChild(node)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getNode(name, value=null) {
|
|
|
|
getNode(name, value=null) {
|
|
|
|
if (this.fields[name]) {
|
|
|
|
if (this.fields[name]) {
|
|
|
|
return this.fields[name]
|
|
|
|
return this.fields[name]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(name)
|
|
|
|
value = value === null ? this.object.json[name] : value
|
|
|
|
value = value === null ? this.object.json[name] : value
|
|
|
|
|
|
|
|
|
|
|
|
if (value instanceof StructuredNode) {
|
|
|
|
if (value instanceof StructuredNode) {
|
|
|
|
this.subviews[name] = new DefaultView(value)
|
|
|
|
this.subviews[name] = (new DefaultView(value)).render()
|
|
|
|
this.fields[name] = this.subviews[name].root
|
|
|
|
const wrap = document.createElement('div')
|
|
|
|
|
|
|
|
wrap.classList.add('wrapper')
|
|
|
|
|
|
|
|
wrap.innerHTML += '<b>' + name + ':</b>'
|
|
|
|
|
|
|
|
wrap.appendChild(this.subviews[name].root)
|
|
|
|
|
|
|
|
this.fields[name] = wrap
|
|
|
|
} else if (value instanceof Array) {
|
|
|
|
} else if (value instanceof Array) {
|
|
|
|
const elm = document.createElement('ul')
|
|
|
|
const elm = document.createElement('ul')
|
|
|
|
value.forEach((elm, i) => {
|
|
|
|
value.forEach((elm, i) => {
|
|
|
@ -52,6 +59,9 @@ class DefaultView extends View{
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.fields[name] = elm
|
|
|
|
this.fields[name] = elm
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (value === null)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
const elm = document.createElement('p')
|
|
|
|
const elm = document.createElement('p')
|
|
|
|
elm.innerHTML = `${name}: ${value}`
|
|
|
|
elm.innerHTML = `${name}: ${value}`
|
|
|
|
this.fields[name] = elm
|
|
|
|
this.fields[name] = elm
|
|
|
|