diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee index e6c2c963c..b31c72acf 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee @@ -813,7 +813,7 @@ class App.CollectionController extends App.Controller if @subscribeId App[@model].unsubscribe(@subscribeId) - uIRunner: -> + uIRunner: => return if !@queue[0] return if @queueRunning @queueRunning = true @@ -1025,6 +1025,8 @@ class App.CollectionController extends App.Controller html = $(App.view(@template)( item: item )) + if @onRenderItemEnd + @onRenderItemEnd(item, html) itemCount = Object.keys(@renderList).length @renderList[item[@uniqKey]] = html if el is false @@ -1044,7 +1046,7 @@ class App.CollectionController extends App.Controller onRenderEnd: -> # nothing - location: (e) -> + location: (e) => @locationVerify(e) click: (e) => diff --git a/app/assets/javascripts/app/controllers/_dashboard/activity_stream.coffee b/app/assets/javascripts/app/controllers/_dashboard/activity_stream.coffee index e805f6d46..892a54304 100644 --- a/app/assets/javascripts/app/controllers/_dashboard/activity_stream.coffee +++ b/app/assets/javascripts/app/controllers/_dashboard/activity_stream.coffee @@ -1,7 +1,15 @@ -class App.DashboardActivityStream extends App.Controller +class App.DashboardActivityStream extends App.CollectionController + model: false + template: 'dashboard/activity_stream_item' + uniqKey: 'id' + observe: + updated_at: true + prepareForObjectListItemSupport: true + items: [] + insertPosition: 'before' + constructor: -> super - @fetch() # bind to rebuild view event @@ -19,48 +27,39 @@ class App.DashboardActivityStream extends App.Controller @ajax( id: 'dashoard_activity_stream' type: 'GET' - url: @apiPath + '/activity_stream' - data: { + url: "#{@apiPath}/activity_stream" + data: limit: @limit || 8 - } processData: true success: (data) => @load(data) ) load: (data) => - App.SessionStorage.set('activity_stream', data) - - items = data.activity_stream - + @items = data.activity_stream App.Collection.loadAssets(data.assets) + @collectionSync(@items) - @render(items) + itemGet: (key) => + for item in @items + return item if key is item.id - render: (items) -> + itemDestroy: (key) -> + # nothing - # show description of activity stream - return if _.isEmpty(items) + itemsAll: => + @items + + onRenderEnd: => + return if _.isEmpty(@items) # remove description of activity stream - @$('.activity-description').removeClass('activity-description') + @el.removeClass('activity-description').addClass('activity-entries') - items = @prepareForObjectList(items) - - html = $('
') - for item in items - html.append(@renderItem(item)) - - @el.html html - - renderItem: (item) -> - html = $(App.view('dashboard/activity_stream')( - item: item - )) + onRenderItemEnd: (item, el) -> new App.WidgetAvatar( - el: html.find('.js-avatar') + el: el.find('.js-avatar') object_id: item.created_by_id size: 40 ) - html \ No newline at end of file diff --git a/app/assets/javascripts/app/controllers/widget/online_notification.coffee b/app/assets/javascripts/app/controllers/widget/online_notification.coffee index 3c153a726..9fc2ea98f 100644 --- a/app/assets/javascripts/app/controllers/widget/online_notification.coffee +++ b/app/assets/javascripts/app/controllers/widget/online_notification.coffee @@ -201,7 +201,7 @@ class App.OnlineNotificationContentWidget extends App.CollectionController alreadyShown: {} insertPosition: 'before' - onRenderEnd: -> + onRenderEnd: => @container.counterGen() # generate desktop notifications @@ -222,5 +222,5 @@ class App.OnlineNotificationContentWidget extends App.CollectionController ) App.OnlineNotification.play() - onClick: -> + onClick: => @container.hide() diff --git a/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco b/app/assets/javascripts/app/views/dashboard/activity_stream_item.jst.eco similarity index 94% rename from app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco rename to app/assets/javascripts/app/views/dashboard/activity_stream_item.jst.eco index d6785cc9b..02d2123a3 100644 --- a/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco +++ b/app/assets/javascripts/app/views/dashboard/activity_stream_item.jst.eco @@ -1,4 +1,4 @@ -