diff --git a/app/assets/javascripts/app/models/stream_aspects.js b/app/assets/javascripts/app/models/stream_aspects.js new file mode 100644 index 000000000..f8536c65d --- /dev/null +++ b/app/assets/javascripts/app/models/stream_aspects.js @@ -0,0 +1,27 @@ +app.models.StreamAspects = app.models.Stream.extend({ + + url : function(){ + return _.any(this.items.models) ? this.timeFilteredPath() : this.basePath() + }, + + initialize : function(models, options){ + var collectionClass = options && options.collection || app.collections.Posts; + this.items = new collectionClass([], this.collectionOptions()); + this.aspects_ids = options.aspects_ids; + }, + + basePath : function(){ + return '/aspects'; + }, + + fetch: function() { + if(this.isFetching()){ return false } + var url = this.url(); + var ids = this.aspects_ids; + this.deferred = this.items.fetch({ + add : true, + url : url, + data : { 'a_ids': ids } + }).done(_.bind(this.triggerFetchedEvents, this)) + } +}); diff --git a/app/assets/javascripts/app/router.js b/app/assets/javascripts/app/router.js index d55081f61..2cd7d775d 100644 --- a/app/assets/javascripts/app/router.js +++ b/app/assets/javascripts/app/router.js @@ -87,18 +87,17 @@ app.Router = Backbone.Router.extend({ app.aspects = new app.collections.Aspects(app.currentUser.get('aspects')); var aspects_list = new app.views.AspectsList({ collection: app.aspects }); aspects_list.render(); + this.aspects_stream(); }, aspects_stream : function(){ var ids = app.aspects.selectedAspects('id'); - - app.stream = new app.models.Stream([], {url: '/aspects'}); - app.stream.fetch({data: $.param({a_ids:ids})}); + app.stream = new app.models.StreamAspects([], { aspects_ids: ids }); + app.stream.fetch(); app.page = new app.views.Stream({model : app.stream}); app.publisher = new app.views.Publisher({collection : app.stream.items}); - var streamFacesView = new app.views.StreamFaces({collection : app.stream.items}); $("#main_stream").html(app.page.render().el); diff --git a/app/assets/javascripts/app/views/aspects_list_view.js b/app/assets/javascripts/app/views/aspects_list_view.js index dbd9c6a91..2c285b859 100644 --- a/app/assets/javascripts/app/views/aspects_list_view.js +++ b/app/assets/javascripts/app/views/aspects_list_view.js @@ -30,7 +30,6 @@ app.views.AspectsList = app.views.Base.extend({ } this.toggleSelector(); - app.router.aspects_stream(); },