Class: Alchemy::Ingredients::PictureEditor

Inherits:
BaseEditor
  • Object
show all
Defined in:
app/components/alchemy/ingredients/picture_editor.rb

Instance Attribute Summary

Attributes inherited from BaseEditor

#html_options, #ingredient

Instance Method Summary collapse

Methods inherited from BaseEditor

#call, #form_field_id, #form_field_name, #initialize

Constructor Details

This class inherits a constructor from Alchemy::Ingredients::BaseEditor

Instance Method Details

#input_fieldObject



14
15
16
17
18
19
20
21
22
23
24
25
26
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/components/alchemy/ingredients/picture_editor.rb', line 14

def input_field
  ("alchemy-picture-editor") do
    concat(
      tag.div(class: "picture_thumbnail",
        data: {
          target_size: settings[:size] || [
            image_file_width.to_i,
            image_file_height.to_i
          ].join("x"),
          image_cropper: thumbnail_url_options[:crop]
        }) do
        if editable?
          concat tag.button(
            render_icon("close"),
            type: "button",
            class: "picture_tool delete"
          )
        end
        concat(
          tag.div(class: "picture_image") do
            render Alchemy::Admin::PictureThumbnail.new(
              ingredient,
              css_class: "img_paddingtop",
              placeholder: render_icon(:image, size: "xl")
            )
          end
        )
        if css_class.present?
          concat render(
            "alchemy/ingredients/shared/picture_css_class",
            css_class: css_class
          )
        end
        concat(
          tag.div(class: "edit_images_bottom") do
            render(
              "alchemy/ingredients/shared/picture_tools",
              picture_editor: self
            )
          end
        )
      end
    )
    concat hidden_field_tag(form_field_name(:picture_id),
      picture&.id,
      id: form_field_id(:picture_id),
      data: {
        picture_id: true,
        image_file_width: image_file_width,
        image_file_height: image_file_height
      })
    concat hidden_field_tag(form_field_name(:link), ingredient.link, data: {link_value: true}, id: nil)
    concat hidden_field_tag(form_field_name(:link_title), ingredient.link_title, data: {link_title: true}, id: nil)
    concat hidden_field_tag(form_field_name(:link_class_name), ingredient.link_class_name, data: {link_class: true}, id: nil)
    concat hidden_field_tag(form_field_name(:link_target), ingredient.link_target, data: {link_target: true}, id: nil)
    concat hidden_field_tag(form_field_name(:crop_from), ingredient.crop_from, data: {crop_from: true}, id: form_field_id(:crop_from))
    concat hidden_field_tag(form_field_name(:crop_size), ingredient.crop_size, data: {crop_size: true}, id: form_field_id(:crop_size))
  end
end