#
#
def link_to_resource(resource, name=nil, options={})
+ period_index=options[:period]
+ period_index=nil if period_index && period_index<=0
if resource.display_dashboard?
if options[:dashboard]
root = "#{ApplicationController.root_context}/dashboard/index?"
query = request.query_parameters
query[:id] = resource.id
query[:metric] = options[:metric] if options[:metric]
+ query[:period] = period_index if period_index
query.each do |key, value|
path += '&' unless path.empty?
path += "#{u key}=#{u value}"
"<a class='#{options[:class]}' title='#{options[:title]}' href='#{root + path}'>#{name || resource.name}</a>"
else
url = "#{ApplicationController.root_context}/dashboard/index?id=#{u resource.key}"
+ url += "&period=#{u period_index}" if period_index
url += "&metric=#{u options[:metric]}" if options[:metric]
"<a class='#{options[:class]}' title='#{options[:title]}' " +
"onclick='window.open(this.href,\"resource-#{resource.key.parameterize}\",\"\");return false;' " +