Add sub_menu in r_tags
This commit is contained in:
parent
db1b84e962
commit
a5b13e680f
|
@ -24,6 +24,10 @@ $("#module_app_list select").live('change', function() {
|
|||
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets');
|
||||
});
|
||||
|
||||
$("#tag_list select").live('change', function() {
|
||||
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_r_tag_options');
|
||||
});
|
||||
|
||||
$('.part_kind').live('click', function() {
|
||||
$('.part_kind_partial').hide();
|
||||
$('#part_' + $(this).attr('value')).show();
|
||||
|
|
|
@ -25,7 +25,7 @@ class Admin::PagePartsController < ApplicationController
|
|||
@module_apps = ModuleApp.all(:conditions => {:enable_frontend => true})
|
||||
@module_app = @part.module_app ? @part.module_app : @module_apps[0]
|
||||
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
|
||||
@tag_objects = @r_tag.classify.constantize.all
|
||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||
case @module_app.key
|
||||
when 'bulletin'
|
||||
@categories = BulletinCategory.all
|
||||
|
@ -75,4 +75,12 @@ class Admin::PagePartsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def reload_r_tag_options
|
||||
@r_tag = (ModuleApp.find(params[:id]) rescue nil) || params[:id]
|
||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ class PagePart
|
|||
field :content
|
||||
field :kind
|
||||
field :public_r_tag
|
||||
field :public_r_tag_object_id, :type => BSON::ObjectId, :default => nil
|
||||
field :public_r_tag_object_id, :default => nil
|
||||
field :widget_path
|
||||
|
||||
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<span id='tag_list'>
|
||||
<%= f.select :public_r_tag, LIST[:public_r_tags].collect{|tag| [t(tag), tag]}, :selected => @r_tag %>
|
||||
<%= f.select :public_r_tag, LIST[:public_r_tags].collect{|tag| [t(tag), tag]}, {:selected => @r_tag}, {:rel => admin_page_parts_path} %>
|
||||
</span>
|
||||
|
||||
<span id='name_list'>
|
||||
<%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %>
|
||||
<% if @r_tag.eql?('sub_menu') %>
|
||||
<%= f.select :public_r_tag_object_id, options_for_select([t(:horizontal), t(:vertical)], t(:horizontal)) %>
|
||||
<% else %>
|
||||
<%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %>
|
||||
<% end %>
|
||||
</span>
|
|
@ -0,0 +1,5 @@
|
|||
<% if @r_tag.eql?('sub_menu') %>
|
||||
$('#name_list select').html("<%= j options_for_select(t(:horizontal) => :horizontal, t(:vertical) => :vertical) %>")
|
||||
<% else %>
|
||||
$('#name_list select').html("<%= j options_from_collection_for_select(@tag_objects, :id, :title) %>")
|
||||
<% end %>
|
|
@ -9,6 +9,7 @@ markups:
|
|||
|
||||
public_r_tags:
|
||||
- ad_banner
|
||||
- sub_menu
|
||||
|
||||
page_part_kinds:
|
||||
- text
|
||||
|
|
|
@ -77,6 +77,7 @@ Orbit::Application.routes.draw do
|
|||
resources :page_parts do
|
||||
member do
|
||||
get 'reload_widgets'
|
||||
get 'reload_r_tag_options'
|
||||
end
|
||||
end
|
||||
resources :purchases do
|
||||
|
|
|
@ -106,4 +106,20 @@ module ParserCommon
|
|||
page_menu.swap(fragment)
|
||||
end
|
||||
|
||||
# sub_menus
|
||||
def parse_sub_menus(body = nil, page = nil, id = nil)
|
||||
body.css('sub_menu').each do |sub_menu|
|
||||
res = ''
|
||||
res << "<ul>"
|
||||
page.children.each do |child|
|
||||
res << "<li>"
|
||||
res << "<a href='#{child.full_name}'>#{child.i18n_variable[I18n.locale]}</a>"
|
||||
res << "</li>"
|
||||
end
|
||||
res << "</ul>"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
||||
sub_menu.swap(fragment)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Reference in New Issue