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.link = ''
|
||||||
item.title = '???'
|
item.title = '???'
|
||||||
|
|
||||||
if item.object is 'Ticket::Article'
|
# convert backend name space to local name space
|
||||||
item.object = 'Article'
|
item.object = item.object.replace("::", '')
|
||||||
article = App.TicketArticle.find( item.o_id )
|
|
||||||
ticket = App.Ticket.find( article.ticket_id )
|
|
||||||
item.title = article.subject || ticket.title
|
|
||||||
item.link = article.uiUrl()
|
|
||||||
|
|
||||||
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 = object.objectDisplayName()
|
||||||
|
|
||||||
item.created_by = App.User.find( item.created_by_id )
|
item.created_by = App.User.find( item.created_by_id )
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ class App.Model extends Spine.Model
|
||||||
uiUrl: ->
|
uiUrl: ->
|
||||||
'#'
|
'#'
|
||||||
|
|
||||||
|
objectDisplayName: ->
|
||||||
|
@constructor.className
|
||||||
|
|
||||||
displayName: ->
|
displayName: ->
|
||||||
return @name if @name
|
return @name if @name
|
||||||
if @realname
|
if @realname
|
||||||
|
|
|
@ -17,6 +17,9 @@ class App.TicketArticle extends App.Model
|
||||||
uiUrl: ->
|
uiUrl: ->
|
||||||
'#ticket/zoom/' + @ticket_id + '/' + @id
|
'#ticket/zoom/' + @ticket_id + '/' + @id
|
||||||
|
|
||||||
|
objectDisplayName: ->
|
||||||
|
'Article'
|
||||||
|
|
||||||
@_fillUp: (data) ->
|
@_fillUp: (data) ->
|
||||||
|
|
||||||
# add created & updated
|
# add created & updated
|
||||||
|
@ -31,3 +34,12 @@ class App.TicketArticle extends App.Model
|
||||||
|
|
||||||
data
|
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
|
# get related objects
|
||||||
assets = {}
|
assets = {}
|
||||||
activity_stream.each {|item|
|
activity_stream.each {|item|
|
||||||
|
require item['object'].to_filename
|
||||||
record = Kernel.const_get( item['object'] ).find( item['o_id'] )
|
record = Kernel.const_get( item['object'] ).find( item['o_id'] )
|
||||||
assets = record.assets(assets)
|
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
|
line.length > options[:line_width] ? line.gsub(/(.{1,#{options[:line_width]}})(\s+|$)/, "\\1\n").strip : line
|
||||||
end * "\n"
|
end * "\n"
|
||||||
end
|
end
|
||||||
|
def to_filename
|
||||||
|
camel_cased_word = self.to_s
|
||||||
|
camel_cased_word.gsub(/::/, '/').downcase
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue