From aea15fa622e30839da05b0b34ded27f45f7b1386 Mon Sep 17 00:00:00 2001 From: "Matt K. Fu" Date: Tue, 16 Jul 2013 17:41:22 +0800 Subject: [PATCH] add class to default widget if row data is hot or top --- app/helpers/default_widget_helper.rb | 7 +++++++ app/views/default_widget/_typeA.html.erb | 2 +- app/views/default_widget/_typeB.html.erb | 2 +- app/views/default_widget/_typeC.html.erb | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/helpers/default_widget_helper.rb b/app/helpers/default_widget_helper.rb index 32fccb209..3536525ca 100644 --- a/app/helpers/default_widget_helper.rb +++ b/app/helpers/default_widget_helper.rb @@ -3,6 +3,13 @@ module DefaultWidgetHelper I18n.t("#{@page_part.module_app.key}.default_widget.#{field}") end + def get_top_hot_class(row_data) + class_attr = [] + class_attr << 'data_is_hot' if( row_data.is_hot? rescue false ) + class_attr << 'data_is_top' if( row_data.is_top? rescue false) + return class_attr.join(" ") + end + def link_to_field(row_data,field, switch, options=nil) method_ary = @page_part.module_app.widget_fields_link_method field = field.to_sym diff --git a/app/views/default_widget/_typeA.html.erb b/app/views/default_widget/_typeA.html.erb index d419554d4..910d23b6a 100644 --- a/app/views/default_widget/_typeA.html.erb +++ b/app/views/default_widget/_typeA.html.erb @@ -9,7 +9,7 @@ <% @data.each do |row_data| %> - + <% @frontend_field_names.each_with_index do |field,index|%> <%= content_tag(:td,content_tag(:span,link_to_field(row_data,field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s}),:class=>@frontend_classes[index]))unless field.blank?%> <% end %> diff --git a/app/views/default_widget/_typeB.html.erb b/app/views/default_widget/_typeB.html.erb index e5808c3a8..4a394a116 100644 --- a/app/views/default_widget/_typeB.html.erb +++ b/app/views/default_widget/_typeB.html.erb @@ -1,7 +1,7 @@ <%= content_tag :div,:class=>@tag_class do%>