27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/helpers/quadro/widget_helper.rb', line 27
def widget_block(widget, options, &block)
return "" unless widget
widget_type = widget.type.constantize.short_name
case widget_type
when 'form'
simple_form_for(widget.name, url: form_page_path(widget.page), remote: true, html: { id: widget.name }) do |form|
content = block_given? ? capture(form, &block) : nil
if user_signed_in?
options.merge!({ id: widget.id, type: widget.type, name: widget.name, page: widget.page_id, path: page_widget_path(page_id: widget.page_id, id: widget.id) }).reject!{ |k, v| v.nil? }
render("quadro/widgets/#{widget_type}/signed_on", widget: widget, options: options, content: content, form: form)
else
render("quadro/widgets/#{widget_type}/signed_off", widget: widget, options: options, content: content, form: form)
end
end
else
content = block_given? ? capture(&block) : nil
if user_signed_in?
options.merge!({ id: widget.id, type: widget.type, name: widget.name, page: widget.page_id, path: page_widget_path(page_id: widget.page_id, id: widget.id) }).reject!{ |k, v| v.nil? }
render("quadro/widgets/#{widget_type}/signed_on", widget: widget, options: options, content: content)
else
render("quadro/widgets/#{widget_type}/signed_off", widget: widget, options: options, content: content)
end
end
end
|