Created
May 13, 2011 15:58
-
-
Save skizzybiz/970797 to your computer and use it in GitHub Desktop.
Report Approval/Nomination
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.groupedNominationsController = SC.TreeController.create({ | |
content: null, | |
selection: null, | |
treeItemIsGrouped: YES, | |
setNominations: function(nominations) { | |
var group, osVersion, osVersions, root; | |
root = SC.Object.create({ | |
treeItemChildren: [] | |
treeItemIsExpanded: YES | |
}); | |
osVersions = {}; | |
osVersion = group = null; | |
nominations.forEach(function(nomination) { | |
osVersion = nomination.get('osVersion'); | |
if (osVersions[osVersion]) { | |
group = osVersions[osVersion]; | |
} else { | |
group = SC.Object.create({ | |
treeItemChildren: [], | |
treeItemIsExpanded: YES | |
label: osVersion | |
}); | |
root.treeItemChildren.push(group); | |
osVersions[osVersion] = group; | |
} | |
group.treeItemChildren.push(SC.Object.create({ | |
treeItemChildren: null, | |
label: nomination.get('reportTemplate').get('name'), | |
record: nomination | |
})); | |
}); | |
this.set('content', root); | |
} | |
}); |
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.main = function() { | |
var nominations, templates; | |
Authoring.myReports = Authoring.getPath('Pages.reportApproval.mainPane').append(); | |
nominations = Authoring.store.find(Authoring.Nomination); | |
nominations.addObserver('status', this, function() { | |
if (nominations.get('status') !== SC.Record.READY_CLEAN) return; | |
c = Authoring.groupedNominationsController; | |
c.setNominations(nominations); | |
c.selectObject(c.get('firstSelectableObject')); | |
}); | |
}; | |
window.main = function() { | |
return Authoring.main(); | |
}; |
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
// ... | |
contentView: SC.SourceListView.design({ | |
contentBinding: 'Authoring.groupedNominationsController.arrangedObjects', | |
selectionBinding: 'Authoring.groupedNominationsController.selection', | |
contentValueKey: 'label', | |
rowHeight: 21, | |
canEditContent: NO, | |
canDeleteContent: NO | |
}) |
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.reportTemplateController = SC.ObjectController.create({ | |
// This line is the trouble maker: it causes the browser to lock up in an infinite loop | |
// treeNodeBinding: SC.Binding.single('Authoring.groupedNominationsController.selection') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment