coffeescript-ui
Version:
Coffeescript User Interface System
73 lines (62 loc) • 1.57 kB
text/coffeescript
###
* coffeescript-ui - Coffeescript User Interface System (CUI)
* Copyright (c) 2013 - 2016 Programmfabrik GmbH
* MIT Licence
* https://github.com/programmfabrik/coffeescript-ui, http://www.coffeescript-ui.org
###
class CUI.ObjectDumper extends CUI.ListViewTree
constructor: (opts) ->
super(opts)
if
headerRow = new CUI.ListViewTreeHeaderNode(headers: )
.children.splice(0,0, headerRow)
.open()
initOpts: ->
super()
object:
mandatory: true
check: (v) ->
if CUI.util.isArray(v) or CUI.util.isPlainObject(v)
true
else
false
headers:
default: [
label: text: "key"
,
label: text: "value"
]
check: (v) ->
v.length == 2
do_open:
mandatory: true
default: false
check: Boolean
parse_json:
mandatory: true
default: false
check: Boolean
readOpts: ->
super()
= ["auto", "auto"]
= ["cui-object-dumper-key", "cui-object-dumper-value"]
if
= true
= 1
=
initListView: ->
super()
= new CUI.ObjectDumperNode(data: , do_open: , parse_json: )
__hasOnlyPlainValues: (object) ->
for key, value of object
if CUI.util.isPlainObject(value) or CUI.util.isArray(value)
return false
if and CUI.util.isJSON(value)
return false
return true