Module: Kuhsaft::BrickList

Included in:
Brick, ColumnBrick, Page, SliderBrick
Defined in:
lib/kuhsaft/brick_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/kuhsaft/brick_list.rb', line 3

def self.included(base)
  def base.acts_as_brick_list
    has_many :bricks,
             class_name: 'Kuhsaft::Brick',
             dependent: :destroy,
             as: :brick_list
  end
end

Instance Method Details

#allowed_brick_typesObject

Return a list of classnames which can be added as childs Return an empty array if you want no constraints



72
73
74
# File 'lib/kuhsaft/brick_list.rb', line 72

def allowed_brick_types
  []
end

#brick_typesObject

Returns all possible brick types which can be added as child to this brick list instance



79
80
81
# File 'lib/kuhsaft/brick_list.rb', line 79

def brick_types
  @brick_types ||= Kuhsaft::BrickTypeFilter.new(self)
end

#collect_fulltextObject

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.



61
62
63
64
65
66
# File 'lib/kuhsaft/brick_list.rb', line 61

def collect_fulltext
  return '' unless respond_to?(:bricks)
  bricks.localized.reduce('') do |text, brick|
    text << brick.collect_fulltext
  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

Returns:

  • (Boolean)


52
53
54
# File 'lib/kuhsaft/brick_list.rb', line 52

def renders_own_childs?
  false
end

#to_brick_item_idObject



12
13
14
# File 'lib/kuhsaft/brick_list.rb', line 12

def to_brick_item_id
  "brick-item-#{id}-#{self.class.to_s.underscore.gsub('/', '_')}"
end

#to_brick_list_idObject



16
17
18
# File 'lib/kuhsaft/brick_list.rb', line 16

def to_brick_list_id
  "brick-list-#{id}-#{self.class.to_s.underscore.gsub('/', '_')}"
end

#uploader?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/kuhsaft/brick_list.rb', line 83

def uploader?
  self.class.ancestors.include? CarrierWave::Mount::Extension
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

Returns:

  • (Boolean)


24
25
26
# File 'lib/kuhsaft/brick_list.rb', line 24

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

Returns:

  • (Boolean)


33
34
35
# File 'lib/kuhsaft/brick_list.rb', line 33

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

Returns:

  • (Boolean)


42
43
44
# File 'lib/kuhsaft/brick_list.rb', line 42

def user_can_save?
  true
end