more button works according to categories
This commit is contained in:
parent
a38cf6304e
commit
3fad5445da
|
@ -40,6 +40,7 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
|
|
||||||
def default_widget
|
def default_widget
|
||||||
@search = params["search_query"].blank? ? false : true
|
@search = params["search_query"].blank? ? false : true
|
||||||
|
|
||||||
if !params[:id].blank? and !params["clicked_field_name"].blank?
|
if !params[:id].blank? and !params["clicked_field_name"].blank?
|
||||||
clicked_field_name = params["clicked_field_name"].to_sym
|
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}})")
|
redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {inner: #{params[:inner] || true}})")
|
||||||
|
@ -69,7 +70,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 || @search
|
if params[:click]
|
||||||
|
@data = get_more_btn_data.page(params[:page_main]).per(@data_limit)
|
||||||
|
|
||||||
|
elsif @paginate || @search
|
||||||
if @search
|
if @search
|
||||||
@data = search_result.page(params[:page_main]).per(@data_limit) rescue []
|
@data = search_result.page(params[:page_main]).per(@data_limit) rescue []
|
||||||
else #regular listing
|
else #regular listing
|
||||||
|
@ -93,6 +97,15 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_more_btn_data
|
||||||
|
filterids = PagePart.find(params[:part_id]).category
|
||||||
|
model = eval(@default_widget["query"])
|
||||||
|
data = model.where(:category_id.in => filterids)
|
||||||
|
data.available_for_lang(I18n.locale).can_display.desc(:is_top, :postdate)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_category_field_name
|
def get_category_field_name
|
||||||
@ori_class_name = @ori_class_name.constantize
|
@ori_class_name = @ori_class_name.constantize
|
||||||
|
|
|
@ -64,6 +64,8 @@ class PagesController < ApplicationController
|
||||||
url = "/#{@item.path}"
|
url = "/#{@item.path}"
|
||||||
options = ''
|
options = ''
|
||||||
options << "#{options.blank? ? '?' : '&'}page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
options << "#{options.blank? ? '?' : '&'}page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
||||||
|
options << "#{options.blank? ? '?' : '&'}click=#{params[:click]}" unless params[:click].blank?
|
||||||
|
options << "#{options.blank? ? '?' : '&'}part_id=#{params[:page_part_id]}" unless params[:page_part_id].blank?
|
||||||
|
|
||||||
if params[:category_id].is_a? Array
|
if params[:category_id].is_a? Array
|
||||||
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('category_id',params[:category_id])}" unless params[:category_id].blank?
|
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('category_id',params[:category_id])}" unless params[:category_id].blank?
|
||||||
|
@ -105,48 +107,48 @@ class PagesController < ApplicationController
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def get_item
|
def get_item
|
||||||
if params[:page_id]
|
# if params[:page_id]
|
||||||
@item = Item.find(params[:page_id])
|
# @item = Item.find(params[:page_id])
|
||||||
elsif params[:same_page_id]
|
# elsif params[:same_page_id]
|
||||||
@item = Item.find(params[:same_page_id])
|
# @item = Item.find(params[:same_page_id])
|
||||||
else
|
# else
|
||||||
category_ids = Array(params[:category_id]) unless params[:category_id].nil?
|
# category_ids = Array(params[:category_id]) unless params[:category_id].nil?
|
||||||
tag_ids = Array(params[:tag_id]) unless params[:tag_id].nil?
|
# tag_ids = Array(params[:tag_id]) unless params[:tag_id].nil?
|
||||||
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
# module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
||||||
|
|
||||||
default_query = { is_published: true, module_app_id: module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget'] }
|
# default_query = { is_published: true, module_app_id: module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget'] }
|
||||||
specific_categories = { :category => category_ids }
|
# specific_categories = { :category => category_ids }
|
||||||
in_categories = { :category.in => category_ids }
|
# in_categories = { :category.in => category_ids }
|
||||||
nil_categories = { :category.in => [nil, []] }
|
# nil_categories = { :category.in => [nil, []] }
|
||||||
specific_tags = { :tag => tag_ids }
|
# specific_tags = { :tag => tag_ids }
|
||||||
in_tags = { :tag.in => tag_ids }
|
# in_tags = { :tag.in => tag_ids }
|
||||||
nil_tags = { :tag.in => [nil, []] }
|
# nil_tags = { :tag.in => [nil, []] }
|
||||||
|
|
||||||
if !category_ids.blank? && !tag_ids.blank?
|
# if !category_ids.blank? && !tag_ids.blank?
|
||||||
@item = Item.where(default_query.merge(specific_categories).merge(specific_tags)).first
|
# @item = Item.where(default_query.merge(specific_categories).merge(specific_tags)).first
|
||||||
@item = Item.where(default_query.merge(specific_categories).merge(in_tags)).first unless @item
|
# @item = Item.where(default_query.merge(specific_categories).merge(in_tags)).first unless @item
|
||||||
@item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first unless @item
|
# @item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first unless @item
|
||||||
@item = Item.where(default_query.merge(specific_tags).merge(in_categories)).first unless @item
|
# @item = Item.where(default_query.merge(specific_tags).merge(in_categories)).first unless @item
|
||||||
@item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first unless @item
|
# @item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first unless @item
|
||||||
@item = Item.where(default_query.merge(in_categories).merge(in_tags)).first unless @item
|
# @item = Item.where(default_query.merge(in_categories).merge(in_tags)).first unless @item
|
||||||
@item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item
|
# @item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item
|
||||||
@item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item
|
# @item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item
|
||||||
elsif !category_ids.blank?
|
# elsif !category_ids.blank?
|
||||||
@item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first
|
# @item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first
|
||||||
@item = Item.where(default_query.merge(specific_categories)).first unless @item
|
# @item = Item.where(default_query.merge(specific_categories)).first unless @item
|
||||||
@item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item
|
# @item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item
|
||||||
@item = Item.where(default_query.merge(in_categories)).first unless @item
|
# @item = Item.where(default_query.merge(in_categories)).first unless @item
|
||||||
elsif !tag_ids.blank?
|
# elsif !tag_ids.blank?
|
||||||
@item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first
|
# @item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first
|
||||||
@item = Item.where(default_query.merge(specific_tags)).first unless @item
|
# @item = Item.where(default_query.merge(specific_tags)).first unless @item
|
||||||
@item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item
|
# @item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item
|
||||||
@item = Item.where(default_query.merge(in_tags)).first unless @item
|
# @item = Item.where(default_query.merge(in_tags)).first unless @item
|
||||||
end
|
# end
|
||||||
@item = Item.find(params[:orig_page]) unless @item || params[:orig_page].blank?
|
# @item = Item.find(params[:orig_page]) unless @item || params[:orig_page].blank?
|
||||||
@item = Item.where(default_query.merge(nil_categories).merge(nil_tags)).first unless @item
|
# @item = Item.where(default_query.merge(nil_categories).merge(nil_tags)).first unless @item
|
||||||
@item = Item.where(default_query).first unless @item
|
# @item = Item.where(default_query).first unless @item
|
||||||
end
|
# end
|
||||||
raise PageError, 'Missing Frontend Page' if @item.nil?
|
# raise PageError, 'Missing Frontend Page' if @item.nil?
|
||||||
|
|
||||||
# if params[:page_id]
|
# if params[:page_id]
|
||||||
# @item = Item.find(params[:page_id])
|
# @item = Item.find(params[:page_id])
|
||||||
|
@ -170,6 +172,15 @@ class PagesController < ApplicationController
|
||||||
# @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]).first unless @item
|
||||||
# end
|
# end
|
||||||
# raise PageError,'Missing Frontend Page' if @item.nil?
|
# raise PageError,'Missing Frontend Page' if @item.nil?
|
||||||
|
if params[:page_id]
|
||||||
|
@item = Item.find(params[:page_id])
|
||||||
|
elsif params[:same_page_id]
|
||||||
|
@item = Item.find(params[:same_page_id])
|
||||||
|
else
|
||||||
|
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
||||||
|
@item = Item.root.children.where(:module_app_id => module_app.id).first
|
||||||
|
end
|
||||||
|
raise PageError,'Missing Frontend Page' if @item.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_frontend_open
|
def check_frontend_open
|
||||||
|
|
|
@ -8,13 +8,13 @@ defaults: &defaults
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
database: test_site
|
database: orbit_site_new
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
database: test_site
|
database: orbit_site_new
|
||||||
|
|
||||||
# set these environment variables on your prod server
|
# set these environment variables on your prod server
|
||||||
production:
|
production:
|
||||||
|
|
|
@ -12,10 +12,11 @@ module DefaultWidgetTagHelper
|
||||||
if param.is_a?(Array) and !param.blank?
|
if param.is_a?(Array) and !param.blank?
|
||||||
params_str << param.collect{|t| "#{index}[]=#{t}"}.join("&")
|
params_str << param.collect{|t| "#{index}[]=#{t}"}.join("&")
|
||||||
params.delete index
|
params.delete index
|
||||||
|
params_str = params_str + "&"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
params_str = params_str + (params_str.eql?("?") ? params.to_param : "&#{params.to_param}" )
|
params_str = params_str + (params_str.eql?("?") ? params.to_param : "&#{params.to_param}" )
|
||||||
|
params_str = params_str + "&click=more_btn&page_part_id=#{@params[:part_id]}"
|
||||||
content_tag :div,:class=> 'more' do
|
content_tag :div,:class=> 'more' do
|
||||||
link_to I18n.t(@more_link[:label_i18n]),[eval("#{@more_link[:path_method]}"),params_str].join()
|
link_to I18n.t(@more_link[:label_i18n]),[eval("#{@more_link[:path_method]}"),params_str].join()
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,12 +19,12 @@ module ParserFrontEnd
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_page_content(page,args={})
|
def parse_page_content(page,args={})
|
||||||
|
|
||||||
args["category_id"] = args["category_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if !args["category_id"].blank? and args["category_id"].is_a?(String)
|
args["category_id"] = args["category_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if !args["category_id"].blank? and args["category_id"].is_a?(String)
|
||||||
args["tag_id"] = args["tag_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if !args["tag_id"].blank? and args["tag_id"].is_a? String
|
args["tag_id"] = args["tag_id"].gsub(/\"|\[|\]/,'').split(",").each(&:strip!) if !args["tag_id"].blank? and args["tag_id"].is_a? String
|
||||||
# tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
|
# tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
|
||||||
# category = params[:category_id].blank? ? page[:category] : params[:category_id]
|
# category = params[:category_id].blank? ? page[:category] : params[:category_id]
|
||||||
body = Nokogiri::HTML(page.content)
|
body = Nokogiri::HTML(page.content)
|
||||||
|
|
||||||
if @edit
|
if @edit
|
||||||
body.css('.page_part').each do |page_part|
|
body.css('.page_part').each do |page_part|
|
||||||
part = PagePart.find(page_part['part_id']) rescue nil
|
part = PagePart.find(page_part['part_id']) rescue nil
|
||||||
|
@ -41,6 +41,7 @@ module ParserFrontEnd
|
||||||
end
|
end
|
||||||
|
|
||||||
body.css('orbit_front').each do |front|
|
body.css('orbit_front').each do |front|
|
||||||
|
|
||||||
if front['value']
|
if front['value']
|
||||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div id='#{front['id']}' class='#{front['class']}'>#{eval(front['value']).to_s}</div>")
|
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div id='#{front['id']}' class='#{front['class']}'>#{eval(front['value']).to_s}</div>")
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,6 +9,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_result
|
def search_result
|
||||||
|
debugger
|
||||||
if params[:search_query] == ""
|
if params[:search_query] == ""
|
||||||
@bulletins = get_bulletins_for_index
|
@bulletins = get_bulletins_for_index
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue