Class: Hyrax::Dashboard::CollectionsController
Overview
Shows a list of all collections to the admins
Instance Method Summary
collapse
#batch, #batch=, #check_for_empty_batch?
#add_breadcrumb_for_action, #add_breadcrumb_for_controller, #mark_active_action
#add_breadcrumb_for_action, #add_breadcrumb_for_controller, #build_breadcrumbs, #default_trail, #trail_from_referer
configure_facets, #index
configure_facets, #index
Instance Method Details
#after_create ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 79
def after_create
form
set_default_permissions
link_parent_collection(params[:parent_id]) unless params[:parent_id].nil?
respond_to do |format|
ActiveFedora::SolrService.instance.conn.commit
format.html { redirect_to edit_dashboard_collection_path(@collection), notice: t('hyrax.dashboard.my.action.collection_create_success') }
format.json { render json: @collection, status: :created, location: dashboard_collection_path(@collection) }
end
end
|
#after_create_error ⇒ Object
92
93
94
95
96
97
98
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 92
def after_create_error
form
respond_to do |format|
format.html { render action: 'new' }
format.json { render json: @collection.errors, status: :unprocessable_entity }
end
end
|
#after_destroy(_id) ⇒ Object
152
153
154
155
156
157
158
159
160
161
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 152
def after_destroy(_id)
respond_to do |format|
format.html do
redirect_to my_collections_path,
notice: t('hyrax.dashboard.my.action.collection_delete_success')
end
format.json { head :no_content, location: my_collections_path }
end
end
|
#after_destroy_error(id) ⇒ Object
163
164
165
166
167
168
169
170
171
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 163
def after_destroy_error(id)
respond_to do |format|
format.html do
flash[:notice] = t('hyrax.dashboard.my.action.collection_delete_fail')
render :edit, status: :unprocessable_entity
end
format.json { render json: { id: id }, status: :unprocessable_entity, location: dashboard_collection_path(@collection) }
end
end
|
#after_update ⇒ Object
120
121
122
123
124
125
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 120
def after_update
respond_to do |format|
format.html { redirect_to update_referer, notice: t('hyrax.dashboard.my.action.collection_update_success') }
format.json { render json: @collection, status: :updated, location: dashboard_collection_path(@collection) }
end
end
|
#after_update_error ⇒ Object
127
128
129
130
131
132
133
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 127
def after_update_error
form
respond_to do |format|
format.html { render action: 'edit' }
format.json { render json: @collection.errors, status: :unprocessable_entity }
end
end
|
#collection ⇒ Object
181
182
183
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 181
def collection
action_name == 'show' ? @presenter : @collection
end
|
#create ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 100
def create
@collection = ::Collection.new
authorize! :create, @collection
@collection.collection_type_gid = params[:collection_type_gid].presence || default_collection_type.gid
@collection.attributes = collection_params.except(:members, :parent_id, :collection_type_gid)
@collection.apply_depositor_metadata(current_user.user_key)
add_members_to_collection unless batch.empty?
@collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?
if @collection.save
after_create
else
after_create_error
end
end
|
#deny_collection_access(exception) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 42
def deny_collection_access(exception)
if exception.action == :edit
redirect_to(url_for(action: 'show'), alert: 'You do not have sufficient privileges to edit this document')
elsif current_user&.persisted?
redirect_to root_url, alert: exception.message
else
session['user_return_to'] = request.url
redirect_to main_app.new_user_session_url, alert: exception.message
end
end
|
#destroy ⇒ Object
173
174
175
176
177
178
179
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 173
def destroy
if @collection.destroy
after_destroy(params[:id])
else
after_destroy_error(params[:id])
end
end
|
#edit ⇒ Object
75
76
77
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 75
def edit
form
end
|
#files ⇒ Object
Renders a JSON response with a list of files in this collection This is used by the edit form to populate the thumbnail_id dropdown
187
188
189
190
191
192
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 187
def files
result = form.select_files.map do |label, id|
{ id: id, text: label }
end
render json: result
end
|
#new ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 53
def new
collection_type_id = params[:collection_type_id].presence || default_collection_type.id
@collection.collection_type_gid = CollectionType.find(collection_type_id).gid
add_breadcrumb t(:'hyrax.controls.home'), root_path
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
add_breadcrumb t('.header', type_title: @collection.collection_type.title), request.path
@collection.apply_depositor_metadata(current_user.user_key)
form
end
|
#search_builder_class ⇒ Object
#show ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 65
def show
if @collection.collection_type.brandable?
banner_info = CollectionBrandingInfo.where(collection_id: @collection.id.to_s).where(role: "banner")
@banner_file = "/" + banner_info.first.local_path.split("/")[-4..-1].join("/") unless banner_info.empty?
end
presenter
query_collection_members
end
|
#update ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'app/controllers/hyrax/dashboard/collections_controller.rb', line 135
def update
unless params[:update_collection].nil?
process_banner_input
process_logo_input
end
process_member_changes
@collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?
@collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
if @collection.update(collection_params.except(:members))
after_update
else
after_update_error
end
end
|