Created
February 12, 2013 23:27
-
-
Save domchristie/4774472 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
App.LineItemsController = Ember.ArrayController.extend({ | |
groupedContent: (function() { | |
var lineItems = this.get('content'); | |
if(!lineItems.get('isLoaded')) { | |
return null; | |
} | |
return lineItems.reduce(function(grouped, object, index, content) { | |
if(content.objectAt(index-1) && | |
object.get('date').valueOf() == content.objectAt(index-1).get('date').valueOf()) { | |
grouped.get('lastObject').pushObject(object); | |
} | |
else { | |
grouped.pushObject(Em.A([object])); | |
} | |
return grouped; | |
}, Em.A([])); | |
}).property('content.isLoaded') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment