From fdf4cfad2de9be3745b35f068de2333001549875 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 28 Feb 2012 14:08:57 +0800 Subject: [PATCH] Add category for announcement widget --- app/controllers/admin/page_parts_controller.rb | 1 + app/views/admin/page_parts/_module_widget.html.erb | 5 +++++ app/views/admin/pages/_form.html.erb | 4 ++-- lib/parsers/parser_back_end.rb | 6 +++++- lib/parsers/parser_front_end.rb | 6 +++++- .../panel/announcement/widget/bulletins_controller.rb | 6 +++++- 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index 1c6b9c56..a6e3314f 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -26,6 +26,7 @@ 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 end def create diff --git a/app/views/admin/page_parts/_module_widget.html.erb b/app/views/admin/page_parts/_module_widget.html.erb index 532cff53..fd481172 100644 --- a/app/views/admin/page_parts/_module_widget.html.erb +++ b/app/views/admin/page_parts/_module_widget.html.erb @@ -4,4 +4,9 @@ <%= f.select :widget_path, @module_app.widgets.collect{|widget| [widget.humanize, widget]}, :selected => @part.widget_path %> + + + + + <%= select 'page_part', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @part[:category] %> \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index a45dbbd2..9722413c 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -26,8 +26,8 @@

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

<%= f.label :is_published, "#{t('admin.is_published')} ?" %> diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index c2de9804..4b8fbd27 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -111,7 +111,11 @@ module ParserBackEnd when 'text' ret << part.i18n_variable[I18n.locale] rescue '' when 'module_widget' - ret << "

" + if part[:category] + ret << "
" + else + ret << "
" + end when 'public_r_tag' ret << "" else diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 453053e5..008a265c 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -134,7 +134,11 @@ module ParserFrontEnd when 'text' ret << part.i18n_variable[I18n.locale] rescue '' when 'module_widget' - ret << "
" + if part[:category] + ret << "
" + else + ret << "
" + end when 'public_r_tag' ret << "" else diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb index cdaa07c5..6695156a 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb @@ -13,7 +13,11 @@ class Panel::Announcement::Widget::BulletinsController < ObitWidgetController # deadline # @bulletin_categorys = BulletinCategory.first; # @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9) - @bulletins = Bulletin.widget_datas.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) + end get_categorys