Module: CobblesHelper

Defined in:
app/helpers/cobbles_helper.rb

Defined Under Namespace

Classes: Cobble, Cobbler

Instance Method Summary collapse

Instance Method Details

#cobble_list(name, options = {}, &block) ⇒ Object


91
92
93
94
95
96
97
98
# File 'app/helpers/cobbles_helper.rb', line 91

def cobble_list(name, options = {}, &block)
  id = Cobble.current.id
  list(name, options.deep_merge(content_for: {
                                  settings:   "cobble_#{id}_meta_toolbar".to_sym,
                                  pagination: "cobble_#{id}_meta_toolbar".to_sym,
                                  actions:    "cobble_#{id}_main_toolbar".to_sym
                                }), &block)
end

#cobble_meta_toolbar(&block) ⇒ Object


86
87
88
89
# File 'app/helpers/cobbles_helper.rb', line 86

def cobble_meta_toolbar(&block)
  id = Cobble.current.id
  content_for("cobble_#{id}_meta_toolbar".to_sym, &block)
end

#cobble_toolbar(options = {}, &block) ⇒ Object


81
82
83
84
# File 'app/helpers/cobbles_helper.rb', line 81

def cobble_toolbar(options = {}, &block)
  content_for("cobble_#{Cobble.current.id}_main_toolbar".to_sym, toolbar(options.merge(wrap: false), &block))
  nil
end

#cobble_toolbar_tag(cobble, name) ⇒ Object


100
101
102
103
104
105
# File 'app/helpers/cobbles_helper.rb', line 100

def cobble_toolbar_tag(cobble, name)
  tbid = "cobble_#{cobble.id}_#{name}_toolbar".to_sym
  if content_for?(tbid)
    (:div, content_for(tbid), class: "cobble-toolbar cobble-#{name.to_s.dasherize}-toolbar")
  end
end

#cobbles(options = {}) {|cobbler| ... } ⇒ Object

Cobbles are a simple layout with all cobble in one list. List is sortable and cobbles are hideable/collapseable

Yields:

  • (cobbler)

66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/helpers/cobbles_helper.rb', line 66

def cobbles(options = {}, &_block)
  name = options[:name] || "#{controller_name}-#{action_name}".to_sym
  config = YAML.safe_load(current_user.preference("cobbler.#{name}", {}.to_yaml).value).deep_symbolize_keys
  cobbler = Cobbler.new(self, name, order: config[:order])
  yield cobbler

  # Nothing expected at output
  Ekylibre::View::Addon.render(:cobbler, self, c: cobbler)

  if cobbler.any?
    cobbler.sort!
    render 'cobbles', cobbler: cobbler
  end
end