Moved to asset support for initial page load.

This commit is contained in:
Martin Edenhofer 2014-08-02 23:54:54 +02:00
parent 44590eb9b2
commit 5458de229f
3 changed files with 49 additions and 52 deletions

View file

@ -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

View file

@ -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
module_function :session
end

View file

@ -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
module_function :session
end