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 # lookup real data
if App[item.object] if App[item.object]
object = App[item.object].find( item.o_id ) object = App[item.object].find( item.o_id )
item.link = object.uiUrl() item.link = object.uiUrl()
item.title = object.displayName() item.title = object.displayName()
item.object_name = object.objectDisplayName() item.object_name = object.objectDisplayName()
item.cssIcon = object.iconActivity( @Session.all() )
item.created_by = App.User.retrieve( item.created_by_id ) item.created_by = App.User.retrieve( item.created_by_id )

View file

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

View file

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

View file

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

View file

@ -26,3 +26,14 @@ class App.Ticket extends App.Model
uiUrl: -> uiUrl: ->
'#ticket/zoom/' + @id '#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

@ -32,3 +32,9 @@ class App.TicketArticle extends App.Model
if ticket if ticket
return ticket.title 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> <h2 class="can-move"><%- @T( @head ) %></h2>
<% for item in @items: %> <% 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="avatar" style="background-image: url(<%- item.created_by.image %>)"></div>
<div class="activity-body flex horizontal"> <div class="activity-body flex horizontal">
<div class="activity-message flex"> <div class="activity-message flex">
@ -8,7 +8,7 @@
<div class="activity-time humanTimeFromNow" data-time="<%- item.created_at %>">?</div> <div class="activity-time humanTimeFromNow" data-time="<%- item.created_at %>">?</div>
</div> </div>
<div class="activity-icon"> <div class="activity-icon">
<span class="priority icon"></span> <span class="<%- item.cssIcon %> icon"></span>
</div> </div>
</div> </div>
</div> </div>