Moved to own controller for showing avatars.

This commit is contained in:
Martin Edenhofer 2015-03-09 01:24:02 +01:00
parent 6b6d0b89c4
commit 30560ad5b1
9 changed files with 74 additions and 43 deletions

View file

@ -268,13 +268,14 @@ class App.Controller extends Spine.Controller
userPopups: (position = 'right') -> userPopups: (position = 'right') ->
# open user in new task if current user is agent # open user in new task if current user is agent
if @isRole('Agent') return if !@isRole('Agent')
@el.find('div.user-popover, span.user-popover').bind('click', (e) =>
id = $(e.target).data('id') @el.find('div.user-popover, span.user-popover').bind('click', (e) =>
if id id = $(e.target).data('id')
user = App.User.find(id) if id
@navigate user.uiUrl() user = App.User.find(id)
); @navigate user.uiUrl()
);
@userPopupsDestroy() @userPopupsDestroy()
@ -325,13 +326,14 @@ class App.Controller extends Spine.Controller
organizationPopups: (position = 'right') -> organizationPopups: (position = 'right') ->
# open org in new task if current user agent # open org in new task if current user agent
if @isRole('Agent') return if !@isRole('Agent')
@el.find('div.organization-popover, span.organization-popover').bind('click', (e) =>
id = $(e.target).data('id') @el.find('div.organization-popover, span.organization-popover').bind('click', (e) =>
if id id = $(e.target).data('id')
organization = App.Organization.find(id) if id
@navigate organization.uiUrl() organization = App.Organization.find(id)
); @navigate organization.uiUrl()
);
@organizationPopupsDestroy() @organizationPopupsDestroy()

View file

@ -40,16 +40,22 @@ class App.DashboardActivityStream extends App.Controller
render: (items) -> render: (items) ->
items = @prepareForObjectList(items) items = @prepareForObjectList(items)
html = App.view('dashboard/activity_stream')( @html App.view('dashboard/activity_stream')(
head: 'Activity Stream', head: 'Activity Stream',
items: items
) )
html = $(html) for item in items
@el.append( @renderItem(item) )
@html html
# start user popups
@userPopups('left')
# update time # update time
@frontendTimeUpdate() @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

View file

@ -86,6 +86,12 @@ class App.Navigation extends App.Controller
active_tab: active_tab active_tab: active_tab
) )
new App.WidgetAvatar(
el: @$('.js-avatar')
user_id: App.Session.get('id')
noPopups: true
)
renderResult: (result = []) => renderResult: (result = []) =>
el = @$('#global-search-result') el = @$('#global-search-result')

View file

@ -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)

View file

@ -0,0 +1 @@
<%- @user.avatar(@size, @position, @class) %>

View file

@ -1,19 +1 @@
<h2 class="can-move"><%- @T( @head ) %></h2> <h2 class="can-move"><%- @T( @head ) %></h2>
<% for item in @items: %>
<div class="activity-entry horizontal">
<a class="activity-avatar" href="<%- item.created_by.uiUrl() %>">
<%- item.created_by.avatar() %>
</a>
<a href="<%- item.link %>" class="activity-body flex horizontal">
<span class="activity-message flex">
<span class="activity-text">
<%= item.created_by.displayName() %> <%- @T( item.type ) %> <%- @T( item.object_name ) %><% if item.title: %> (<%= item.title %>)<% end %>
</span>
<span class="activity-time humanTimeFromNow" data-time="<%- item.created_at %>">?</span>
</span>
<span class="activity-icon">
<span class="<%- item.cssIcon %> icon"></span>
</span>
</a>
</div>
<% end %>

View file

@ -0,0 +1,14 @@
<div class="activity-entry horizontal">
<div class="activity-avatar js-avatar"></div>
<a href="<%- @item.link %>" class="activity-body flex horizontal">
<span class="activity-message flex">
<span class="activity-text">
<%= @item.created_by.displayName() %> <%- @T( @item.type ) %> <%- @T( @item.object_name ) %><% if @item.title: %> (<%= @item.title %>)<% end %>
</span>
<span class="activity-time humanTimeFromNow" data-time="<%- @item.created_at %>">?</span>
</span>
<span class="activity-icon">
<span class="<%- @item.cssIcon %> icon"></span>
</span>
</a>
</div>

View file

@ -4,7 +4,7 @@
<a class="list-button horizontal centered dropdown-toggle" data-toggle="dropdown" href="<%= item.target %>" title="<%- @T( item.name ) %>"> <a class="list-button horizontal centered dropdown-toggle" data-toggle="dropdown" href="<%= item.target %>" title="<%- @T( item.name ) %>">
<span class="dropdown-nose"></span> <span class="dropdown-nose"></span>
<% if item.class is 'user': %> <% if item.class is 'user': %>
<%- item.avatar %> <span class="js-avatar"></span>
<% else: %> <% else: %>
<span class="green plus icon"></span> <span class="green plus icon"></span>
<span class="white plus icon"></span> <span class="white plus icon"></span>

View file

@ -3,7 +3,7 @@
<input type="hidden" name="internal" value="<%= @article.internal %>"> <input type="hidden" name="internal" value="<%= @article.internal %>">
<input type="hidden" name="form_id" value="<%= @article.form_id %>"> <input type="hidden" name="form_id" value="<%= @article.form_id %>">
<div class="editControls"> <div class="editControls">
<%- App.User.fullLocal( @S('id') ).avatar("40", 'right', 'zIndex-5') %> <div class="js-avatar"></div>
<div class="dark pop-select zIndex-7 editControls-item"> <div class="dark pop-select zIndex-7 editControls-item">
<div class="pop-selected u-clickable centered"> <div class="pop-selected u-clickable centered">
<div class="gray <%- @article.type %> channel icon"></div> <div class="gray <%- @article.type %> channel icon"></div>