Class: Workarea::Admin::NavigationTaxonsController
Instance Method Summary
collapse
#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model
Methods included from Publishing
#allow_publishing!, #allow_publishing?, #set_publishing_options
Methods included from Visiting
#most_visited
Instance Method Details
#children ⇒ Object
66
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 66
def children; end
|
#create ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 22
def create
SetNavigable.new(@taxon, params).set
if @taxon.save
@taxon.move_to_position(params[:position]) if params[:position].present?
flash[:success] = t('workarea.admin.navigation_taxons.flash_messages.created')
redirect_to navigation_taxons_path(taxon_ids: @taxon.parent_ids)
else
flash[:error] = t('workarea.admin.navigation_taxons.flash_messages.created_error')
@parent = Navigation::Taxon.find(params[:parent_id])
render :new, status: :unprocessable_entity
end
end
|
#destroy ⇒ Object
83
84
85
86
87
88
89
90
91
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 83
def destroy
if @taxon.destroy
flash[:success] = t('workarea.admin.navigation_taxons.flash_messages.removed')
else
flash[:error] = @taxon.errors.to_a.to_sentence
end
redirect_to navigation_taxons_path(taxon_ids: @taxon.parent_ids)
end
|
#edit ⇒ Object
37
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 37
def edit; end
|
#index ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 8
def index
@roots = if params[:taxon_ids].present?
Navigation::Taxon
.find(params[:taxon_ids])
.sort_by(&:depth)
else
[Navigation::Taxon.root]
end
end
|
#insert ⇒ Object
61
62
63
64
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 61
def insert
taxon = Navigation::Taxon.new(params[:taxon])
render partial: 'insert', locals: { parent: @taxon, taxon: taxon }
end
|
#move ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 68
def move
other = Navigation::Taxon.find(params[:other_id])
if params[:direction] == 'above'
@taxon.move_above(other)
elsif params[:direction] == 'below'
@taxon.move_below(other)
else
@taxon.parent = other
@taxon.save!
end
head 200
end
|
#new ⇒ Object
18
19
20
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 18
def new
@parent = Navigation::Taxon.find(params[:parent_id])
end
|
#select ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 51
def select
if params[:id].present?
@taxon = Navigation::Taxon.find(params[:id])
else
@taxon = Workarea::Navigation::Taxon.root
end
render partial: 'select', locals: { taxon: @taxon }
end
|
#update ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/workarea/admin/navigation_taxons_controller.rb', line 39
def update
SetNavigable.new(@taxon, params).set
if @taxon.update_attributes(params[:taxon])
flash[:success] = t('workarea.admin.navigation_taxons.flash_messages.updated')
redirect_to navigation_taxons_path(taxon_ids: @taxon.parent_ids)
else
flash[:error] = t('workarea.admin.navigation_taxons.flash_messages.changes_error')
render :edit, status: :unprocessable_entity
end
end
|