Improved icon support, moved definition of used icons to model.

This commit is contained in:
Martin Edenhofer 2014-07-24 14:49:24 +02:00
parent 01882851d9
commit 9805e3cf14
7 changed files with 50 additions and 27 deletions

View file

@ -49,10 +49,11 @@ class App.DashboardActivityStream extends App.Controller
# lookup real data
if App[item.object]
object = App[item.object].find( item.o_id )
item.link = object.uiUrl()
item.title = object.displayName()
item.object_name = object.objectDisplayName()
object = App[item.object].find( item.o_id )
item.link = object.uiUrl()
item.title = object.displayName()
item.object_name = object.objectDisplayName()
item.cssIcon = object.iconActivity( @Session.all() )
item.created_by = App.User.retrieve( item.created_by_id )

View file

@ -112,22 +112,20 @@ class App.DashboardTicket extends App.Controller
attribute.data =
id: refObject.id
value
callbackPriorityIconHeader = (header) ->
callbackIconHeader = (header) ->
attribute =
name: 'priority_icon'
name: 'icon'
display: ''
translation: false
style: 'width: 28px'
header.unshift(0)
header[0] = attribute
header
callbackPriorityIcon = (value, object, attribute, header, refObject) ->
callbackIcon = (value, object, attribute, header, refObject) ->
value = ' '
attribute.class = 'priority icon'
if object && object.priority_id
attribute.class += " level-#{object.priority_id}"
attribute.class = object.icon()
attribute.link = ''
attribute.title = App.i18n.translateInline( object.priority.displayName() )
attribute.title = App.i18n.translateInline( object.iconTitle() )
value
new App.ControllerTable(
@ -137,13 +135,13 @@ class App.DashboardTicket extends App.Controller
objects: @tickets_in_table,
checkbox: false
groupBy: @overview.group_by
callbackHeader: callbackPriorityIconHeader
callbackHeader: callbackIconHeader
bindRow:
events:
'click': openTicket
callbackAttributes:
priority_icon:
[ callbackPriorityIcon ]
icon:
[ callbackIcon ]
customer_id:
[ callbackResetLink, callbackUserPopover ]
owner_id:

View file

@ -203,22 +203,20 @@ class Table extends App.ControllerContent
@el.find('.bulk-action').addClass('hide')
else
@el.find('.bulk-action').removeClass('hide')
callbackPriorityIconHeader = (header) ->
callbackIconHeader = (header) ->
attribute =
name: 'priority_icon'
name: 'icon'
display: ''
translation: false
style: 'width: 28px'
header.unshift(0)
header[0] = attribute
header
callbackPriorityIcon = (value, object, attribute, header, refObject) ->
callbackIcon = (value, object, attribute, header, refObject) ->
value = ' '
attribute.class = 'priority icon'
if object && object.priority_id
attribute.class += " level-#{object.priority_id}"
attribute.class = object.icon()
attribute.link = ''
attribute.title = App.i18n.translateInline( object.priority.displayName() )
attribute.title = App.i18n.translateInline( object.iconTitle() )
value
new App.ControllerTable(
@ -235,10 +233,10 @@ class Table extends App.ControllerContent
# customer_id:
# events:
# 'mouseover': popOver
callbackHeader: callbackPriorityIconHeader
callbackHeader: callbackIconHeader
callbackAttributes:
priority_icon:
[ callbackPriorityIcon ]
icon:
[ callbackIcon ]
customer_id:
[ callbackUserPopover ]
owner_id:

View file

@ -59,6 +59,15 @@ class App.Model extends Spine.Model
return name
return '???'
icon: (user) ->
''
iconTitle: (user) ->
''
iconActivity: (user) ->
''
@validate: ( data = {} ) ->
return if !data['model'].configure_attributes

View file

@ -26,3 +26,14 @@ class App.Ticket extends App.Model
uiUrl: ->
'#ticket/zoom/' + @id
icon: (user) ->
"priority icon level-#{ @priority_id }"
iconTitle: (user) ->
App.TicketPriority.find( @priority_id ).displayName()
iconActivity: (user) ->
if @owner_id == user.id
return 'user'
'group'

View file

@ -31,4 +31,10 @@ class App.TicketArticle extends App.Model
ticket = App.Ticket.find( @ticket_id )
if ticket
return ticket.title
'???'
'???'
iconActivity: (user) ->
ticket = App.Ticket.find(@ticket_id)
if ticket.owner_id == user.id
return 'user'
'group'

View file

@ -1,6 +1,6 @@
<h2 class="can-move"><%- @T( @head ) %></h2>
<% for item in @items: %>
<div class="level-1 activity-entry horizontal">
<div class="activity-entry horizontal">
<div class="avatar" style="background-image: url(<%- item.created_by.image %>)"></div>
<div class="activity-body flex horizontal">
<div class="activity-message flex">
@ -8,7 +8,7 @@
<div class="activity-time humanTimeFromNow" data-time="<%- item.created_at %>">?</div>
</div>
<div class="activity-icon">
<span class="priority icon"></span>
<span class="<%- item.cssIcon %> icon"></span>
</div>
</div>
</div>