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]
|
||||
@item = Item.find(params[:same_page_id])
|
||||
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]})
|
||||
if !params[:category_id].blank? && !params[:tag_id].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 => params[:category_id], :tag.in => [nil, []]}) unless @item
|
||||
elsif !params[:category_id].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
|
||||
elsif !params[:tag_id].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
|
||||
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 => category_ids, :tag.in => tag_ids})
|
||||
@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 !category_ids.blank?
|
||||
@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 !tag_ids.blank?
|
||||
@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
|
||||
@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
|
||||
|
|
|
@ -9,15 +9,15 @@ module DefaultWidgetHelper
|
|||
if(method_ary.has_key?(field) and (switch == true))
|
||||
url = case method_ary[field][: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
|
||||
get_data_link(method_ary[field]['method'], options,row_data.id)
|
||||
get_data_link(method_ary[field][:method], options,row_data.id)
|
||||
else
|
||||
ary = method_ary[field][:args].clone
|
||||
object_hash = ary.each do |key,val|
|
||||
ary[key]= type_trans_or_to_s(row_data.send(val[0]).send(val[1]))
|
||||
end
|
||||
get_data_link(method_ary[field]['method'], options,object_hash)
|
||||
get_data_link(method_ary[field][:method], options,object_hash)
|
||||
end
|
||||
|
||||
link_to row_data.send(field), url
|
||||
|
@ -50,7 +50,7 @@ module DefaultWidgetHelper
|
|||
when NilClass
|
||||
eval eval("#{method_entry}(#{options})")
|
||||
when BSON::ObjectId
|
||||
object = "'#{object.to_s}'"
|
||||
object = object.to_s
|
||||
eval("#{method_entry}(#{{:id => object}.merge options})")
|
||||
when Hash
|
||||
eval("#{method_entry}(#{object.merge options})")
|
||||
|
|
Loading…
Reference in New Issue