Class: Workarea::Admin::ContentBlocksController
Instance Method Summary
collapse
#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model
Methods included from Publishing
#allow_publishing!, #set_publishing_options
Methods included from Visiting
#most_visited
Instance Method Details
#allow_publishing? ⇒ Boolean
61
62
63
64
65
66
67
68
69
|
# File 'app/controllers/workarea/admin/content_blocks_controller.rb', line 61
def allow_publishing?
super || (
defined?(@content) &&
(
!@content.active? ||
(@content.contentable.present? && !@content.contentable.active?)
)
)
end
|
#create ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/workarea/admin/content_blocks_controller.rb', line 16
def create
if @block.save
flash[:success] = t('workarea.admin.content_blocks.flash_messages.added')
else
flash[:error] = @block.errors.to_a.to_sentence
end
redirect_to return_to || edit_content_path(
@content,
release_id: @block.activate_with
)
end
|
#destroy ⇒ Object
55
56
57
58
59
|
# File 'app/controllers/workarea/admin/content_blocks_controller.rb', line 55
def destroy
@block.destroy
flash[:success] = t('workarea.admin.content_blocks.flash_messages.removed')
redirect_to return_to || edit_content_path(@content)
end
|
#index ⇒ Object
9
10
11
12
13
14
|
# File 'app/controllers/workarea/admin/content_blocks_controller.rb', line 9
def index
@return = params[:return_to].to_h
@system_block_types = Configuration::ContentBlocks.types
@content_presets = Content::Preset.all.to_a
end
|
#move ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/workarea/admin/content_blocks_controller.rb', line 41
def move
position_data = params.fetch(:block, [])
position_data.each do |block_id, position|
block = @content.blocks.find(block_id)
block.position = position
block.save!
end
flash[:success] = t('workarea.admin.content_blocks.flash_messages.moved')
head :ok
end
|
#update ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/workarea/admin/content_blocks_controller.rb', line 29
def update
@block.attributes = params[:block]
if @block.save
flash[:success] = t('workarea.admin.content_blocks.flash_messages.saved')
else
flash[:error] = @block.errors.to_a.to_sentence
end
redirect_to return_to || edit_content_path(@content)
end
|