Guest User

Untitled

a guest
Jul 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. // the following is from an ArrayController whose content is a set of Pages; the TreeController's content property is bound to this property:
  2.  
  3. outline: function () {
  4. var contentLength = this.getPath('content.length') || 0;
  5.  
  6. return contentLength === 0 ? null : SC.Object.create({
  7. title: 'toplevel',
  8. treeItemIsExpanded: YES,
  9. pages: this.map( function (page) { return page; } ),
  10. treeItemChildren: this.map( function (page) {
  11. var stepNum = 1;
  12. return SC.Object.create({
  13. title: page.get('name') || 'Page %@'.fmt(page.get('pageNumber') + 1),
  14. treeItemIsExpanded: YES,
  15. treeItemIsGrouped: NO, // just added; doesn't make the page selectable
  16. page: page,
  17. steps: page.get('steps'),
  18. treeItemChildren: page.get('steps').map( function (step) {
  19. return SC.Object.create({
  20. title: 'Step %@'.fmt(stepNum++),
  21. step: step,
  22. treeItemIsExpanded: YES,
  23. treeItemChildren: null
  24. });
  25. })
  26. });
  27. })
  28. });
  29. // FIXME this will NOT update when steps are added/removed or have their properties changed
  30. }.property('[]').cacheable()
Add Comment
Please, Sign In to add comment