Class: Hyrax::BatchEditsController
Instance Method Summary
collapse
#batch, #batch=, #check_for_empty_batch?
#add_breadcrumb_for_action, #build_breadcrumbs, #default_trail, #trail_from_referer
#display_media_download_link?, #media_display, #media_display_partial, #parent_path
Instance Method Details
#after_destroy_collection ⇒ Object
30
31
32
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 30
def after_destroy_collection
redirect_back fallback_location: hyrax.batch_edits_path
end
|
#after_update ⇒ Object
23
24
25
26
27
28
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 23
def after_update
respond_to do |format|
format.json { head :no_content }
format.html { redirect_to_return_controller }
end
end
|
#check_for_empty! ⇒ Object
34
35
36
37
38
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 34
def check_for_empty!
return unless check_for_empty_batch?
redirect_back fallback_location: hyrax.batch_edits_path
false
end
|
#destroy_collection ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 40
def destroy_collection
batch.each do |doc_id|
resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(doc_id))
transactions['collection_resource.destroy']
.with_step_args('collection_resource.delete' => { user: current_user })
.call(resource)
.value!
end
flash[:notice] = "Batch delete complete"
after_destroy_collection
end
|
#edit ⇒ Object
17
18
19
20
21
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 17
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
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 63
def update
case params["update_type"]
when "update"
batch.each do |doc_id|
update_document(Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: doc_id, use_valkyrie: false))
end
flash[:notice] = "Batch update complete"
after_update
when "delete_all"
destroy_batch
end
end
|
#update_document(obj) ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 52
def update_document(obj)
interpret_visiblity_params(obj)
obj.attributes = work_params(admin_set_id: obj.admin_set_id).except(*visibility_params)
obj.date_modified = Time.current.ctime
InheritPermissionsJob.perform_now(obj)
VisibilityCopyJob.perform_now(obj)
obj.save
end
|