Skip to content

Commit

Permalink
Reintroduced getChildSchema as a TreemaNode function so subclasses co…
Browse files Browse the repository at this point in the history
…uld override it still.
  • Loading branch information
sderickson committed Aug 22, 2014
1 parent 1a5b23e commit bef28ab
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"treema.js",
"treema.css"
],
"version": "0.1.1",
"version": "0.1.2",
"authors": [
"CodeCombat <team@codecombat.com>"
],
Expand Down
22 changes: 13 additions & 9 deletions dev/js/treema.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/base.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class TreemaNode
saveChanges: (oldData)->
return if oldData is @data
@addTrackedAction {'oldData':oldData, 'newData':@data, 'path':@getPath(), 'action':'edit'}
getChildSchema: (key) -> TreemaNode.utils.getChildSchema(key, @schema)
buildValueForDisplay: -> console.error('"buildValueForDisplay" has not been overridden.')
buildValueForEditing: ->
return unless @editable and @directlyEditable
Expand Down
18 changes: 9 additions & 9 deletions src/core.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ do __init = ->
({
key: key
value: value
schema: TreemaNode.utils.getChildSchema(key, @schema)
schema: @getChildSchema(key)
} for value, key in @data)

buildValueForDisplay: (valEl, data) ->
Expand Down Expand Up @@ -181,13 +181,13 @@ do __init = ->
keysAccountedFor.push(key)
children.push({
key: key,
schema: TreemaNode.utils.getChildSchema(key, @schema)
schema: @getChildSchema(key)
defaultData: defaultData
})
continue

keysAccountedFor.push(key)
schema = TreemaNode.utils.getChildSchema(key, @schema)
schema = @getChildSchema(key)
children.push({
key: key
value: @data[key]
Expand All @@ -201,7 +201,7 @@ do __init = ->
children.push({
key: key
value: value
schema: TreemaNode.utils.getChildSchema(key, @schema)
schema: @getChildSchema(key)
defaultData: @getDefaultDataForKey(key)
})

Expand All @@ -211,7 +211,7 @@ do __init = ->
keysAccountedFor.push(key)
children.push({
key: key
schema: TreemaNode.utils.getChildSchema(key, @schema)
schema: @getChildSchema(key)
defaultData: @getDefaultDataForKey(key)
})

Expand All @@ -221,7 +221,7 @@ do __init = ->
keysAccountedFor.push(key)
children.push({
key: key
schema: TreemaNode.utils.getChildSchema(key, @schema)
schema: @getChildSchema(key)
defaultData: @getDefaultDataForKey(key)
})

Expand Down Expand Up @@ -252,7 +252,7 @@ do __init = ->
break
i += 1

childSchema = TreemaNode.utils.getChildSchema(key, @schema)
childSchema = @getChildSchema(key)
name = childSchema.title or key
if $.isPlainObject(value) or $.isArray(value)
text.push "#{name}"
Expand All @@ -273,7 +273,7 @@ do __init = ->
return unless @schema.required
for key in @schema.required
continue if @data[key]?
helperTreema = TreemaNode.make(null, {schema: TreemaNode.utils.getChildSchema(key, @schema)}, @)
helperTreema = TreemaNode.make(null, {schema: @getChildSchema(key)}, @)
helperTreema.populateData()
@data[key] = helperTreema.data

Expand Down Expand Up @@ -393,7 +393,7 @@ do __init = ->
return

addNewChildForKey: (key) ->
schema = TreemaNode.utils.getChildSchema(key, @schema)
schema = @getChildSchema(key)
newTreema = TreemaNode.make(null, {schema: schema}, @, key)
childNode = @createChildNode(newTreema)
@findObjectInsertionPoint(key).before(childNode)
Expand Down
22 changes: 13 additions & 9 deletions treema.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bef28ab

Please sign in to comment.