Add fill defaults button to solutions treema node in level editor

This commit is contained in:
Scott Erickson 2016-01-06 13:48:54 -08:00
parent 86d9b081c1
commit fde11d8f0d

View file

@ -73,6 +73,7 @@ module.exports = class ThangComponentConfigView extends CocoView
'acceleration': nodes.AccelerationNode
'thang-type': nodes.ThangTypeNode
'item-thang-type': nodes.ItemThangTypeNode
'solutions': SolutionsNode
@editThangTreema = @$el.find('.treema').treema treemaOptions
@editThangTreema.build()
@ -94,3 +95,30 @@ module.exports = class ThangComponentConfigView extends CocoView
class ComponentConfigNode extends TreemaObjectNode
nodeDescription: 'Component Property'
class SolutionsNode extends TreemaArrayNode
buildValueForDisplay: (valEl, data) ->
btn = $('<button class="btn btn-default btn-xs">Fill defaults</button>')
btn.on('click', @onClickFillDefaults)
valEl.append(btn)
onClickFillDefaults: (e) =>
e.preventDefault()
sources = {}
if source = @parent.data.source
sources.javascript = source
sources = { javascript: @parent.data.source }
_.extend sources, @parent.data.languages or {}
solutions = _.clone(@data)
for language in _.keys(sources)
source = sources[language]
solution = _.findWhere(solutions, {language: language})
continue if solution
solutions.push({
source: source
language: language
passes: true
})
@set('/', solutions)