Pane serializes its serializable items

This commit is contained in:
Nathan Sobo
2013-02-20 16:01:08 -07:00
committed by probablycorey
parent bee1efed5c
commit 568fcf441e
2 changed files with 9 additions and 4 deletions

View File

@@ -105,4 +105,9 @@ describe "Pane", ->
describe ".itemForPath(path)", ->
it "returns the item for which a call to .getPath() returns the given path", ->
expect(pane.itemForPath(editSession1.getPath())).toBe editSession1
expect(pane.itemForPath(editSession2.getPath())).toBe editSession2
expect(pane.itemForPath(editSession2.getPath())).toBe editSession2
describe "serialization", ->
it "can serialize and deserialize the pane and all its serializable items", ->
newPane = deserialize(pane.serialize())
expect(newPane.getItems()).toEqual [editSession1, editSession2]

View File

@@ -10,8 +10,8 @@ class Pane extends View
@div class: 'pane', =>
@div class: 'item-views', outlet: 'itemViews'
@deserialize: ({wrappedView}) ->
new Pane(deserialize(wrappedView))
@deserialize: ({items}) ->
new Pane(items.map((item) -> deserialize(item))...)
currentItem: null
items: null
@@ -96,7 +96,7 @@ class Pane extends View
serialize: ->
deserializer: "Pane"
wrappedView: @wrappedView?.serialize()
items: _.compact(@getItems().map (item) -> item.serialize?())
adjustDimensions: -> # do nothing