Module: Sufia::BatchEditsControllerBehavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- Breadcrumbs
- Included in:
- BatchEditsController
- Defined in:
- app/controllers/concerns/sufia/batch_edits_controller_behavior.rb
Instance Method Summary
collapse
#add_breadcrumb_for_controller, #build_breadcrumbs, #default_trail, #trail_from_referer
Instance Method Details
#after_destroy_collection ⇒ Object
48
49
50
|
# File 'app/controllers/concerns/sufia/batch_edits_controller_behavior.rb', line 48
def after_destroy_collection
redirect_to_return_controller unless request.xhr?
end
|
#after_update ⇒ Object
44
45
46
|
# File 'app/controllers/concerns/sufia/batch_edits_controller_behavior.rb', line 44
def after_update
redirect_to_return_controller unless request.xhr?
end
|
#edit ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/concerns/sufia/batch_edits_controller_behavior.rb', line 11
def edit
super
@generic_file = ::GenericFile.new
@generic_file.depositor = current_user.user_key
@terms = @generic_file.terms_for_editing - [:title, :format, :resource_type]
@show_file = ::GenericFile.new
@show_file.depositor = current_user.user_key
h = {}
@names = []
permissions = []
batch.each do |doc_id|
gf = ::GenericFile.load_instance_from_solr(doc_id)
gf.terms_for_editing.each do |key|
h[key] ||= []
h[key] = (h[key] + gf.send(key)).uniq
end
@names << gf.to_s
permissions = (permissions + gf.permissions).uniq
end
initialize_fields(h, @show_file)
perm_param ={'user'=>{},'group'=>{"public"=>"read"}}
permissions.each{ |perm| perm_param[perm[:type]][perm[:name]] = perm[:access]}
@show_file.permissions = HashWithIndifferentAccess.new(perm_param)
end
|
#update ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'app/controllers/concerns/sufia/batch_edits_controller_behavior.rb', line 58
def update
batch_sav = batch.dup if request.xhr?
catalog_index_path = sufia.dashboard_index_path
type = params["update_type"]
if type == "update"
super
elsif type == "delete_all"
batch.each do |doc_id|
gf = ::GenericFile.find(doc_id)
gf.destroy
end
after_update
end
if request.xhr?
self.batch = batch_sav.dup
@key = params["key"]
if @key != "permissions"
@vals = params["generic_file"][@key]
else
@vals = [""]
end
render :update_edit
end
end
|
#update_document(obj) ⇒ Object
52
53
54
55
56
|
# File 'app/controllers/concerns/sufia/batch_edits_controller_behavior.rb', line 52
def update_document(obj)
super
obj.date_modified = Time.now.ctime
obj.visibility = params[:visibility]
end
|