add toSentence support in aspects
This commit is contained in:
parent
c0417fab93
commit
e9031a7bf3
2 changed files with 7 additions and 3 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
app.collections.Aspects = Backbone.Collection.extend({
|
app.collections.Aspects = Backbone.Collection.extend({
|
||||||
model: app.models.Aspect,
|
model: app.models.Aspect,
|
||||||
|
|
||||||
selectedAspectsIds: function(){
|
selectedAspects: function(attribute){
|
||||||
return _.pluck(_.filter(this.toJSON(), function(a){
|
return _.pluck(_.filter(this.toJSON(), function(a){
|
||||||
return a.selected;
|
return a.selected;
|
||||||
}), 'id');
|
}), attribute);
|
||||||
},
|
},
|
||||||
|
|
||||||
allSelected: function(){
|
allSelected: function(){
|
||||||
|
|
@ -17,5 +17,9 @@ app.collections.Aspects = Backbone.Collection.extend({
|
||||||
|
|
||||||
deselectAll: function(){
|
deselectAll: function(){
|
||||||
this.map(function(a){ a.set({ 'selected' : false })} );
|
this.map(function(a){ a.set({ 'selected' : false })} );
|
||||||
|
},
|
||||||
|
|
||||||
|
toSentence: function(){
|
||||||
|
return this.selectedAspects('name').join(", ").replace(/,\s([^,]+)$/, ' and $1')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ app.Router = Backbone.Router.extend({
|
||||||
|
|
||||||
aspects_stream : function(){
|
aspects_stream : function(){
|
||||||
|
|
||||||
var ids = app.aspects.selectedAspectsIds();
|
var ids = app.aspects.selectedAspects('id');
|
||||||
|
|
||||||
app.stream = new app.models.Stream([], {url: '/aspects'});
|
app.stream = new app.models.Stream([], {url: '/aspects'});
|
||||||
app.stream.fetch({data: $.param({a_ids:ids})});
|
app.stream.fetch({data: $.param({a_ids:ids})});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue