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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 18
def create
@material_form = DocumentGenerator.material_form.new(form_params)
if form_params[:link].match?(RE_GOOGLE_FOLDER)
file_ids = gdoc_files_from form_params[:link]
return bulk_import(file_ids) && render(:import) if file_ids.any?
flash.now[:alert] = t '.empty_folder'
return render(:new)
end
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
39
40
41
42
43
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 39
def destroy
material = Material.find(params[:id])
material.destroy
redirect_to admin_materials_path(query: params[:query]), notice: t('.success')
end
|
#destroy_selected ⇒ Object
45
46
47
48
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 45
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
50
51
52
53
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 50
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
55
56
57
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 55
def new
@material_form = MaterialForm.new(source_type: params[:source_type].presence || 'gdoc')
end
|
#reimport_selected ⇒ Object
59
60
61
62
|
# File 'app/controllers/lcms/engine/admin/materials_controller.rb', line 59
def reimport_selected
bulk_import @materials.map(&:file_url)
render :import
end
|