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
29
30
31
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 29
def after_destroy_collection
redirect_back fallback_location: hyrax.batch_edits_path
end
|
#after_update ⇒ Object
22
23
24
25
26
27
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 22
def after_update
respond_to do |format|
format.json { head :no_content }
format.html { redirect_to_return_controller }
end
end
|
#check_for_empty! ⇒ Object
33
34
35
36
37
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 33
def check_for_empty!
return unless check_for_empty_batch?
redirect_back fallback_location: hyrax.batch_edits_path
false
end
|
#destroy_collection ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 39
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
16
17
18
19
20
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 16
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
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 66
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/controllers/hyrax/batch_edits_controller.rb', line 48
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
if params[:visibility]
Deprecation.warn(self, "visibility is not submitted by the Hyrax UI and is deprecated " \
"for removal in Hyrax 3.0. Please use " \
"#{form_class.model_name.param_key}[visibility] instead.")
obj.visibility = params[:visibility]
end
InheritPermissionsJob.perform_now(obj)
VisibilityCopyJob.perform_now(obj)
obj.save
end
|