Improved object lookup for activity stream.
This commit is contained in:
parent
68e7ec857b
commit
97f8425c37
5 changed files with 26 additions and 9 deletions
|
@ -44,17 +44,14 @@ class App.DashboardActivityStream extends App.Controller
|
|||
item.link = ''
|
||||
item.title = '???'
|
||||
|
||||
if item.object is 'Ticket::Article'
|
||||
item.object = 'Article'
|
||||
article = App.TicketArticle.find( item.o_id )
|
||||
ticket = App.Ticket.find( article.ticket_id )
|
||||
item.title = article.subject || ticket.title
|
||||
item.link = article.uiUrl()
|
||||
# convert backend name space to local name space
|
||||
item.object = item.object.replace("::", '')
|
||||
|
||||
if App[item.object]
|
||||
object = App[item.object].find( item.o_id )
|
||||
item.link = object.uiUrl()
|
||||
item.title = object.displayName()
|
||||
object = App[item.object].find( item.o_id )
|
||||
item.link = object.uiUrl()
|
||||
item.title = object.displayName()
|
||||
item.object = object.objectDisplayName()
|
||||
|
||||
item.created_by = App.User.find( item.created_by_id )
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ class App.Model extends Spine.Model
|
|||
uiUrl: ->
|
||||
'#'
|
||||
|
||||
objectDisplayName: ->
|
||||
@constructor.className
|
||||
|
||||
displayName: ->
|
||||
return @name if @name
|
||||
if @realname
|
||||
|
|
|
@ -17,6 +17,9 @@ class App.TicketArticle extends App.Model
|
|||
uiUrl: ->
|
||||
'#ticket/zoom/' + @ticket_id + '/' + @id
|
||||
|
||||
objectDisplayName: ->
|
||||
'Article'
|
||||
|
||||
@_fillUp: (data) ->
|
||||
|
||||
# add created & updated
|
||||
|
@ -31,3 +34,12 @@ class App.TicketArticle extends App.Model
|
|||
|
||||
data
|
||||
|
||||
|
||||
displayName: ->
|
||||
if @subject
|
||||
return @subject
|
||||
if App.Ticket.exists( @ticket_id )
|
||||
ticket = App.Ticket.find( @ticket_id )
|
||||
if ticket
|
||||
return ticket.title
|
||||
'???'
|
|
@ -111,6 +111,7 @@ returns
|
|||
# get related objects
|
||||
assets = {}
|
||||
activity_stream.each {|item|
|
||||
require item['object'].to_filename
|
||||
record = Kernel.const_get( item['object'] ).find( item['o_id'] )
|
||||
assets = record.assets(assets)
|
||||
}
|
||||
|
|
|
@ -19,4 +19,8 @@ class String
|
|||
line.length > options[:line_width] ? line.gsub(/(.{1,#{options[:line_width]}})(\s+|$)/, "\\1\n").strip : line
|
||||
end * "\n"
|
||||
end
|
||||
def to_filename
|
||||
camel_cased_word = self.to_s
|
||||
camel_cased_word.gsub(/::/, '/').downcase
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue