Merge branch 'ntu' of https://github.com/Rulingcom/orbit into ntu
* 'ntu' of https://github.com/Rulingcom/orbit: fixing default widget error when needs image make default widget works without init Fix order in structure Fix old tags
This commit is contained in:
commit
a0868a05ac
|
@ -46,12 +46,16 @@ class Admin::TagsController < OrbitBackendController
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def set_module_app
|
|
||||||
@module_app ||= ModuleApp.first(:conditions => {:key => @app_title.underscore}) rescue nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_tags
|
def get_tags
|
||||||
@tags = (@module_app ? @module_app.tags : Tag.all)
|
@tags = (@module_app ? @module_app.tags : Tag.all)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def setup_vars
|
||||||
|
@app_key = request.env['HTTP_REFERER'].split('/')[4]
|
||||||
|
if @app_key
|
||||||
|
@app_key.gsub!(/[?].*/, '')
|
||||||
|
@module_app = ModuleApp.first(conditions: {:key => @app_key})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
class DefaultWidgetController< OrbitWidgetController
|
||||||
|
|
||||||
|
def front_end_available(var)
|
||||||
|
@page_part = PagePart.find params[:part_id]
|
||||||
|
@page_part.module_app.enable_frontend?
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_widget
|
||||||
|
@tag_class = nil
|
||||||
|
|
||||||
|
@default_widget = @page_part.module_app.get_default_widget
|
||||||
|
@widget_image_field = @default_widget[:image]
|
||||||
|
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 = eval(@default_widget[:query]).limit(data_limit).includes(@widget_image_field)
|
||||||
|
@fields = @page_part.widget_field
|
||||||
|
|
||||||
|
# binding.pry
|
||||||
|
|
||||||
|
case params[:type]
|
||||||
|
when "typeA"
|
||||||
|
@tag_class = 'defulat_widget_typeA'
|
||||||
|
render "typeA"
|
||||||
|
when /typeB_/
|
||||||
|
@tag_class = "defulat_widget_#{params[:type]}"
|
||||||
|
render "typeB"
|
||||||
|
when "typeC"
|
||||||
|
@tag_class = 'defulat_widget_typeC'
|
||||||
|
render "typeC"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# {"inner"=>"true",
|
||||||
|
# "category_id"=>"false",
|
||||||
|
# "tag_id"=>"",
|
||||||
|
# "page"=>"",
|
||||||
|
# "search_query"=>"",
|
||||||
|
# "part_title"=>"",
|
||||||
|
# "part_id"=>"50ac426f83e75219d20000a7",
|
||||||
|
# "controller"=>"default_widget",
|
||||||
|
# "action"=>"default_widget",
|
||||||
|
# "type"=>"typeA"}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -47,10 +47,10 @@ class Item
|
||||||
new_parent = Item.find(new_parent)
|
new_parent = Item.find(new_parent)
|
||||||
current_position_sibling = find_by_parent_and_position(new_parent, position.to_i)
|
current_position_sibling = find_by_parent_and_position(new_parent, position.to_i)
|
||||||
if current_position_sibling
|
if current_position_sibling
|
||||||
current_position_sibling.at_bottom? ? move_below(current_position_sibling) : move_above(current_position_sibling)
|
move_above(current_position_sibling)
|
||||||
elsif self.parent != new_parent
|
elsif self.parent != new_parent
|
||||||
self.parent = new_parent
|
self.parent = new_parent
|
||||||
save!
|
save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,6 +30,13 @@ class ModuleApp
|
||||||
|
|
||||||
before_save :set_key
|
before_save :set_key
|
||||||
|
|
||||||
|
#>>>>>>>>>>>>> remove after app config applied
|
||||||
|
def get_default_widget
|
||||||
|
{:query=>'Bulletin.all',:image=> 'image'}
|
||||||
|
end
|
||||||
|
#<<<<<<<<<<<<@@
|
||||||
|
|
||||||
|
|
||||||
def is_manager?(user)
|
def is_manager?(user)
|
||||||
managing_users.include?(user)
|
managing_users.include?(user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,14 +24,12 @@ class Page < Item
|
||||||
has_many :page_metas, :autosave => true, :dependent => :destroy
|
has_many :page_metas, :autosave => true, :dependent => :destroy
|
||||||
accepts_nested_attributes_for :page_parts, :allow_destroy => true
|
accepts_nested_attributes_for :page_parts, :allow_destroy => true
|
||||||
|
|
||||||
before_save :delete_empty_frontend_field
|
|
||||||
before_save :create_parts, if: Proc.new { |page| page.new_record? || page.design_id_changed? }
|
before_save :create_parts, if: Proc.new { |page| page.new_record? || page.design_id_changed? }
|
||||||
after_save :generate_html
|
before_save :delete_empty_frontend_field, :generate_html
|
||||||
|
|
||||||
# protected
|
protected
|
||||||
|
|
||||||
def create_parts
|
def create_parts
|
||||||
|
|
||||||
page_design = self.design
|
page_design = self.design
|
||||||
parent = self.parent
|
parent = self.parent
|
||||||
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent
|
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent
|
||||||
|
@ -73,10 +71,7 @@ class Page < Item
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_html
|
def generate_html
|
||||||
Page.without_callback(:save, :after, :generate_html) do
|
self.content_translations = parse_page_noko(self, Site.first)
|
||||||
self.content_translations = parse_page_noko(self, Site.first)
|
|
||||||
self.save
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<%= content_tag :div,:class=>@tag_class do%>
|
||||||
|
<div class="defulat_widget_type_A">
|
||||||
|
<table class="defulat_widget_tb" border="0" cellpadding="0" cellspacing="0" >
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<% @fields.each do |field|%>
|
||||||
|
<th><%= content_tag(:span,field[0],:class=>field[1])%></th>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<% @data.each do |row_data| %>
|
||||||
|
<tr>
|
||||||
|
<% @fields.each do |field|%>
|
||||||
|
<td><%= content_tag(:span,row_data.send(field[0]),:class=>field[1])%></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<%= content_tag :div,:class=>@tag_class do%>
|
||||||
|
<ul class="defulat_widget_list">
|
||||||
|
|
||||||
|
<% @data.each do |row_data| %>
|
||||||
|
<%= content_tag(:li) do %>
|
||||||
|
<div class="img app-pic">
|
||||||
|
<%= image_tag row_data.send(@widget_image_field)%>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="wrap">
|
||||||
|
<% @fields.each do |field|%>
|
||||||
|
<%= content_tag(:span,row_data.send(field[0]),:class=>field[1])%>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<div class="more">more</div>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<%= content_tag :div,:class=>@tag_class do%>
|
||||||
|
<div class="img app-pic">
|
||||||
|
<%= image_tag @data.first.send(@widget_image_field)%>
|
||||||
|
</div>
|
||||||
|
<ul class="defulat_widget_list">
|
||||||
|
<% @data.each do |row_data| %>
|
||||||
|
<%= content_tag(:li) do %>
|
||||||
|
<% @fields.each do |field|%>
|
||||||
|
<%= content_tag(:span,row_data.send(field[0]),:class=>field[1])%>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<div class="more">more</div>
|
||||||
|
<% end %>
|
|
@ -241,7 +241,8 @@ Orbit::Application.routes.draw do
|
||||||
match 'show_sitemap' => 'front#show_sitemap', :as => :front_show_sitemap
|
match 'show_sitemap' => 'front#show_sitemap', :as => :front_show_sitemap
|
||||||
end
|
end
|
||||||
|
|
||||||
|
match '/panel/orbit_app/widget/:type' => 'default_widget#default_widget'
|
||||||
|
|
||||||
match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request|
|
match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request|
|
||||||
!request.query_string.include?("inner=true")
|
!request.query_string.include?("inner=true")
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,4 +350,26 @@ namespace :migrate do
|
||||||
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/gallery/gallery.json").read).save
|
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/gallery/gallery.json").read).save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
task :make_default_widget_work_config => :environment do
|
||||||
|
a = ModuleApp.where(:key=>'announcement').first
|
||||||
|
a.widgets[:default_widget] = ['typeA','typeC','typeB_style2','typeB_style3','typeB_style4']
|
||||||
|
a.widget_fields = ["title","bulletin_category","postdate"]
|
||||||
|
a.save
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
task :reorder_items => :environment do
|
||||||
|
reorder_children(Item.root)
|
||||||
|
end
|
||||||
|
|
||||||
|
def reorder_children(parent)
|
||||||
|
parent.children.each_with_index do |child, i|
|
||||||
|
child.position = i
|
||||||
|
child.save
|
||||||
|
reorder_children(child) if child.children
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue