Improved how to generate links to objects in ui.

This commit is contained in:
Martin Edenhofer 2013-09-30 01:24:52 +02:00
parent b520bb9066
commit 683d676565
11 changed files with 86 additions and 34 deletions

View file

@ -40,24 +40,21 @@ class App.DashboardActivityStream extends App.Controller
render: (items) ->
for item in items
if item.object is 'Ticket'
ticket = App.Ticket.find( item.o_id )
item.link = '#ticket/zoom/' + ticket.id
item.title = ticket.title
item.object = 'Ticket'
else if item.object is 'Ticket::Article'
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.link = '#ticket/zoom/' + ticket.id + '/' + article.id
item.title = article.subject || ticket.title
item.object = 'Article'
item.link = article.uiUrl()
else if item.object is 'User'
user = App.User.find( item.o_id )
item.link = '#user/zoom/' + item.o_id
item.title = user.displayName()
item.object = 'User'
if App[item.object]
object = App[item.object].find( item.o_id )
item.link = object.uiUrl()
item.title = object.displayName()
item.created_by = App.User.find( item.created_by_id )

View file

@ -28,24 +28,21 @@ class App.TicketHistory extends App.ControllerModal
render: ( items, orderClass = '' ) ->
for item in items
if item.object is 'Ticket'
ticket = App.Ticket.find( item.o_id )
item.link = '#ticket/zoom/' + ticket.id
item.title = ticket.title
item.object = 'Ticket'
else if item.object is 'Ticket::Article'
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.link = '#ticket/zoom/' + ticket.id + '/' + article.id
item.title = article.subject || ticket.title
item.object = 'Article'
item.link = article.uiUrl()
else if item.object is 'User'
user = App.User.find( item.o_id )
item.link = '#user/zoom/' + item.o_id
item.title = user.displayName()
item.object = 'User'
if App[item.object]
object = App[item.object].find( item.o_id )
item.link = object.uiUrl()
item.title = object.displayName()
item.created_by = App.User.find( item.created_by_id )

View file

@ -113,7 +113,7 @@ class App.Navigation extends App.Controller
display: "##{ticket.number} - #{ticket.title} - #{ticket.humanTime}"
id: ticket.id
class: "ticket-popover"
url: "#ticket/zoom/#{ticket.id}"
url: ticket.uiUrl()
area.result.push data
else if area.name is 'User'
area.result = []
@ -123,7 +123,7 @@ class App.Navigation extends App.Controller
display: "#{user.displayName()}"
id: user.id
class: "user-popover"
url: "#users/#{user.id}"
url: user.uiUrl()
area.result.push data
else if area.name is 'Organization'
area.result = []
@ -133,7 +133,7 @@ class App.Navigation extends App.Controller
display: "#{organization.displayName()}"
id: organization.id
class: "organization-popover"
url: "#organizations/#{ticket.id}"
url: organization.uiUrl()
area.result.push data
if @result
@ -320,11 +320,11 @@ class App.Navigation extends App.Controller
ticket = App.Ticket.find( item.o_id )
prio++
NavBarRight['RecendViewed::' + ticket.id + '-' + prio ] = {
prio: prio,
parent: '#current_user',
name: item.recent_view_object + ' (' + ticket.title + ')',
target: '#ticket/zoom/' + ticket.id,
divider: divider,
prio: prio
parent: '#current_user'
name: item.recent_view_object + ' (' + ticket.title + ')'
target: ticket.uiUrl()
divider: divider
navheader: navheader
}

View file

@ -13,6 +13,9 @@ class App.Model extends Spine.Model
App.Store.delete(key)
)
uiUrl: ->
'#'
displayName: ->
return @name if @name
if @realname
@ -26,6 +29,10 @@ class App.Model extends Spine.Model
return name
if @email
return @email
if @title
return @title
if @subject
return @subject
return '???'
displayNameLong: ->

View file

@ -17,3 +17,6 @@ class App.Group extends App.Model
@configure_overview = [
'name',
]
uiUrl: ->
'#group/zoom/' + @id

View file

@ -14,6 +14,9 @@ class App.Organization extends App.Model
'shared',
]
uiUrl: ->
'#organization/zoom/' + @id
@_fillUp: (data) ->
# addd users of organization

View file

@ -20,6 +20,9 @@ class App.Ticket extends App.Model
{ name: 'article_count', display: 'Article#', style: 'width: 12%' },
]
uiUrl: ->
'#ticket/zoom/' + @id
@_fillUp: (data) ->
# priority

View file

@ -14,6 +14,9 @@ class App.TicketArticle extends App.Model
{ name: 'internal', display: 'Visibility', tag: 'radio', default: false, null: true, options: { true: 'internal', false: 'public' }, class: 'medium' },
]
uiUrl: ->
'#ticket/zoom/' + @ticket_id + '/' + @id
@_fillUp: (data) ->
# add created & updated

View file

@ -30,6 +30,9 @@ class App.User extends App.Model
'login', 'firstname', 'lastname',
]
uiUrl: ->
'#user/zoom/' + @id
@_fillUp: (data) ->
# set socal media links

View file

@ -1,6 +1,8 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Group < ApplicationModel
include Group::Assets
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
belongs_to :email_address
belongs_to :signature

View file

@ -0,0 +1,34 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
module Group::Assets
=begin
get all assets / related models for this group
group = Group.find(123)
result = group.assets( assets_if_exists )
returns
result = {
:groups => {
123 => group_model_123,
1234 => group_model_1234,
}
}
=end
def assets (data)
if !data[ Group.to_app_model ]
data[ Group.to_app_model ] = {}
end
if !data[ Group.to_app_model ][ self.id ]
data[ Group.to_app_model ][ self.id ] = self.attributes
end
data
end
end