diff --git a/app/assets/javascripts/app/controllers/_dashboard/activity_stream.js.coffee b/app/assets/javascripts/app/controllers/_dashboard/activity_stream.js.coffee index 0f1fcfd27..cf1d6c656 100644 --- a/app/assets/javascripts/app/controllers/_dashboard/activity_stream.js.coffee +++ b/app/assets/javascripts/app/controllers/_dashboard/activity_stream.js.coffee @@ -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 ) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee index 37fa9545e..60913ff5d 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee @@ -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 ) diff --git a/app/assets/javascripts/app/controllers/navigation.js.coffee b/app/assets/javascripts/app/controllers/navigation.js.coffee index 38f84c4e7..f169532af 100644 --- a/app/assets/javascripts/app/controllers/navigation.js.coffee +++ b/app/assets/javascripts/app/controllers/navigation.js.coffee @@ -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 } diff --git a/app/assets/javascripts/app/models/_application_model.js.coffee b/app/assets/javascripts/app/models/_application_model.js.coffee index 0bc429b4f..2e0340f5b 100644 --- a/app/assets/javascripts/app/models/_application_model.js.coffee +++ b/app/assets/javascripts/app/models/_application_model.js.coffee @@ -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: -> diff --git a/app/assets/javascripts/app/models/group.js.coffee b/app/assets/javascripts/app/models/group.js.coffee index 2336dd463..7ad3f1be6 100644 --- a/app/assets/javascripts/app/models/group.js.coffee +++ b/app/assets/javascripts/app/models/group.js.coffee @@ -17,3 +17,6 @@ class App.Group extends App.Model @configure_overview = [ 'name', ] + + uiUrl: -> + '#group/zoom/' + @id \ No newline at end of file diff --git a/app/assets/javascripts/app/models/organization.js.coffee b/app/assets/javascripts/app/models/organization.js.coffee index 64465300e..4de1a3b22 100644 --- a/app/assets/javascripts/app/models/organization.js.coffee +++ b/app/assets/javascripts/app/models/organization.js.coffee @@ -14,6 +14,9 @@ class App.Organization extends App.Model 'shared', ] + uiUrl: -> + '#organization/zoom/' + @id + @_fillUp: (data) -> # addd users of organization diff --git a/app/assets/javascripts/app/models/ticket.js.coffee b/app/assets/javascripts/app/models/ticket.js.coffee index 0dcea0da6..f7e585bac 100644 --- a/app/assets/javascripts/app/models/ticket.js.coffee +++ b/app/assets/javascripts/app/models/ticket.js.coffee @@ -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 diff --git a/app/assets/javascripts/app/models/ticket_article.js.coffee b/app/assets/javascripts/app/models/ticket_article.js.coffee index 2fa16dd27..4870f4d4d 100644 --- a/app/assets/javascripts/app/models/ticket_article.js.coffee +++ b/app/assets/javascripts/app/models/ticket_article.js.coffee @@ -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 diff --git a/app/assets/javascripts/app/models/user.js.coffee b/app/assets/javascripts/app/models/user.js.coffee index e8551d42f..2868a32e7 100644 --- a/app/assets/javascripts/app/models/user.js.coffee +++ b/app/assets/javascripts/app/models/user.js.coffee @@ -30,6 +30,9 @@ class App.User extends App.Model 'login', 'firstname', 'lastname', ] + uiUrl: -> + '#user/zoom/' + @id + @_fillUp: (data) -> # set socal media links diff --git a/app/models/group.rb b/app/models/group.rb index 758af4306..e3a730bc2 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -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 diff --git a/app/models/group/assets.rb b/app/models/group/assets.rb new file mode 100644 index 000000000..87eacc87a --- /dev/null +++ b/app/models/group/assets.rb @@ -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 \ No newline at end of file