Tags & Categories

This commit is contained in:
manson 2014-05-12 16:16:46 +08:00
parent 678327686f
commit 4f25ba67cb
4 changed files with 22 additions and 33 deletions

View File

@ -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

View File

@ -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

View File

@ -36,7 +36,7 @@
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %>
<%= select_category(f, @module_app) %>
</div>
</div>
@ -58,7 +58,6 @@
</div>
<!-- Status Module -->
<%# if show_form_status_field(@bulletin) %>
<div class="tab-pane fade" id="status">
<!-- Status -->
@ -82,21 +81,12 @@
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<!-- Tag -->
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<% @tags.each do |tag| %>
<label class="checkbox inline btn <%= 'active' if @bulletin.tags.include?(tag) %>">
<%= check_box_tag 'bulletin[tags][]', tag.id, @bulletin.tags.include?(tag) %> <%= tag.name %>
</label>
<% end %>
<%= select_tag(f, @module_app, @bulletin) %>
</div>
</div>
</div>
<!-- Images Module -->
<div class="tab-pane fade" id="imageupload">

View File

@ -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