From 5458de229f39b059611132a53a39aaf37d1d31e8 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 2 Aug 2014 23:54:54 +0200 Subject: [PATCH] Moved to asset support for initial page load. --- app/controllers/sessions/collection_base.rb | 41 ++++++++-------- .../sessions/collection_network.rb | 13 ++--- app/controllers/sessions/collection_ticket.rb | 47 ++++++++++--------- 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/app/controllers/sessions/collection_base.rb b/app/controllers/sessions/collection_base.rb index b3abe18e1..69947cb8b 100644 --- a/app/controllers/sessions/collection_base.rb +++ b/app/controllers/sessions/collection_base.rb @@ -1,34 +1,37 @@ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module ExtraCollection - def session( collections, user ) + def session( collections, assets, user ) # all base stuff - collections[ Taskbar.to_app_model ] = Taskbar.where( :user_id => user.id ) - collections[ Role.to_app_model ] = Role.all - collections[ Group.to_app_model ] = Group.all + collections[ Taskbar.to_app_model ] = Taskbar.where( :user_id => user.id ) + assets = {} + collections[ Taskbar.to_app_model ].each {|item| + assets = item.assets(assets) + } + collections[ Role.to_app_model ] = Role.all + collections[ Role.to_app_model ].each {|item| + assets = item.assets(assets) + } + + collections[ Group.to_app_model ] = Group.all + collections[ Group.to_app_model ].each {|item| + assets = item.assets(assets) + } if !user.is_role('Customer') collections[ Organization.to_app_model ] = Organization.all + collections[ Organization.to_app_model ].each {|item| + assets = item.assets(assets) + } else if user.organization_id collections[ Organization.to_app_model ] = Organization.where( :id => user.organization_id ) + collections[ Organization.to_app_model ].each {|item| + assets = item.assets(assets) + } end end end - def push( collections, user ) - - # all base stuff - #collections[ Role.to_app_model ] = Role.all - #collections[ Group.to_app_model ] = Group.all - - #if !user.is_role('Customer') - # collections[ Organization.to_app_model ] = Organization.all - #else - # if user.organization_id - # collections[ Organization.to_app_model ] = Organization.where( :id => user.organization_id ) - # end - #end - end - module_function :session, :push + module_function :session end diff --git a/app/controllers/sessions/collection_network.rb b/app/controllers/sessions/collection_network.rb index 2048dc58c..466801d86 100644 --- a/app/controllers/sessions/collection_network.rb +++ b/app/controllers/sessions/collection_network.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module ExtraCollection - def session( collections, user ) + def session( collections, assets, user ) collections[ Network.to_app_model ] = Network.all collections[ Network::Category.to_app_model ] = Network::Category.all @@ -9,13 +9,6 @@ module ExtraCollection collections[ Network::Privacy.to_app_model ] = Network::Privacy.all end - def push( collections, user ) - collections[ Network.to_app_model ] = Network.all - collections[ Network::Category.to_app_model ] = Network::Category.all - collections[ Network::Category::Type.to_app_model ] = Network::Category::Type.all - collections[ Network::Privacy.to_app_model ] = Network::Privacy.all - - end - module_function :session, :push -end + module_function :session +end \ No newline at end of file diff --git a/app/controllers/sessions/collection_ticket.rb b/app/controllers/sessions/collection_ticket.rb index 032b79a91..20645bb7e 100644 --- a/app/controllers/sessions/collection_ticket.rb +++ b/app/controllers/sessions/collection_ticket.rb @@ -1,42 +1,43 @@ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module ExtraCollection - def session( collections, user ) + def session( collections, assets, user ) # all ticket stuff collections[ Ticket::StateType.to_app_model ] = Ticket::StateType.all + collections[ Ticket::StateType.to_app_model ].each {|item| + assets = item.assets(assets) + } collections[ Ticket::State.to_app_model ] = Ticket::State.all + collections[ Ticket::State.to_app_model ].each {|item| + assets = item.assets(assets) + } collections[ Ticket::Priority.to_app_model ] = Ticket::Priority.all + collections[ Ticket::Priority.to_app_model ].each {|item| + assets = item.assets(assets) + } collections[ Ticket::Article::Type.to_app_model ] = Ticket::Article::Type.all + collections[ Ticket::Article::Type.to_app_model ].each {|item| + assets = item.assets(assets) + } collections[ Ticket::Article::Sender.to_app_model ] = Ticket::Article::Sender.all - + collections[ Ticket::Article::Sender.to_app_model ].each {|item| + assets = item.assets(assets) + } if !user.is_role('Customer') # all signatures collections[ Signature.to_app_model ] = Signature.all + collections[ Signature.to_app_model ].each {|item| + assets = item.assets(assets) + } # all email addresses collections[ EmailAddress.to_app_model ] = EmailAddress.all + collections[ EmailAddress.to_app_model ].each {|item| + assets = item.assets(assets) + } end end - def push( collections, user ) - - # all ticket stuff - #collections[ Ticket::StateType.to_app_model ] = Ticket::StateType.all - #collections[ Ticket::State.to_app_model ] = Ticket::State.all - #collections[ Ticket::Priority.to_app_model ] = Ticket::Priority.all - #collections[ Ticket::Article::Type.to_app_model ] = Ticket::Article::Type.all - #collections[ Ticket::Article::Sender.to_app_model ] = Ticket::Article::Sender.all - - #if !user.is_role('Customer') - - # all signatures - # collections[ Signature.to_app_model ] = Signature.all - - # all email addresses - # collections[ EmailAddress.to_app_model ] = EmailAddress.all - #end - end - - module_function :session, :push -end + module_function :session +end \ No newline at end of file