Module: Kuhsaft::BrickList
- Included in:
- Brick, ColumnBrick, Page, SliderBrick
- Defined in:
- lib/kuhsaft/brick_list.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#allowed_brick_types ⇒ Object
Return a list of classnames which can be added as childs Return an empty array if you want no constraints.
-
#brick_types ⇒ Object
Returns all possible brick types which can be added as child to this brick list instance.
-
#collect_fulltext ⇒ Object
Return relevant fulltext information for this brick (e.g: it’s name, description etc ).
-
#renders_own_childs? ⇒ Boolean
When true, the brick must implement the rendering of its childs by itself by using the _childs partial When false, the default BrickList rendering is used See _brick_item partial.
- #to_brick_item_id ⇒ Object
- #to_brick_list_id ⇒ Object
-
#user_can_add_childs? ⇒ Boolean
See TwoColumnBrick as an example, which can only have to ColumBricks and the User should not be able to add more.
-
#user_can_delete? ⇒ Boolean
return true if the user should be able to delete the brick through the UI.
-
#user_can_save? ⇒ Boolean
Return true if the user can hit the save button Return false if not See column brick, which has no data on its own except childs, therefore no button is needed.
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 |
# File 'lib/kuhsaft/brick_list.rb', line 4 def self.included(base) def base.acts_as_brick_list self.has_many :bricks, :class_name => 'Kuhsaft::Brick', :dependent => :destroy, :as => :brick_list end end |
Instance Method Details
#allowed_brick_types ⇒ Object
Return a list of classnames which can be added as childs Return an empty array if you want no constraints
74 75 76 |
# File 'lib/kuhsaft/brick_list.rb', line 74 def allowed_brick_types [] end |
#brick_types ⇒ Object
Returns all possible brick types which can be added as child to this brick list instance
81 82 83 |
# File 'lib/kuhsaft/brick_list.rb', line 81 def brick_types @brick_types ||= Kuhsaft::BrickTypeFilter.new(self) end |
#collect_fulltext ⇒ Object
Return relevant fulltext information for this brick (e.g: it’s name, description etc ). It will be stored in the related Page. Implement how you see fit.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/kuhsaft/brick_list.rb', line 59 def collect_fulltext if respond_to?(:bricks) bricks.localized.inject('') do |text, brick| text << brick.collect_fulltext text end else '' end end |
#renders_own_childs? ⇒ Boolean
When true, the brick must implement the rendering of its childs by itself by using the _childs partial When false, the default BrickList rendering is used See _brick_item partial
50 51 52 |
# File 'lib/kuhsaft/brick_list.rb', line 50 def renders_own_childs? false end |
#to_brick_item_id ⇒ Object
10 11 12 |
# File 'lib/kuhsaft/brick_list.rb', line 10 def to_brick_item_id "brick-item-#{id}-#{self.class.to_s.underscore.gsub('/', '_')}" end |
#to_brick_list_id ⇒ Object
14 15 16 |
# File 'lib/kuhsaft/brick_list.rb', line 14 def to_brick_list_id "brick-list-#{id}-#{self.class.to_s.underscore.gsub('/', '_')}" end |
#user_can_add_childs? ⇒ Boolean
See TwoColumnBrick as an example, which can only have to ColumBricks and the User should not be able to add more
22 23 24 |
# File 'lib/kuhsaft/brick_list.rb', line 22 def user_can_add_childs? true end |
#user_can_delete? ⇒ Boolean
return true if the user should be able to delete the brick through the UI. return false if not. See ColumnBrick, which should not be deleted inside the TwoColumnBrick
31 32 33 |
# File 'lib/kuhsaft/brick_list.rb', line 31 def user_can_delete? true end |
#user_can_save? ⇒ Boolean
Return true if the user can hit the save button Return false if not See column brick, which has no data on its own except childs, therefore no button is needed
40 41 42 |
# File 'lib/kuhsaft/brick_list.rb', line 40 def user_can_save? true end |