Moved to own controller for showing avatars.
This commit is contained in:
parent
6b6d0b89c4
commit
30560ad5b1
9 changed files with 74 additions and 43 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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)
|
1
app/assets/javascripts/app/views/avatar.jst.eco
Normal file
1
app/assets/javascripts/app/views/avatar.jst.eco
Normal file
|
@ -0,0 +1 @@
|
|||
<%- @user.avatar(@size, @position, @class) %>
|
|
@ -1,19 +1 @@
|
|||
<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 %>
|
||||
|
|
|
@ -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>
|
|
@ -4,7 +4,7 @@
|
|||
<a class="list-button horizontal centered dropdown-toggle" data-toggle="dropdown" href="<%= item.target %>" title="<%- @T( item.name ) %>">
|
||||
<span class="dropdown-nose"></span>
|
||||
<% if item.class is 'user': %>
|
||||
<%- item.avatar %>
|
||||
<span class="js-avatar"></span>
|
||||
<% else: %>
|
||||
<span class="green plus icon"></span>
|
||||
<span class="white plus icon"></span>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<input type="hidden" name="internal" value="<%= @article.internal %>">
|
||||
<input type="hidden" name="form_id" value="<%= @article.form_id %>">
|
||||
<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="pop-selected u-clickable centered">
|
||||
<div class="gray <%- @article.type %> channel icon"></div>
|
||||
|
|
Loading…
Reference in a new issue