Improved how to generate links to objects in ui.
This commit is contained in:
parent
b520bb9066
commit
683d676565
11 changed files with 86 additions and 34 deletions
|
@ -40,24 +40,21 @@ class App.DashboardActivityStream extends App.Controller
|
||||||
render: (items) ->
|
render: (items) ->
|
||||||
|
|
||||||
for item in 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 )
|
article = App.TicketArticle.find( item.o_id )
|
||||||
ticket = App.Ticket.find( article.ticket_id )
|
ticket = App.Ticket.find( article.ticket_id )
|
||||||
item.link = '#ticket/zoom/' + ticket.id + '/' + article.id
|
|
||||||
item.title = article.subject || ticket.title
|
item.title = article.subject || ticket.title
|
||||||
item.object = 'Article'
|
item.link = article.uiUrl()
|
||||||
|
|
||||||
else if item.object is 'User'
|
if App[item.object]
|
||||||
user = App.User.find( item.o_id )
|
object = App[item.object].find( item.o_id )
|
||||||
item.link = '#user/zoom/' + item.o_id
|
item.link = object.uiUrl()
|
||||||
item.title = user.displayName()
|
item.title = object.displayName()
|
||||||
item.object = 'User'
|
|
||||||
|
|
||||||
item.created_by = App.User.find( item.created_by_id )
|
item.created_by = App.User.find( item.created_by_id )
|
||||||
|
|
||||||
|
|
|
@ -28,24 +28,21 @@ class App.TicketHistory extends App.ControllerModal
|
||||||
render: ( items, orderClass = '' ) ->
|
render: ( items, orderClass = '' ) ->
|
||||||
|
|
||||||
for item in 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 )
|
article = App.TicketArticle.find( item.o_id )
|
||||||
ticket = App.Ticket.find( article.ticket_id )
|
ticket = App.Ticket.find( article.ticket_id )
|
||||||
item.link = '#ticket/zoom/' + ticket.id + '/' + article.id
|
|
||||||
item.title = article.subject || ticket.title
|
item.title = article.subject || ticket.title
|
||||||
item.object = 'Article'
|
item.link = article.uiUrl()
|
||||||
|
|
||||||
else if item.object is 'User'
|
if App[item.object]
|
||||||
user = App.User.find( item.o_id )
|
object = App[item.object].find( item.o_id )
|
||||||
item.link = '#user/zoom/' + item.o_id
|
item.link = object.uiUrl()
|
||||||
item.title = user.displayName()
|
item.title = object.displayName()
|
||||||
item.object = 'User'
|
|
||||||
|
|
||||||
item.created_by = App.User.find( item.created_by_id )
|
item.created_by = App.User.find( item.created_by_id )
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ class App.Navigation extends App.Controller
|
||||||
display: "##{ticket.number} - #{ticket.title} - #{ticket.humanTime}"
|
display: "##{ticket.number} - #{ticket.title} - #{ticket.humanTime}"
|
||||||
id: ticket.id
|
id: ticket.id
|
||||||
class: "ticket-popover"
|
class: "ticket-popover"
|
||||||
url: "#ticket/zoom/#{ticket.id}"
|
url: ticket.uiUrl()
|
||||||
area.result.push data
|
area.result.push data
|
||||||
else if area.name is 'User'
|
else if area.name is 'User'
|
||||||
area.result = []
|
area.result = []
|
||||||
|
@ -123,7 +123,7 @@ class App.Navigation extends App.Controller
|
||||||
display: "#{user.displayName()}"
|
display: "#{user.displayName()}"
|
||||||
id: user.id
|
id: user.id
|
||||||
class: "user-popover"
|
class: "user-popover"
|
||||||
url: "#users/#{user.id}"
|
url: user.uiUrl()
|
||||||
area.result.push data
|
area.result.push data
|
||||||
else if area.name is 'Organization'
|
else if area.name is 'Organization'
|
||||||
area.result = []
|
area.result = []
|
||||||
|
@ -133,7 +133,7 @@ class App.Navigation extends App.Controller
|
||||||
display: "#{organization.displayName()}"
|
display: "#{organization.displayName()}"
|
||||||
id: organization.id
|
id: organization.id
|
||||||
class: "organization-popover"
|
class: "organization-popover"
|
||||||
url: "#organizations/#{ticket.id}"
|
url: organization.uiUrl()
|
||||||
area.result.push data
|
area.result.push data
|
||||||
|
|
||||||
if @result
|
if @result
|
||||||
|
@ -320,11 +320,11 @@ class App.Navigation extends App.Controller
|
||||||
ticket = App.Ticket.find( item.o_id )
|
ticket = App.Ticket.find( item.o_id )
|
||||||
prio++
|
prio++
|
||||||
NavBarRight['RecendViewed::' + ticket.id + '-' + prio ] = {
|
NavBarRight['RecendViewed::' + ticket.id + '-' + prio ] = {
|
||||||
prio: prio,
|
prio: prio
|
||||||
parent: '#current_user',
|
parent: '#current_user'
|
||||||
name: item.recent_view_object + ' (' + ticket.title + ')',
|
name: item.recent_view_object + ' (' + ticket.title + ')'
|
||||||
target: '#ticket/zoom/' + ticket.id,
|
target: ticket.uiUrl()
|
||||||
divider: divider,
|
divider: divider
|
||||||
navheader: navheader
|
navheader: navheader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ class App.Model extends Spine.Model
|
||||||
App.Store.delete(key)
|
App.Store.delete(key)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
uiUrl: ->
|
||||||
|
'#'
|
||||||
|
|
||||||
displayName: ->
|
displayName: ->
|
||||||
return @name if @name
|
return @name if @name
|
||||||
if @realname
|
if @realname
|
||||||
|
@ -26,6 +29,10 @@ class App.Model extends Spine.Model
|
||||||
return name
|
return name
|
||||||
if @email
|
if @email
|
||||||
return @email
|
return @email
|
||||||
|
if @title
|
||||||
|
return @title
|
||||||
|
if @subject
|
||||||
|
return @subject
|
||||||
return '???'
|
return '???'
|
||||||
|
|
||||||
displayNameLong: ->
|
displayNameLong: ->
|
||||||
|
|
|
@ -17,3 +17,6 @@ class App.Group extends App.Model
|
||||||
@configure_overview = [
|
@configure_overview = [
|
||||||
'name',
|
'name',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
uiUrl: ->
|
||||||
|
'#group/zoom/' + @id
|
|
@ -14,6 +14,9 @@ class App.Organization extends App.Model
|
||||||
'shared',
|
'shared',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
uiUrl: ->
|
||||||
|
'#organization/zoom/' + @id
|
||||||
|
|
||||||
@_fillUp: (data) ->
|
@_fillUp: (data) ->
|
||||||
|
|
||||||
# addd users of organization
|
# addd users of organization
|
||||||
|
|
|
@ -20,6 +20,9 @@ class App.Ticket extends App.Model
|
||||||
{ name: 'article_count', display: 'Article#', style: 'width: 12%' },
|
{ name: 'article_count', display: 'Article#', style: 'width: 12%' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
uiUrl: ->
|
||||||
|
'#ticket/zoom/' + @id
|
||||||
|
|
||||||
@_fillUp: (data) ->
|
@_fillUp: (data) ->
|
||||||
|
|
||||||
# priority
|
# priority
|
||||||
|
|
|
@ -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' },
|
{ 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) ->
|
@_fillUp: (data) ->
|
||||||
|
|
||||||
# add created & updated
|
# add created & updated
|
||||||
|
|
|
@ -30,6 +30,9 @@ class App.User extends App.Model
|
||||||
'login', 'firstname', 'lastname',
|
'login', 'firstname', 'lastname',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
uiUrl: ->
|
||||||
|
'#user/zoom/' + @id
|
||||||
|
|
||||||
@_fillUp: (data) ->
|
@_fillUp: (data) ->
|
||||||
|
|
||||||
# set socal media links
|
# set socal media links
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Group < ApplicationModel
|
class Group < ApplicationModel
|
||||||
|
include Group::Assets
|
||||||
|
|
||||||
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
|
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
|
||||||
belongs_to :email_address
|
belongs_to :email_address
|
||||||
belongs_to :signature
|
belongs_to :signature
|
||||||
|
|
34
app/models/group/assets.rb
Normal file
34
app/models/group/assets.rb
Normal 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
|
Loading…
Reference in a new issue