diff --git a/app/assets/javascripts/app/collections/aspects.js b/app/assets/javascripts/app/collections/aspects.js index 6aa44a56d..1351db044 100644 --- a/app/assets/javascripts/app/collections/aspects.js +++ b/app/assets/javascripts/app/collections/aspects.js @@ -1,10 +1,10 @@ app.collections.Aspects = Backbone.Collection.extend({ model: app.models.Aspect, - selectedAspectsIds: function(){ + selectedAspects: function(attribute){ return _.pluck(_.filter(this.toJSON(), function(a){ return a.selected; - }), 'id'); + }), attribute); }, allSelected: function(){ @@ -17,5 +17,9 @@ app.collections.Aspects = Backbone.Collection.extend({ deselectAll: function(){ this.map(function(a){ a.set({ 'selected' : false })} ); + }, + + toSentence: function(){ + return this.selectedAspects('name').join(", ").replace(/,\s([^,]+)$/, ' and $1') } }) diff --git a/app/assets/javascripts/app/router.js b/app/assets/javascripts/app/router.js index c0a3d0174..d55081f61 100644 --- a/app/assets/javascripts/app/router.js +++ b/app/assets/javascripts/app/router.js @@ -91,7 +91,7 @@ app.Router = Backbone.Router.extend({ aspects_stream : function(){ - var ids = app.aspects.selectedAspectsIds(); + var ids = app.aspects.selectedAspects('id'); app.stream = new app.models.Stream([], {url: '/aspects'}); app.stream.fetch({data: $.param({a_ids:ids})});