Class: Alchemy::Admin::EssencePicturesController

Inherits:
BaseController show all
Defined in:
app/controllers/alchemy/admin/essence_pictures_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#leave

Methods included from Modules

included, #module_definition_for, register_module

Methods included from ConfigurationMethods

#configuration, #multi_language?, #multi_site?

Instance Method Details

#assignObject

Assigns picture, but does not saves it.

When the user saves the element the content gets updated as well.



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 41

def assign
  @picture = Picture.find_by(id: params[:picture_id])
  @content.essence.picture = @picture
  @element = @content.element
  @dragable = @options[:grouped]
  @options = @options.merge(dragable: @dragable)

  # We need to update timestamp here because we don't save yet,
  # but the cache needs to be get invalid.
  # And we don't user @content.touch here, because that updates
  # also the element and page timestamps what we don't want yet.
  @content.update_column(:updated_at, Time.now)
end

#cropObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 17

def crop
  if @picture = @essence_picture.picture
    @content = @essence_picture.content
    @options[:format] ||= (configuration(:image_store_format) or 'png')

    @min_size = sizes_from_essence_or_params
    @ratio = ratio_from_size_or_params
    infer_width_or_height_from_ratio

    @default_box = @essence_picture.default_mask(@min_size)
    @initial_box = @essence_picture.cropping_mask || @default_box
  else
    @no_image_notice = _t(:no_image_for_cropper_found)
  end
end

#destroyObject



55
56
57
58
59
60
61
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 55

def destroy
  @content = Content.find_by(id: params[:id])
  @element = @content.element
  @content_id = @content.id
  @content.destroy
  @essence_pictures = @element.contents.essence_pictures
end

#editObject



14
15
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 14

def edit
end

#updateObject



33
34
35
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 33

def update
  @essence_picture.update(essence_picture_params)
end