Fix link for default widget
Convert single id to array to find item
This commit is contained in:
parent
7dcea95dd4
commit
5e4e3ac560
|
@ -69,14 +69,16 @@ class PagesController < ApplicationController
|
||||||
elsif params[:same_page_id]
|
elsif params[:same_page_id]
|
||||||
@item = Item.find(params[:same_page_id])
|
@item = Item.find(params[:same_page_id])
|
||||||
else
|
else
|
||||||
|
category_ids = params[:category_id].is_a?(Array) ? params[:category_id] : [params[:category_id]]
|
||||||
|
tag_ids = params[:tag_id].is_a?(Array) ? params[:tag_id] : [params[:tag_id]]
|
||||||
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
||||||
if !params[:category_id].blank? && !params[:tag_id].blank?
|
if !category_ids.blank? && !tag_ids.blank?
|
||||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category.in => params[:category_id], :tag.in => params[:tag_id]})
|
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category.in => category_ids, :tag.in => tag_ids})
|
||||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category.in => params[:category_id], :tag.in => [nil, []]}) unless @item
|
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category.in => category_ids, :tag.in => [nil, []]}) unless @item
|
||||||
elsif !params[:category_id].blank?
|
elsif !category_ids.blank?
|
||||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], :category.in => params[:category_id]).any_in(tag: [nil, []]).first
|
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], :category.in => category_ids).any_in(tag: [nil, []]).first
|
||||||
elsif !params[:tag_id].blank?
|
elsif !tag_ids.blank?
|
||||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], :tag.in => params[:tag_id]).any_in(category: [nil, []]).first
|
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], :tag.in => tag_ids).any_in(category: [nil, []]).first
|
||||||
end
|
end
|
||||||
@item = Item.find(params[:orig_page]) unless @item || params[:orig_page].blank?
|
@item = Item.find(params[:orig_page]) unless @item || params[:orig_page].blank?
|
||||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).all_of("tag" => {"$in" => [nil, []]},"category" => { "$in" => [nil, []]}).first unless @item
|
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).all_of("tag" => {"$in" => [nil, []]},"category" => { "$in" => [nil, []]}).first unless @item
|
||||||
|
|
|
@ -9,15 +9,15 @@ module DefaultWidgetHelper
|
||||||
if(method_ary.has_key?(field) and (switch == true))
|
if(method_ary.has_key?(field) and (switch == true))
|
||||||
url = case method_ary[field][:args]
|
url = case method_ary[field][:args]
|
||||||
when nil # no args
|
when nil # no args
|
||||||
get_data_link(method_ary[field]["method"], options)
|
get_data_link(method_ary[field][:method], options)
|
||||||
when :self # passing self
|
when :self # passing self
|
||||||
get_data_link(method_ary[field]['method'], options,row_data.id)
|
get_data_link(method_ary[field][:method], options,row_data.id)
|
||||||
else
|
else
|
||||||
ary = method_ary[field][:args].clone
|
ary = method_ary[field][:args].clone
|
||||||
object_hash = ary.each do |key,val|
|
object_hash = ary.each do |key,val|
|
||||||
ary[key]= type_trans_or_to_s(row_data.send(val[0]).send(val[1]))
|
ary[key]= type_trans_or_to_s(row_data.send(val[0]).send(val[1]))
|
||||||
end
|
end
|
||||||
get_data_link(method_ary[field]['method'], options,object_hash)
|
get_data_link(method_ary[field][:method], options,object_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
link_to row_data.send(field), url
|
link_to row_data.send(field), url
|
||||||
|
@ -50,7 +50,7 @@ module DefaultWidgetHelper
|
||||||
when NilClass
|
when NilClass
|
||||||
eval eval("#{method_entry}(#{options})")
|
eval eval("#{method_entry}(#{options})")
|
||||||
when BSON::ObjectId
|
when BSON::ObjectId
|
||||||
object = "'#{object.to_s}'"
|
object = object.to_s
|
||||||
eval("#{method_entry}(#{{:id => object}.merge options})")
|
eval("#{method_entry}(#{{:id => object}.merge options})")
|
||||||
when Hash
|
when Hash
|
||||||
eval("#{method_entry}(#{object.merge options})")
|
eval("#{method_entry}(#{object.merge options})")
|
||||||
|
|
Loading…
Reference in New Issue