fix default failed when cate or tags set to empty
This commit is contained in:
parent
285119a5f3
commit
626b2a7bca
|
@ -14,6 +14,9 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
ori_class_name = @default_widget["query"].split('.')[0]
|
ori_class_name = @default_widget["query"].split('.')[0]
|
||||||
result = nil
|
result = nil
|
||||||
result_objects = nil
|
result_objects = nil
|
||||||
|
params["tag_id"] = [] if params["tag_id"]=="[]"
|
||||||
|
params["category_id"] = [] if params["category_id"]=="[]"
|
||||||
|
|
||||||
if !params["tag_id"].blank?
|
if !params["tag_id"].blank?
|
||||||
@tags = Tag.find(params["tag_id"]) rescue nil
|
@tags = Tag.find(params["tag_id"]) rescue nil
|
||||||
result_ids = nil
|
result_ids = nil
|
||||||
|
@ -32,7 +35,6 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_widget
|
def default_widget
|
||||||
|
|
||||||
if !params[:id].blank?
|
if !params[:id].blank?
|
||||||
redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: #{params[:inner] || true}})")
|
redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: #{params[:inner] || true}})")
|
||||||
else
|
else
|
||||||
|
@ -50,10 +52,10 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
@data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
|
@data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
|
||||||
end
|
end
|
||||||
if @paginate
|
if @paginate
|
||||||
@data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit)
|
@data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
|
||||||
# @data = query_for_default_widget.limit(@data_limit).includes(@widget_image_field)
|
# @data = query_for_default_widget.limit(@data_limit).includes(@widget_image_field)
|
||||||
else
|
else
|
||||||
@data = eval(@default_widget["query"]).includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
|
@data = query_for_default_widget.includes(@widget_image_field).desc(:created_at)
|
||||||
# @data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at)
|
# @data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at)
|
||||||
end
|
end
|
||||||
case params[:type]
|
case params[:type]
|
||||||
|
|
Loading…
Reference in New Issue