diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index ece047f1..ef9e3e77 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -76,9 +76,10 @@ class PagesController < ApplicationController elsif !params[:tag_id].blank? @item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], tag: params[:tag_id]).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 - @item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).first unless @item @item = Item.where(module_app_id: module_app.id, app_frontend_url: 'default_widget').first unless @item + @item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).first unless @item end raise PageError,'Missing Frontend Page' if @item.nil? end diff --git a/app/helpers/default_widget_helper.rb b/app/helpers/default_widget_helper.rb index 913c77ee..9173b823 100644 --- a/app/helpers/default_widget_helper.rb +++ b/app/helpers/default_widget_helper.rb @@ -3,24 +3,24 @@ module DefaultWidgetHelper I18n.t("#{@page_part.module_app.key}.default_widget.#{field}") end - def link_to_field(row_data,field,switch) + def link_to_field(row_data,field, options=nil, switch) method_ary = @page_part.module_app.widget_fields_link_method field = field.to_sym 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]) + get_data_link(method_ary[field]["method"], options) when :self # passing self - get_data_link(method_ary[field][:method],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],object_hash) + get_data_link(method_ary[field]['method'], options,object_hash) end - - link_to row_data.send(field),url + + link_to row_data.send(field), url else type_trans_or_to_s(row_data.send(field) ) end @@ -45,13 +45,17 @@ module DefaultWidgetHelper end end - def get_data_link(method_entry,object = nil) + def get_data_link(method_entry, options=nil, object = nil) case object - when nil - eval method_entry + when NilClass + eval eval("#{method_entry}(#{options})") + when BSON::ObjectId + object = "'#{object.to_s}'" + eval("#{method_entry}(#{object}, #{options})") + when Hash + eval("#{method_entry}(#{object.merge options})") else - object = "'#{object.to_s}'" if object.class == BSON::ObjectId - eval("#{method_entry}(#{object})" ) + '' end end diff --git a/app/views/default_widget/_typeA.html.erb b/app/views/default_widget/_typeA.html.erb index 20ce3dbd..02dabedb 100644 --- a/app/views/default_widget/_typeA.html.erb +++ b/app/views/default_widget/_typeA.html.erb @@ -11,7 +11,7 @@ <% @data.each do |row_data| %>