Add categories for all the widgets

This commit is contained in:
Christophe Vilayphiou 2012-02-28 22:00:05 +08:00
parent 6a30b0a1e4
commit 18617850e5
4 changed files with 16 additions and 3 deletions

View File

@ -26,7 +26,12 @@ class Admin::PagePartsController < ApplicationController
@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
@categories = BulletinCategory.all
case @module_app.key
when 'bulletin'
@categories = BulletinCategory.all
when 'web_resource'
@categories = WebLinkCategory.all
end
end
def create
@ -59,6 +64,12 @@ class Admin::PagePartsController < ApplicationController
def reload_widgets
@module_app = ModuleApp.find(params[:id])
case @module_app.key
when 'announcement'
@categories = BulletinCategory.all
when 'web_resource'
@categories = WebLinkCategory.all
end
respond_to do |format|
format.js {}
end

View File

@ -8,5 +8,5 @@
<span id="widget_category">
<%= select 'page_part', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @part[:category] %>
<%= render 'widget_categories' %>
</span>

View File

@ -0,0 +1 @@
<%= select 'page_part', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => (@part ? @part[:category] : nil) if @categories && @categories.size > 0 %>

View File

@ -1 +1,2 @@
$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|widget| [widget.humanize, widget]}) %>")
$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|widget| [widget.humanize, widget]}) %>")
$('#widget_category').html("<%= j render 'widget_categories' %>")