Created
July 20, 2011 07:58
-
-
Save justinpeterman/1094548 to your computer and use it in GitHub Desktop.
Nested Records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Authoring = SC.Application.create( | |
store: SC.Store.create().from(SC.Record.fixtures) | |
}) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Authoring.LibraryFile = SC.Record.extend({ | |
name: SC.Record.attr(String), | |
path: SC.Record.attr(String), | |
size: SC.Record.attr(Number), | |
type: SC.Record.attr(String), | |
checksum: SC.Record.attr(String), | |
cdn: SC.Record.attr(Boolean) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Authoring.libraryFileController = SC.ArrayController.create({ | |
contentBinding: 'Authoring.libraryController.content.files' | |
}) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sc_require('models/library_model'); | |
//sc_require('models/file_model'); add here? | |
Authoring.Library.FIXTURES = [ | |
{ | |
user_id : 1, | |
name : "Justin", | |
files : [ | |
{ | |
guid : 0, | |
name : "photo1.png", | |
path : "some/path", | |
size : 26, | |
type : "image/png", | |
checksum : "", | |
cdn : false | |
}, | |
{ | |
guid : 1, | |
name : "photo2.png", | |
path : "some/path", | |
size : 14, | |
type : "image/png", | |
checksum : "", | |
cdn : false | |
}, | |
{ | |
guid : 2, | |
name : "photo3.png", | |
path : "some/path", | |
size : 12, | |
type : "image/png", | |
checksum : "", | |
cdn : false | |
}, | |
{ | |
guid : 3, | |
name : "photo4.png", | |
path : "some/path", | |
size : 4, | |
type : "image/png", | |
checksum : "", | |
cdn : false | |
}, | |
{ | |
guid : 4, | |
name : "photo5.png", | |
path : "some/path", | |
size : 18, | |
type : "image/png", | |
checksum : "", | |
cdn : false | |
}, | |
{ | |
guid : 5, | |
name : "photo6.png", | |
path : "some/path", | |
size : 12, | |
type : "image/png", | |
checksum : "", | |
cdn : false | |
} | |
] | |
} | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Authoring.libraryController = SC.ObjectController.create({ | |
content: null | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Authoring.Library = SC.Record.extend({ | |
name: SC.Record.attr(String), | |
user_id: SC.Record.attr(Number), | |
files: SC.Record.toMany('Authoring.LibraryFile', { nested: true }) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SC.ScrollView.design({ | |
layout: { top: 140 }, | |
contentView: SC.ListView.design({ | |
layout: { top: 0 }, | |
classNames: 'library-list', | |
actOnSelect: YES, | |
showAlternatingRows: YES, | |
rowHeight: 24, | |
contentBinding: "Authoring.libraryFileController", | |
selectionBinding: "Authoring.libraryFileController.selection", | |
contentValueKey: "name", | |
action: "fileClicked" | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// call to statechart action | |
Authoring.libraryController.set('content', Authoring.store.find(Authoring.Library)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment