@@ -18,14 +18,39 @@ def add_new_banner(uploaded_file_ids)
18
18
banner_info . save f . collection_banner_url
19
19
end
20
20
21
- # [Hyrax-overwrite-v3.0.0.pre.rc1 ] Restrict deletion to admins only
21
+ # [Hyrax-overwrite-v3.4.2 ] Restrict deletion to admins only
22
22
def destroy
23
23
if current_user . admin? && @collection . destroy
24
24
after_destroy ( params [ :id ] )
25
25
else
26
26
after_destroy_error ( params [ :id ] )
27
27
end
28
28
end
29
+
30
+ def new
31
+ # Coming from the UI, a collection type id should always be present. Coming from the API, if a collection type id is not specified,
32
+ # use the default collection type (provides backward compatibility with versions < Hyrax 2.1.0)
33
+ @aspace_repositories = retrieve_aspace_repositories
34
+ collection_type_id = params [ :collection_type_id ] . presence || default_collection_type . id
35
+ @collection . collection_type_gid = CollectionType . find ( collection_type_id ) . to_global_id
36
+ add_breadcrumb t ( :'hyrax.controls.home' ) , root_path
37
+ add_breadcrumb t ( :'hyrax.dashboard.breadcrumbs.admin' ) , hyrax . dashboard_path
38
+ add_breadcrumb t ( '.header' , type_title : collection_type . title ) , request . path
39
+ @collection . try ( :apply_depositor_metadata , current_user . user_key )
40
+ form
41
+ end
42
+
43
+ private
44
+
45
+ def retrieve_aspace_repositories
46
+ service = Aspace ::ApiService . new
47
+ formatter = Aspace ::FormattingService . new
48
+
49
+ service . authenticate!
50
+
51
+ data = service . fetch_repositories
52
+ data . map { |r | formatter . format_repository ( r ) } || [ ]
53
+ end
29
54
end
30
55
end
31
56
end
0 commit comments