From d996b91b54cc92512d4fcf0c43af552c1942ac5c Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 15 Jul 2013 17:09:48 +0800 Subject: [PATCH] preview by default widget --- app/controllers/default_widget_controller.rb | 6 +++++- vendor/built_in_modules/announcement/init.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/default_widget_controller.rb b/app/controllers/default_widget_controller.rb index ef3d77bf4..63314529b 100644 --- a/app/controllers/default_widget_controller.rb +++ b/app/controllers/default_widget_controller.rb @@ -40,9 +40,13 @@ class DefaultWidgetController< OrbitWidgetController def default_widget @search = params["search_query"].blank? ? false : true - if !params[:id].blank? + if !params[:id].blank? and !params["clicked_field_name"].blank? clicked_field_name = params["clicked_field_name"].to_sym redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {inner: #{params[:inner] || true}})") + elsif !params[:id].blank? and params["preview"] + clicked_field_name = :title + @preview_pages = @page_part.module_app.widget_fields_link_method.find_all{|t| t[1].has_key?(:preview)}.collect{|t| t[0]} + redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {preview: true,inner: #{params[:inner] || true},clicked_field_name: '#{@preview_pages.first.to_s}'})") else @tag_class = nil @default_widget = @page_part.module_app.get_default_widget diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb index 45f4c18a7..852f71f4c 100644 --- a/vendor/built_in_modules/announcement/init.rb +++ b/vendor/built_in_modules/announcement/init.rb @@ -33,7 +33,7 @@ module Announcement enable ["typeA","typeC"] image :image field :postdate - link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self} + link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self,:preview=>true} link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:bulletin_category,:id]}} link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'more_plus' end