Skip to content

Commit 1d899fc

Browse files
committed
Revert "Moves the loading of Aspace repositories to the controller action (#2168). (#2230)"
This reverts commit c57dfd0.
1 parent 725b23a commit 1d899fc

File tree

2 files changed

+17
-37
lines changed

2 files changed

+17
-37
lines changed

app/controllers/hyrax/dashboard/collections_controller_override.rb

-33
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,6 @@ def destroy
2626
after_destroy_error(params[:id])
2727
end
2828
end
29-
30-
# [Hyrax-overwrite-v3.4.2] Creates instance variable for aspace repositories.
31-
def new
32-
# Coming from the UI, a collection type id should always be present. Coming from the API, if a collection type id is not specified,
33-
# use the default collection type (provides backward compatibility with versions < Hyrax 2.1.0)
34-
@aspace_repositories = retrieve_aspace_repositories
35-
collection_type_id = params[:collection_type_id].presence || default_collection_type.id
36-
@collection.collection_type_gid = CollectionType.find(collection_type_id).to_global_id
37-
add_breadcrumb t(:'hyrax.controls.home'), root_path
38-
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
39-
add_breadcrumb t('.header', type_title: collection_type.title), request.path
40-
@collection.try(:apply_depositor_metadata, current_user.user_key)
41-
form
42-
end
43-
44-
private
45-
46-
def retrieve_aspace_repositories
47-
service = Aspace::ApiService.new
48-
formatter = Aspace::FormattingService.new
49-
50-
repositories =
51-
begin
52-
service.authenticate!
53-
54-
data = service.fetch_repositories
55-
data.map { |r| formatter.format_repository(r) } || []
56-
rescue
57-
Rails.logger.error "Curate failed to authenticate with ArchivesSpace."
58-
[]
59-
end
60-
repositories
61-
end
6229
end
6330
end
6431
end

app/views/hyrax/dashboard/collections/new.html.erb

+17-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
<p>Select an ArchivesSpace Repository.</p>
2121
<div class="form-group">
2222
<label for="sel1">Select list:</label>
23-
<% repositories = @aspace_repositories.presence || [] %>
24-
<%= select_tag('sel1',
25-
options_for_select(repositories.collect{ |ar| [ar[:name], ar[:repository_id]] }),
26-
class: 'form-control') %>
23+
<select class="form-control" id="sel1"></select>
2724
</div>
2825
<div class="call-number-field">
2926
<label for="aspace-call-number">Call Number: (must be exact)</label>
@@ -74,6 +71,22 @@
7471
var result_success;
7572
var result_error;
7673

74+
$.ajax({
75+
url: '/aspace/repositories',
76+
type: 'GET',
77+
dataType: 'json',
78+
async: false,
79+
success: function(repositories) {
80+
jQuery.each( repositories, function(i, val) {
81+
var o = new Option(val.name, val.repository_id);
82+
/// jquerify the DOM object 'o' so we can use the html method
83+
$(o).html(val.name);
84+
$("#sel1").append(o);
85+
repository_id = val.repository_id;
86+
});
87+
}
88+
});
89+
7790
$("#aspace-loader").click(function (e) {
7891
$("#aspace-error").hide();
7992
$(".aspace-result-empty").empty();

0 commit comments

Comments
 (0)