Add menu_enabled_for: the page can be shown even if there's no link in the menu

This commit is contained in:
Christophe Vilayphiou 2012-05-07 15:47:14 +08:00
parent 8b61314cc4
commit 8a3f0b9bdc
4 changed files with 12 additions and 1 deletions

View File

@ -8,6 +8,7 @@ class Item
field :position, :type => Integer
field :is_published, :type => Boolean, :default => false, :index => true
field :enabled_for, :type => Array, :default => nil
field :menu_enabled_for, :type => Array, :default => nil
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
validates :name, :exclusion => { :in => LIST[:forbidden_item_names] }
@ -46,7 +47,7 @@ class Item
a = []
if objects
objects.each do |object|
a << object if object.enabled_for.nil? ? true : object.enabled_for.include?(I18n.locale.to_s)
a << object if object.menu_enabled_for.nil? ? true : object.menu_enabled_for.include?(I18n.locale.to_s)
end
end
a

View File

@ -33,6 +33,14 @@
<%= f.label :is_published, "#{t('admin.is_published')} ?" %>
<%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No
</p>
<p>
<%= f.label :menu_enabled_for, "#{t('admin.menu_enabled_for')}:" %>
<% @site_valid_locales.each do |valid_locale| %>
<%= check_box_tag 'page[menu_enabled_for][]', valid_locale, (@item.menu_enabled_for.nil? ? true : @item.menu_enabled_for.include?(valid_locale)) %>
<%= I18nVariable.from_locale(valid_locale) %>
<% end %>
<%= hidden_field_tag 'page[menu_enabled_for][]', '' %>
</p>
<p>
<%= f.label :enabled_for, "#{t('admin.enabled_for')}:" %>
<% @site_valid_locales.each do |valid_locale| %>

View File

@ -163,6 +163,7 @@ en:
list_infos: User information list
list_roles: User roles list
member: Member
menu_enabled_for: Menu enabled for
module:
authorization: Module Authorization
move_down: Move down

View File

@ -160,6 +160,7 @@ zh_tw:
list_infos: 用戶資料列表
list_roles: 用戶身份列表
member: 會員
menu_enabled_for: 選單啟用
module:
authorization: 模組授權
move_down: 往下移