Move to App.CollectionController for activity stream.
This commit is contained in:
parent
1f548c01df
commit
b3b2a477dc
4 changed files with 34 additions and 33 deletions
|
@ -813,7 +813,7 @@ class App.CollectionController extends App.Controller
|
||||||
if @subscribeId
|
if @subscribeId
|
||||||
App[@model].unsubscribe(@subscribeId)
|
App[@model].unsubscribe(@subscribeId)
|
||||||
|
|
||||||
uIRunner: ->
|
uIRunner: =>
|
||||||
return if !@queue[0]
|
return if !@queue[0]
|
||||||
return if @queueRunning
|
return if @queueRunning
|
||||||
@queueRunning = true
|
@queueRunning = true
|
||||||
|
@ -1025,6 +1025,8 @@ class App.CollectionController extends App.Controller
|
||||||
html = $(App.view(@template)(
|
html = $(App.view(@template)(
|
||||||
item: item
|
item: item
|
||||||
))
|
))
|
||||||
|
if @onRenderItemEnd
|
||||||
|
@onRenderItemEnd(item, html)
|
||||||
itemCount = Object.keys(@renderList).length
|
itemCount = Object.keys(@renderList).length
|
||||||
@renderList[item[@uniqKey]] = html
|
@renderList[item[@uniqKey]] = html
|
||||||
if el is false
|
if el is false
|
||||||
|
@ -1044,7 +1046,7 @@ class App.CollectionController extends App.Controller
|
||||||
onRenderEnd: ->
|
onRenderEnd: ->
|
||||||
# nothing
|
# nothing
|
||||||
|
|
||||||
location: (e) ->
|
location: (e) =>
|
||||||
@locationVerify(e)
|
@locationVerify(e)
|
||||||
|
|
||||||
click: (e) =>
|
click: (e) =>
|
||||||
|
|
|
@ -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: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
||||||
@fetch()
|
@fetch()
|
||||||
|
|
||||||
# bind to rebuild view event
|
# bind to rebuild view event
|
||||||
|
@ -19,48 +27,39 @@ class App.DashboardActivityStream extends App.Controller
|
||||||
@ajax(
|
@ajax(
|
||||||
id: 'dashoard_activity_stream'
|
id: 'dashoard_activity_stream'
|
||||||
type: 'GET'
|
type: 'GET'
|
||||||
url: @apiPath + '/activity_stream'
|
url: "#{@apiPath}/activity_stream"
|
||||||
data: {
|
data:
|
||||||
limit: @limit || 8
|
limit: @limit || 8
|
||||||
}
|
|
||||||
processData: true
|
processData: true
|
||||||
success: (data) =>
|
success: (data) =>
|
||||||
@load(data)
|
@load(data)
|
||||||
)
|
)
|
||||||
|
|
||||||
load: (data) =>
|
load: (data) =>
|
||||||
|
|
||||||
App.SessionStorage.set('activity_stream', data)
|
App.SessionStorage.set('activity_stream', data)
|
||||||
|
@items = data.activity_stream
|
||||||
items = data.activity_stream
|
|
||||||
|
|
||||||
App.Collection.loadAssets(data.assets)
|
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
|
itemsAll: =>
|
||||||
return if _.isEmpty(items)
|
@items
|
||||||
|
|
||||||
|
onRenderEnd: =>
|
||||||
|
return if _.isEmpty(@items)
|
||||||
|
|
||||||
# remove description of activity stream
|
# remove description of activity stream
|
||||||
@$('.activity-description').removeClass('activity-description')
|
@el.removeClass('activity-description').addClass('activity-entries')
|
||||||
|
|
||||||
items = @prepareForObjectList(items)
|
onRenderItemEnd: (item, el) ->
|
||||||
|
|
||||||
html = $('<div class="activity-entries"></div>')
|
|
||||||
for item in items
|
|
||||||
html.append(@renderItem(item))
|
|
||||||
|
|
||||||
@el.html html
|
|
||||||
|
|
||||||
renderItem: (item) ->
|
|
||||||
html = $(App.view('dashboard/activity_stream')(
|
|
||||||
item: item
|
|
||||||
))
|
|
||||||
new App.WidgetAvatar(
|
new App.WidgetAvatar(
|
||||||
el: html.find('.js-avatar')
|
el: el.find('.js-avatar')
|
||||||
object_id: item.created_by_id
|
object_id: item.created_by_id
|
||||||
size: 40
|
size: 40
|
||||||
)
|
)
|
||||||
html
|
|
|
@ -201,7 +201,7 @@ class App.OnlineNotificationContentWidget extends App.CollectionController
|
||||||
alreadyShown: {}
|
alreadyShown: {}
|
||||||
insertPosition: 'before'
|
insertPosition: 'before'
|
||||||
|
|
||||||
onRenderEnd: ->
|
onRenderEnd: =>
|
||||||
@container.counterGen()
|
@container.counterGen()
|
||||||
|
|
||||||
# generate desktop notifications
|
# generate desktop notifications
|
||||||
|
@ -222,5 +222,5 @@ class App.OnlineNotificationContentWidget extends App.CollectionController
|
||||||
)
|
)
|
||||||
App.OnlineNotification.play()
|
App.OnlineNotification.play()
|
||||||
|
|
||||||
onClick: ->
|
onClick: =>
|
||||||
@container.hide()
|
@container.hide()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="activity-entry">
|
<div class="js-item activity-entry">
|
||||||
<div class="activity-avatar js-avatar"></div>
|
<div class="activity-avatar js-avatar"></div>
|
||||||
<a href="<%- @item.link %>" class="activity-body">
|
<a href="<%- @item.link %>" class="activity-body">
|
||||||
<span class="activity-message">
|
<span class="activity-message">
|
Loading…
Reference in a new issue