Remove useless code not removed in merge

Fix argument bug in link_to_field
This commit is contained in:
chris 2013-02-19 20:42:46 +08:00
parent d19ba7b1c6
commit 39c6660c67
5 changed files with 5 additions and 30 deletions

View File

@ -10,24 +10,6 @@ class DefaultWidgetController< OrbitWidgetController
@page_part.module_app.enable_frontend?
end
def query_for_default_widget
ori_class_name = @default_widget["query"].split('.')[0]
result = nil
if !params["tag_id"].blank?
@tag = Tag.find(params["tag_id"]) rescue nil
if params["category_id"].blank?
result = @tag.send(ori_class_name.downcase.pluralize).desc(:created_at)
else
result = @tag.send(ori_class_name.downcase.pluralize).where(get_category_field_name(ori_class_name) => params['category_id']).desc(:created_at)
end
elsif params["category_id"].blank?
result = eval(@default_widget["query"]).desc(:created_at)
else
result = eval("#{ori_class_name}.where(get_category_field_name(ori_class_name) => params['category_id'])").desc(:created_at)
end
result.available_for_lang(I18n.locale).can_display.desc(:created_at)
end
def default_widget
if !params[:id].blank?
redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: #{params[:inner] || true}})")
@ -64,12 +46,5 @@ class DefaultWidgetController< OrbitWidgetController
end
end
end
def get_category_field_name(ori_class_name)
ori_class_name = ori_class_name.constantize
ori_class_name.fields.each_key do |key|
return key if key.include?('category_id')
end
nil
end
end

View File

@ -3,7 +3,7 @@ module DefaultWidgetHelper
I18n.t("#{@page_part.module_app.key}.default_widget.#{field}")
end
def link_to_field(row_data,field, options=nil, switch)
def link_to_field(row_data,field, switch, options=nil)
method_ary = @page_part.module_app.widget_fields_link_method
field = field.to_sym
if(method_ary.has_key?(field) and (switch == "true"))

View File

@ -11,7 +11,7 @@
<% @data.each do |row_data| %>
<tr>
<% @fields.each do |field|%>
<td><%= content_tag(:span,link_to_field(row_data,field[0], orig_page: @page_id.to_s, field[2]),:class=>field[1])%></td>
<td><%= content_tag(:span,link_to_field(row_data,field[0], field[2], {orig_page: @page_id.to_s}),:class=>field[1])%></td>
<% end %>
</tr>
<% end %>

View File

@ -7,7 +7,7 @@
</div>
<div class="wrap">
<% @fields.each do |field|%>
<%= content_tag(:span,link_to_field(row_data,field[0], orig_page: @page_id.to_s, field[2]),:class=>field[1])%>
<%= content_tag(:span,link_to_field(row_data,field[0], field[2], {orig_page: @page_id.to_s}),:class=>field[1])%>
<% end %>
</div>
<% end %>

View File

@ -6,7 +6,7 @@
<% @data.each do |row_data| %>
<%= content_tag(:li) do %>
<% @fields.each do |field|%>
<%= content_tag(:span, link_to_field(row_data,field[0], orig_page: @page_id.to_s, field[2]),:class=>field[1])%>
<%= content_tag(:span, link_to_field(row_data,field[0], field[2], {orig_page: @page_id.to_s}),:class=>field[1])%>
<% end %>
<% end %>
<% end %>