Class: Alchemy::Admin::ContentsController

Inherits:
BaseController show all
Defined in:
app/controllers/alchemy/admin/contents_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

#create ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/alchemy/admin/contents_controller.rb', line 15

def create
  @element = Element.find(params[:content][:element_id])
  @content = Content.create_from_scratch(@element, content_params)
  @options = options_from_params
  @html_options = params[:html_options] || {}
  if picture_gallery_editor?
    @content.update_essence(picture_id: params[:picture_id])
    @options = options_for_picture_gallery
    @content_dom_id = "#add_picture_#{@element.id}"
  else
    @content_dom_id = "#add_content_for_element_#{@element.id}"
  end
  @locals = essence_editor_locals
end

#destroy ⇒ Object



44
45
46
47
48
49
# File 'app/controllers/alchemy/admin/contents_controller.rb', line 44

def destroy
  @content = Content.find(params[:id])
  @content_dom_id = @content.dom_id
  @notice = _t("Successfully deleted content", content: @content.name_for_label)
  @content.destroy
end

#new ⇒ Object



8
9
10
11
12
13
# File 'app/controllers/alchemy/admin/contents_controller.rb', line 8

def new
  @element = Element.find(params[:element_id])
  @options = options_from_params
  @contents = @element.available_contents
  @content = @element.contents.build
end

#order ⇒ Object



35
36
37
38
39
40
41
42
# File 'app/controllers/alchemy/admin/contents_controller.rb', line 35

def order
  Content.transaction do
    params[:content_ids].each_with_index do |id, idx|
      Content.where(id: id).update_all(position: idx + 1)
    end
  end
  @notice = _t("Successfully saved content position")
end

#update ⇒ Object



30
31
32
33
# File 'app/controllers/alchemy/admin/contents_controller.rb', line 30

def update
  @content = Content.find(params[:id])
  @content.update_essence(content_params)
end