Class: Para::Admin::ResourcesController
Instance Method Summary
collapse
#attributes_mappings_for
#attribute_field_mappings_for, #excerpt_value_for, #field_for, #field_value_for, #model_field_mappings, #relation_klass_for, #value_for
#current_ability, #current_admin
Methods included from BaseHelper
#find_partial_for, #find_relation_name_for, #flash_message, #registered_components_options, #resource_title_for, #template_path_lookup
#resource_name
#admin?
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/para/admin/resources_controller.rb', line 17
def create
resource.component = @component if resource.respond_to?(:component=)
resource.assign_attributes(resource_params)
if resource.save
flash_message(:success, resource)
redirect_to after_form_submit_path, status: 303
else
flash_message(:error, resource)
render 'new', status: 422
end
end
|
#destroy ⇒ Object
49
50
51
52
53
|
# File 'app/controllers/para/admin/resources_controller.rb', line 49
def destroy
resource.destroy
flash_message(:success, resource)
redirect_to after_form_submit_path, status: 303
end
|
#edit ⇒ Object
35
36
37
|
# File 'app/controllers/para/admin/resources_controller.rb', line 35
def edit
render 'para/admin/resources/edit'
end
|
#new ⇒ Object
13
14
15
|
# File 'app/controllers/para/admin/resources_controller.rb', line 13
def new
render 'para/admin/resources/new'
end
|
#order ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
|
# File 'app/controllers/para/admin/resources_controller.rb', line 55
def order
ActiveRecord::Base.transaction do
resources_data.each do |resource_params|
resource = resources_hash[resource_params[:id]]
resource.position = resource_params[:position].to_i
resource.save(validate: false)
end
end
head 200
end
|
#tree ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'app/controllers/para/admin/resources_controller.rb', line 67
def tree
ActiveRecord::Base.transaction do
resources_data.each do |resource_params|
resource = resources_hash[resource_params[:id]]
resource.assign_attributes(
position: resource_params[:position].to_i,
parent_id: resource_params[:parent_id]
)
resource.save(validate: false)
end
end
head 200
end
|
#update ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/para/admin/resources_controller.rb', line 39
def update
if resource.update(resource_params)
flash_message(:success, resource)
redirect_to after_form_submit_path, status: 303
else
flash_message(:error, resource)
render 'edit', status: 422
end
end
|