Class: Hyrax::BatchEditsController
Instance Method Summary
collapse
#batch, #batch=, #check_for_empty_batch?
#add_breadcrumb_for_action, #build_breadcrumbs, #default_trail, #trail_from_referer
#media_display, #media_display_partial, #parent_path
Instance Method Details
#after_destroy_collection ⇒ Object
27
28
29
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 27
def after_destroy_collection
redirect_to_return_controller unless request.xhr?
end
|
#after_update ⇒ Object
20
21
22
23
24
25
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 20
def after_update
respond_to do |format|
format.json { head :no_content }
format.html { redirect_to_return_controller }
end
end
|
#check_for_empty! ⇒ Object
31
32
33
34
35
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 31
def check_for_empty!
return unless check_for_empty_batch?
redirect_back fallback_location: hyrax.batch_edits_path
false
end
|
#destroy_collection ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 37
def destroy_collection
batch.each do |doc_id|
obj = ActiveFedora::Base.find(doc_id, cast: true)
obj.destroy
end
flash[:notice] = "Batch delete complete"
after_destroy_collection
end
|
#edit ⇒ Object
14
15
16
17
18
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 14
def edit
work = form_class.model_class.new
work.depositor = current_user.user_key
@form = form_class.new(work, current_user, batch)
end
|
#update ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 53
def update
case params["update_type"]
when "update"
batch.each do |doc_id|
update_document(ActiveFedora::Base.find(doc_id))
end
flash[:notice] = "Batch update complete"
after_update
when "delete_all"
destroy_batch
end
end
|
#update_document(obj) ⇒ Object
46
47
48
49
50
51
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 46
def update_document(obj)
obj.attributes = work_params
obj.date_modified = Time.current.ctime
obj.visibility = params[:visibility]
obj.save
end
|