diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index 2ba35483d..03c859fb2 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -268,13 +268,14 @@ class App.Controller extends Spine.Controller userPopups: (position = 'right') -> # open user in new task if current user is agent - if @isRole('Agent') - @el.find('div.user-popover, span.user-popover').bind('click', (e) => - id = $(e.target).data('id') - if id - user = App.User.find(id) - @navigate user.uiUrl() - ); + return if !@isRole('Agent') + + @el.find('div.user-popover, span.user-popover').bind('click', (e) => + id = $(e.target).data('id') + if id + user = App.User.find(id) + @navigate user.uiUrl() + ); @userPopupsDestroy() @@ -325,13 +326,14 @@ class App.Controller extends Spine.Controller organizationPopups: (position = 'right') -> # open org in new task if current user agent - if @isRole('Agent') - @el.find('div.organization-popover, span.organization-popover').bind('click', (e) => - id = $(e.target).data('id') - if id - organization = App.Organization.find(id) - @navigate organization.uiUrl() - ); + return if !@isRole('Agent') + + @el.find('div.organization-popover, span.organization-popover').bind('click', (e) => + id = $(e.target).data('id') + if id + organization = App.Organization.find(id) + @navigate organization.uiUrl() + ); @organizationPopupsDestroy() diff --git a/app/assets/javascripts/app/controllers/_dashboard/activity_stream.js.coffee b/app/assets/javascripts/app/controllers/_dashboard/activity_stream.js.coffee index 4a3c47903..3af74f5d0 100644 --- a/app/assets/javascripts/app/controllers/_dashboard/activity_stream.js.coffee +++ b/app/assets/javascripts/app/controllers/_dashboard/activity_stream.js.coffee @@ -40,16 +40,22 @@ class App.DashboardActivityStream extends App.Controller render: (items) -> items = @prepareForObjectList(items) - html = App.view('dashboard/activity_stream')( + @html App.view('dashboard/activity_stream')( head: 'Activity Stream', - items: items ) - html = $(html) - - @html html - - # start user popups - @userPopups('left') + for item in items + @el.append( @renderItem(item) ) # update time @frontendTimeUpdate() + + renderItem: (item) -> + html = $(App.view('dashboard/activity_stream_item')( + item: item, + )) + new App.WidgetAvatar( + el: html.find('.js-avatar') + user_id: item.created_by_id + size: 40 + ) + html \ No newline at end of file diff --git a/app/assets/javascripts/app/controllers/navigation.js.coffee b/app/assets/javascripts/app/controllers/navigation.js.coffee index 90e33563d..b47360553 100644 --- a/app/assets/javascripts/app/controllers/navigation.js.coffee +++ b/app/assets/javascripts/app/controllers/navigation.js.coffee @@ -86,6 +86,12 @@ class App.Navigation extends App.Controller active_tab: active_tab ) + new App.WidgetAvatar( + el: @$('.js-avatar') + user_id: App.Session.get('id') + noPopups: true + ) + renderResult: (result = []) => el = @$('#global-search-result') diff --git a/app/assets/javascripts/app/controllers/widget/avatar.js.coffee b/app/assets/javascripts/app/controllers/widget/avatar.js.coffee new file mode 100644 index 000000000..ac13989d9 --- /dev/null +++ b/app/assets/javascripts/app/controllers/widget/avatar.js.coffee @@ -0,0 +1,20 @@ +class App.WidgetAvatar extends App.Controller + constructor: -> + super + + # subscribe and reload data / fetch new data if triggered + @subscribeId = App.User.full( @user_id, @render, false, true ) + + release: => + App.User.unsubscribe(@subscribeId) + + render: (user) => + @html App.view('avatar')( + user: user + size: @size + position: @position + ) + + # start user popups + if !@noPopups + @userPopups(@position) diff --git a/app/assets/javascripts/app/views/avatar.jst.eco b/app/assets/javascripts/app/views/avatar.jst.eco new file mode 100644 index 000000000..a8c83f7c0 --- /dev/null +++ b/app/assets/javascripts/app/views/avatar.jst.eco @@ -0,0 +1 @@ +<%- @user.avatar(@size, @position, @class) %> \ No newline at end of file diff --git a/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco b/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco index b9cc85b36..c2148475c 100644 --- a/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco +++ b/app/assets/javascripts/app/views/dashboard/activity_stream.jst.eco @@ -1,19 +1 @@ -