Class: Lcms::Engine::Admin::MaterialsController
Instance Method Summary
collapse
document_path, engine_klass, host_engine_path, material_path, root_path, settings, #whoami
Instance Method Details
#create ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 18
def create
return bulk_import(gdoc_files) && render(:import) if gdoc_files.size > 1
@material_form = DocumentGenerator.material_form.new(form_params)
if @material_form.save
material = @material_form.material
redirect_to AdminController.material_path(material.id), notice: t('.success', name: material.name)
else
render :new
end
end
|
#destroy ⇒ Object
30
31
32
33
34
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 30
def destroy
material = Material.find(params[:id])
material.destroy
redirect_to admin_materials_path(query: params[:query]), notice: t('.success')
end
|
#destroy_selected ⇒ Object
36
37
38
39
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 36
def destroy_selected
count = @materials.destroy_all.count
redirect_to admin_materials_path(query: params[:query]), notice: t('.success', count: count)
end
|
#import_status ⇒ Object
41
42
43
44
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 41
def import_status
data = import_status_for DocumentGenerator.material_parse_job
render json: data, status: :ok
end
|
#index ⇒ Object
12
13
14
15
16
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 12
def index
@query = OpenStruct.new params[:query]
@materials = DocTemplate.config['queries']['material'].constantize.call(@query, page: params[:page])
render_customized_view
end
|
#new ⇒ Object
46
47
48
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 46
def new
@material_form = MaterialForm.new(source_type: params[:source_type].presence || 'gdoc')
end
|
#reimport_selected ⇒ Object
50
51
52
53
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 50
def reimport_selected
bulk_import @materials.map(&:file_url)
render :import
end
|