From 29b8fec89aa41c8849ba161ed1df9d1183093117 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 5 Feb 2013 16:34:22 +0800 Subject: [PATCH] Temporary fix: show for default widget - the task migrate:recreate_page_parts must be run - "create_parts" in page.rb must be unprotected --- app/controllers/default_widget_controller.rb | 49 +++++++++++--------- app/controllers/pages_controller.rb | 9 ++-- lib/parsers/parser_front_end.rb | 1 + 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/app/controllers/default_widget_controller.rb b/app/controllers/default_widget_controller.rb index 956a2a53..3f8c8759 100644 --- a/app/controllers/default_widget_controller.rb +++ b/app/controllers/default_widget_controller.rb @@ -11,31 +11,34 @@ class DefaultWidgetController< OrbitWidgetController end def default_widget - @tag_class = nil + if !params[:id].blank? + redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: true})") + else + @tag_class = nil - @default_widget = @page_part.module_app.get_default_widget - @widget_image_field = @default_widget["image"] || @default_widget[:image] - data_limit = case @page_part - when Page - @fields = @page_part.frontend_field - @page_part.frontend_data_count.is_a?(Fixnum) ? @page_part.frontend_data_count : (@page_part.frontend_data_count.to_i rescue 3) - when PagePart - @fields = @page_part.widget_field - @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3) + @default_widget = @page_part.module_app.get_default_widget + @widget_image_field = @default_widget["image"] || @default_widget[:image] + data_limit = case @page_part + when Page + @fields = @page_part.frontend_field + @page_part.frontend_data_count.is_a?(Fixnum) ? @page_part.frontend_data_count : (@page_part.frontend_data_count.to_i rescue 3) + when PagePart + @fields = @page_part.widget_field + @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3) + end + @data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field).desc(:created_at) + case params[:type] + when "typeA" + @tag_class = 'default_widget_typeA' + render "typeA" + when /typeB_/ + @tag_class = "default_widget_#{params[:type]}" + render "typeB" + when "typeC" + @tag_class = 'default_widget_typeC' + render "typeC" + end end - @data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field).desc(:created_at) - case params[:type] - when "typeA" - @tag_class = 'default_widget_typeA' - render "typeA" - when /typeB_/ - @tag_class = "default_widget_#{params[:type]}" - render "typeB" - when "typeC" - @tag_class = 'default_widget_typeC' - render "typeC" - end - end end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 57e6a5ff..4d84d9c9 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -69,12 +69,13 @@ class PagesController < ApplicationController @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]}) @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item elsif !params[:category_id].blank? - @item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],category: params[:category_id]).any_in(tag: [nil,'']).first + @item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], category: 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: params[:tag_id]).any_in(category: [nil,'']).first + @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.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: 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 raise PageError,'Missing Frontend Page' if @item.nil? end diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 98721b5f..e706e5cc 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -116,6 +116,7 @@ module ParserFrontEnd if (content["main"] == "true" && !page.module_app.nil?) if page.app_frontend_url == 'default_widget' url = "/panel/orbit_app/widget/#{page.frontend_style}?inner=true" + url << "&id=\#{params[:id] if params[:id] && !params[:id].eql?(page.id.to_s)}" else url = "/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}\#{(\"/\" + params[:id]) if params[:id] && !params[:id].eql?(page.id.to_s)}\#{(\"/\" + params[:controller_action]) if params[:controller_action] && params[:id]}?inner=true" end