Add position ordering and hiding page for i18n
This commit is contained in:
1 parent
f190ce18ee
commit
ce1fecaf93
5 files changed
+35
-8
No files matched your search
@@ -7,6 +7,7 @@ class Item
|
||||
field :full_name, :index => true
|
||||
field :position, :type => Integer
|
||||
field :is_published, :type => Boolean, :default => false, :index => true
|
||||
field :enabled_for, :type => Array, :default => nil
|
||||
|
||||
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
|
||||
validates :name, :exclusion => { :in => LIST[:forbidden_item_names] }
|
||||
@@ -35,6 +36,21 @@ class Item
|
||||
urls = ancestors.map{ |a| a.name } << self.name
|
||||
urls.join("/")
|
||||
end
|
||||
|
||||
def ordered_children
|
||||
self.children.asc(:position)
|
||||
end
|
||||
|
||||
def ordered_and_visible_children
|
||||
objects = ordered_children
|
||||
a = []
|
||||
if objects
|
||||
objects.each do |object|
|
||||
a << object if object.enabled_for.nil? ? true : object.enabled_for.include?(I18n.locale.to_s)
|
||||
end
|
||||
end
|
||||
a
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
||||
Reference in new issue
Block a user