Class: Editor::PropertiesBuilderHelper::PropertyFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
app/helpers/amalgam/editor/properties_builder_helper.rb

Instance Method Summary collapse

Instance Method Details

#attachment(name, options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/amalgam/editor/properties_builder_helper.rb', line 33

def attachment(name, options={})
  options[:class] ||= 'input-xlarge'
  index_create
  obj = object.attachments[name]
  @buffer = label("#{I18n.t('amalgam.attachment')} : #{name}",options.delete(:lable_options)||{:style => 'font-weight:bold;'})
  @buffer.concat '<div style = "border-bottom: solid #cccccc 1px;padding:5px; margin-bottom:3px;">'.html_safe
  @buffer.concat label(I18n.t("amalgam.description")+':',:style => "display:inline;margin-right:35px;")
  @buffer.concat attachment_field(:text_field, :description, obj.try(:description), options)
  @buffer.concat '<br>'.html_safe
  @buffer.concat label(I18n.t("amalgam.file_upload")+':',:style => "display:inline;margin-right:10px;")
  @buffer.concat attachment_field(:file_field, :file)
  @buffer.concat '<br>'.html_safe
  if obj.try(:content_type).to_s =~ /image/
    @buffer.concat label(I18n.t("amalgam.file_pre")+':',:style => "display:inline;margin-right:10px;")
    @buffer.concat @template.image_tag(obj.file.thumb.url)
  else
    @buffer.concat "<a href= '#{obj.file.try(:url)}'>#{I18n.t("amalgam.file_download")}</a>".html_safe if obj
  end
  @buffer.concat attachment_field(:hidden_field, :name, name)
  @buffer.concat attachment_field(:hidden_field, :id, obj.id) if obj.try(:persisted?)
  @buffer.concat '</div>'.html_safe
  @buffer.html_safe
end

#attachment_list(name, options = {}) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/helpers/amalgam/editor/properties_builder_helper.rb', line 57

def attachment_list(name, options={})
  options[:class] ||= "attachment_list_#{name}"
  @buffer = @template.(:div,options) do
    buffer = label("#{I18n.t('amalgam.attachment_list')} : #{name}",options.delete(:lable_options)||{:style => 'font-weight:bold;'})
    objs = object.attachments[name] || []
    objs.each do |obj|
      buffer.concat attachment_item(obj).html_safe
    end
    buffer
  end

  link = @template.link_to('#', :class => 'new_attachment', :name => name, :data => {"model-id" => object.id, "type" => object.class.to_s.underscore}) do
    "<i class=\"icon-plus\"></i>#{::I18n.t('amalgam.admin.actions.new')}".html_safe
  end
  @buffer.concat link
end

#string(attribute, options = {}) ⇒ Object



25
26
27
# File 'app/helpers/amalgam/editor/properties_builder_helper.rb', line 25

def string(attribute, options={})
  field_with_label(:text_field,attribute,options)
end

#text(attribute, options = {}) ⇒ Object



29
30
31
# File 'app/helpers/amalgam/editor/properties_builder_helper.rb', line 29

def text(attribute, options={})
  field_with_label(:text_area,attribute,options)
end