From 4f25ba67cb7c0b9f7d0dbcde9448b0020b13427a Mon Sep 17 00:00:00 2001 From: manson Date: Mon, 12 May 2014 16:16:46 +0800 Subject: [PATCH] Tags & Categories --- .../admin/announcements_controller.rb | 6 ++-- app/models/bulletin.rb | 5 ---- app/views/admin/announcements/_form.html.erb | 14 ++------- lib/announcement/engine.rb | 30 +++++++++++-------- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index e8c2954..e5e3a96 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -10,7 +10,7 @@ class Admin::AnnouncementsController < OrbitAdminController def index @tags = @module_app.tags - @categories = @module_app.categories + @categories = @module_app.categories.enabled @filter_fields = { :status=>[{:title=>"is_top",:id=>"is_top"},{:title=>"is_hot",:id=>"is_hot"},{:title=>"is_hidden",:id=>"is_hidden"}], @@ -58,7 +58,7 @@ class Admin::AnnouncementsController < OrbitAdminController def new @tags =@module_app.tags - @categories = @module_app.categories + @categories = @module_app.categories.enabled @statuses = [] @bulletin = Bulletin.new end @@ -73,7 +73,7 @@ class Admin::AnnouncementsController < OrbitAdminController def edit @tags =@module_app.tags - @categories = @module_app.categories + @categories = @module_app.categories.enabled @statuses = [] end diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index 4864bde..aeae020 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -38,11 +38,6 @@ class Bulletin self.update_user_id = user.id end - def self.with_status(status) - status = [status].flatten - self.any_of(status.map{|s| {s.to_sym=>true}}) - end - def self.can_display() self.any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}) end diff --git a/app/views/admin/announcements/_form.html.erb b/app/views/admin/announcements/_form.html.erb index 70c27bc..738fa1d 100644 --- a/app/views/admin/announcements/_form.html.erb +++ b/app/views/admin/announcements/_form.html.erb @@ -36,7 +36,7 @@
- <%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %> + <%= select_category(f, @module_app) %>
@@ -58,7 +58,6 @@ - <%# if show_form_status_field(@bulletin) %>
@@ -82,19 +81,10 @@
- -
-
- <% @tags.each do |tag| %> - - <% end %> -
+ <%= select_tag(f, @module_app, @bulletin) %>
-
diff --git a/lib/announcement/engine.rb b/lib/announcement/engine.rb index f902bc0..b93b6fe 100644 --- a/lib/announcement/engine.rb +++ b/lib/announcement/engine.rb @@ -12,29 +12,33 @@ module Announcement side_bar do head_label_i18n 'announcement.announcement', icon_class: "icons-megaphone" available_for [:admin,:manager,:sub_manager] - active_for_controllers ({:private=>['announcements']}) + active_for_controllers (['admin/announcements']) head_link_path "admin_announcements_path" context_link 'announcement.all_articles', :link_path=>"admin_announcements_path" , :priority=>1, - :active_for_action=>{'admin/announcement'=>'index'}, + :active_for_action=>{'admin/announcements'=>'index'}, :available_for => [:all] context_link 'announcement.add_new', :link_path=>"new_admin_announcement_path" , :priority=>2, - :active_for_action=>{'admin/announcement'=>'new'}, + :active_for_action=>{'admin/announcements'=>'new'}, :available_for => [:sub_manager] - # context_link 'announcement.categories', - # :link_path=>"admin_announcement_path(get_module_app)" , - # :priority=>3, - # :active_for_category => 'Announcement', - # :available_for => [:manager] - # context_link 'tags', - # :link_path=>"admin_announcement_path(module_app_id: get_module_app)" , - # :priority=>4, - # :active_for_tag => 'Announcement', - # :available_for => [:manager] + context_link 'announcement.categories', + :link_path=>"admin_module_app_categories_path" , + :link_arg=>{:module_app_id=>get_module_app.id}, + :priority=>3, + :active_for_action=>{'admin/announcements'=>'categories'}, + :active_for_category => 'Announcement', + :available_for => [:manager] + context_link 'tags', + :link_path=>"admin_module_app_tags_path" , + :link_arg=>{:module_app_id=>get_module_app.id}, + :priority=>4, + :active_for_action=>{'admin/announcements'=>'tags'}, + :active_for_tag => 'Announcement', + :available_for => [:manager] end end