Fix links in default widget
This commit is contained in:
parent
6324233f58
commit
6d1f919bb7
|
@ -76,9 +76,10 @@ class PagesController < ApplicationController
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], tag: params[:tag_id]).any_in(category: [nil,'']).first
|
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], tag: params[:tag_id]).any_in(category: [nil,'']).first
|
||||||
end
|
end
|
||||||
|
@item = Item.find(params[:orig_page]) unless @item || params[:orig_page].blank?
|
||||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
|
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
|
||||||
@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: 'default_widget').first unless @item
|
@item = Item.where(module_app_id: module_app.id, app_frontend_url: 'default_widget').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?
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,21 +3,21 @@ module DefaultWidgetHelper
|
||||||
I18n.t("#{@page_part.module_app.key}.default_widget.#{field}")
|
I18n.t("#{@page_part.module_app.key}.default_widget.#{field}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_field(row_data,field,switch)
|
def link_to_field(row_data,field, options=nil, switch)
|
||||||
method_ary = @page_part.module_app.widget_fields_link_method
|
method_ary = @page_part.module_app.widget_fields_link_method
|
||||||
field = field.to_sym
|
field = field.to_sym
|
||||||
if(method_ary.has_key?(field) and (switch == "true"))
|
if(method_ary.has_key?(field) and (switch == "true"))
|
||||||
url = case method_ary[field][:args]
|
url = case method_ary[field][:args]
|
||||||
when nil # no args
|
when nil # no args
|
||||||
get_data_link(method_ary[field][:method])
|
get_data_link(method_ary[field]["method"], options)
|
||||||
when :self # passing self
|
when :self # passing self
|
||||||
get_data_link(method_ary[field][:method],row_data.id)
|
get_data_link(method_ary[field]['method'], options,row_data.id)
|
||||||
else
|
else
|
||||||
ary = method_ary[field][:args].clone
|
ary = method_ary[field][:args].clone
|
||||||
object_hash = ary.each do |key,val|
|
object_hash = ary.each do |key,val|
|
||||||
ary[key]= type_trans_or_to_s(row_data.send(val[0]).send(val[1]))
|
ary[key]= type_trans_or_to_s(row_data.send(val[0]).send(val[1]))
|
||||||
end
|
end
|
||||||
get_data_link(method_ary[field][:method],object_hash)
|
get_data_link(method_ary[field]['method'], options,object_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
link_to row_data.send(field), url
|
link_to row_data.send(field), url
|
||||||
|
@ -45,13 +45,17 @@ module DefaultWidgetHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_data_link(method_entry,object = nil)
|
def get_data_link(method_entry, options=nil, object = nil)
|
||||||
case object
|
case object
|
||||||
when nil
|
when NilClass
|
||||||
eval method_entry
|
eval eval("#{method_entry}(#{options})")
|
||||||
|
when BSON::ObjectId
|
||||||
|
object = "'#{object.to_s}'"
|
||||||
|
eval("#{method_entry}(#{object}, #{options})")
|
||||||
|
when Hash
|
||||||
|
eval("#{method_entry}(#{object.merge options})")
|
||||||
else
|
else
|
||||||
object = "'#{object.to_s}'" if object.class == BSON::ObjectId
|
''
|
||||||
eval("#{method_entry}(#{object})" )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<% @data.each do |row_data| %>
|
<% @data.each do |row_data| %>
|
||||||
<tr>
|
<tr>
|
||||||
<% @fields.each do |field|%>
|
<% @fields.each do |field|%>
|
||||||
<td><%= content_tag(:span,link_to_field(row_data,field[0],field[2]),:class=>field[1])%></td>
|
<td><%= content_tag(:span,link_to_field(row_data,field[0], orig_page: @page_id.to_s, field[2]),:class=>field[1])%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<% @fields.each do |field|%>
|
<% @fields.each do |field|%>
|
||||||
<%= content_tag(:span,link_to_field(row_data,field[0]),:class=>field[1])%>
|
<%= content_tag(:span,link_to_field(row_data,field[0], orig_page: @page_id.to_s, field[2]),:class=>field[1])%>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<% @data.each do |row_data| %>
|
<% @data.each do |row_data| %>
|
||||||
<%= content_tag(:li) do %>
|
<%= content_tag(:li) do %>
|
||||||
<% @fields.each do |field|%>
|
<% @fields.each do |field|%>
|
||||||
<%= content_tag(:span,link_to_field(row_data,field[0]),:class=>field[1])%>
|
<%= content_tag(:span, link_to_field(row_data,field[0], orig_page: @page_id.to_s, field[2]),:class=>field[1])%>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -20,6 +20,7 @@ module ParserFrontEnd
|
||||||
|
|
||||||
def parse_page_content(page)
|
def parse_page_content(page)
|
||||||
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]
|
||||||
body = Nokogiri::HTML(page.content)
|
body = Nokogiri::HTML(page.content)
|
||||||
body.css('orbit_front').each do |front|
|
body.css('orbit_front').each do |front|
|
||||||
if front['value']
|
if front['value']
|
||||||
|
@ -119,7 +120,7 @@ module ParserFrontEnd
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
options = "&page_id=#{page.id}&category_id=\#{page[:category]}&tag_id=\#{tag}&preview=\#{params[:preview]}&page_main=\#{params[:page_main]}&search_query=\#{params[:search_query]}&name=\#{params[:name]}&item_type=page"
|
options = "&page_id=#{page.id}&category_id=\#{category}&tag_id=\#{tag}&preview=\#{params[:preview]}&page_main=\#{params[:page_main]}&search_query=\#{params[:search_query]}&name=\#{params[:name]}&item_type=page"
|
||||||
ret << "<orbit_front path='#{url + options}'></div>"
|
ret << "<orbit_front path='#{url + options}'></div>"
|
||||||
else
|
else
|
||||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||||
|
@ -136,7 +137,7 @@ module ParserFrontEnd
|
||||||
else
|
else
|
||||||
"/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
|
"/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
|
||||||
end
|
end
|
||||||
options = "&part_id=\#{part.id}&category_id=\#{part[:category]}&tag_id=\#{!part[:tag].blank? ? part[:tag] : tag}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}&item_type=page_part"
|
options = "&part_id=\#{part.id}&category_id=\#{part[:category]}&tag_id=\#{part[:tag]}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}&item_type=page_part"
|
||||||
ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"
|
ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"
|
||||||
|
|
||||||
when 'public_r_tag'
|
when 'public_r_tag'
|
||||||
|
|
Loading…
Reference in New Issue