Add category for announcement widget

This commit is contained in:
Christophe Vilayphiou 2012-02-28 14:08:57 +08:00
parent 7f9a7edc98
commit fdf4cfad2d
6 changed files with 23 additions and 5 deletions

View File

@ -26,6 +26,7 @@ class Admin::PagePartsController < ApplicationController
@module_app = @part.module_app ? @part.module_app : @module_apps[0] @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 @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
@categories = BulletinCategory.all
end end
def create def create

View File

@ -5,3 +5,8 @@
<span id='widget_list'> <span id='widget_list'>
<%= f.select :widget_path, @module_app.widgets.collect{|widget| [widget.humanize, widget]}, :selected => @part.widget_path %> <%= f.select :widget_path, @module_app.widgets.collect{|widget| [widget.humanize, widget]}, :selected => @part.widget_path %>
</span> </span>
<span id="widget_category">
<%= select 'page_part', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @part[:category] %>
</span>

View File

@ -26,8 +26,8 @@
<p> <p>
<%= t('admin.module_app') %> <%= t('admin.module_app') %>
<%= render :partial => "admin/module_apps/app_selector", :locals => { :f => f } %> <%= render :partial => "admin/module_apps/app_selector", :locals => { :f => f } %>
<span id="app_page_url"><%= select('page','app_frontend_url', @app_frontend_urls ) rescue ''%> </span> <span id="app_page_url"><%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%> </span>
<span id="app_page_category"><%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]} ) rescue ''%> </span> <span id="app_page_category"><%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category] ) rescue ''%> </span>
</p> </p>
<p> <p>
<%= f.label :is_published, "#{t('admin.is_published')} ?" %> <%= f.label :is_published, "#{t('admin.is_published')} ?" %>

View File

@ -111,7 +111,11 @@ module ParserBackEnd
when 'text' when 'text'
ret << part.i18n_variable[I18n.locale] rescue '' ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget' when 'module_widget'
if part[:category]
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?category_id=#{part[:category]}'></div>"
else
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}'></div>" ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}'></div>"
end
when 'public_r_tag' when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>" ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
else else

View File

@ -134,7 +134,11 @@ module ParserFrontEnd
when 'text' when 'text'
ret << part.i18n_variable[I18n.locale] rescue '' ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget' when 'module_widget'
if part[:category]
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&category_id=#{part[:category]}'></div>"
else
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true'></div>" ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true'></div>"
end
when 'public_r_tag' when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>" ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
else else

View File

@ -13,7 +13,11 @@ class Panel::Announcement::Widget::BulletinsController < ObitWidgetController
# deadline # deadline
# @bulletin_categorys = BulletinCategory.first; # @bulletin_categorys = BulletinCategory.first;
# @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9) # @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9)
if params[:category_id]
@bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9)
else
@bulletins = Bulletin.widget_datas.limit(9) @bulletins = Bulletin.widget_datas.limit(9)
end
get_categorys get_categorys