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