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 committed 2012-05-07 15:47:14 +08:00
1 parent 8b61314cc4
commit 8a3f0b9bdc
4 files changed
+12 -1

No files matched your search

+2 -1
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
+8
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| %>