hyrax 3.3.0 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +26 -17
  3. data/.dassie/.env +2 -1
  4. data/.dassie/Gemfile +1 -1
  5. data/.dassie/app/forms/collection_resource_form.rb +8 -0
  6. data/.dassie/app/indexers/collection_resource_indexer.rb +8 -0
  7. data/.dassie/app/models/collection_resource.rb +35 -0
  8. data/.dassie/config/initializers/file_services.rb +4 -0
  9. data/.dassie/config/initializers/hyrax.rb +12 -1
  10. data/.dassie/config/metadata/collection_resource.yaml +23 -0
  11. data/.dassie/db/seeds.rb +74 -17
  12. data/.dassie/spec/forms/collection_resource_form_spec.rb +13 -0
  13. data/.dassie/spec/indexers/collection_resource_indexer_spec.rb +14 -0
  14. data/.dassie/spec/models/collection_resource_spec.rb +13 -0
  15. data/.github/release.yml +26 -0
  16. data/.gitignore +3 -0
  17. data/.regen +1 -1
  18. data/.rubocop.yml +1 -1
  19. data/.rubocop_fixme.yml +22 -3
  20. data/CONTAINERS.md +18 -13
  21. data/Dockerfile +4 -3
  22. data/app/actors/hyrax/actors/file_actor.rb +6 -4
  23. data/app/actors/hyrax/actors/transfer_request_actor.rb +3 -7
  24. data/app/assets/javascripts/hyrax/analytics_events.js +8 -2
  25. data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +1 -3
  26. data/app/assets/javascripts/hyrax/collections_v2.es6 +13 -0
  27. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +1 -3
  28. data/app/controllers/concerns/hyrax/controller.rb +21 -0
  29. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +83 -59
  30. data/app/controllers/hyrax/admin/admin_sets_controller.rb +105 -19
  31. data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +12 -19
  32. data/app/controllers/hyrax/batch_edits_controller.rb +12 -3
  33. data/app/controllers/hyrax/batch_uploads_controller.rb +4 -0
  34. data/app/controllers/hyrax/citations_controller.rb +1 -1
  35. data/app/controllers/hyrax/dashboard/collections_controller.rb +176 -83
  36. data/app/controllers/hyrax/single_use_links_viewer_controller.rb +1 -1
  37. data/app/forms/hyrax/forms/administrative_set_form.rb +19 -1
  38. data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
  39. data/app/forms/hyrax/forms/collection_form.rb +1 -1
  40. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +21 -6
  41. data/app/forms/hyrax/forms/pcdm_collection_form.rb +30 -2
  42. data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
  43. data/app/forms/hyrax/forms/resource_form.rb +23 -5
  44. data/app/forms/hyrax/forms/widgets/admin_set_visibility.rb +1 -1
  45. data/app/helpers/hyrax/collections_helper.rb +14 -0
  46. data/app/helpers/hyrax/membership_helper.rb +1 -1
  47. data/app/helpers/hyrax/trophy_helper.rb +1 -1
  48. data/app/helpers/hyrax/url_helper.rb +1 -1
  49. data/app/indexers/hyrax/administrative_set_indexer.rb +8 -2
  50. data/app/indexers/hyrax/deep_indexing_service.rb +1 -1
  51. data/app/indexers/hyrax/file_set_indexer.rb +1 -0
  52. data/app/indexers/hyrax/pcdm_collection_indexer.rb +3 -2
  53. data/app/indexers/hyrax/thumbnail_indexer.rb +31 -0
  54. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +6 -6
  55. data/app/indexers/hyrax/valkyrie_indexer.rb +4 -2
  56. data/app/indexers/hyrax/valkyrie_work_indexer.rb +13 -0
  57. data/app/inputs/controlled_vocabulary_input.rb +2 -0
  58. data/app/jobs/change_depositor_event_job.rb +47 -0
  59. data/app/jobs/characterize_job.rb +43 -3
  60. data/app/jobs/concerns/hyrax/members_permission_job_behavior.rb +1 -1
  61. data/app/jobs/content_depositor_change_event_job.rb +2 -1
  62. data/app/jobs/hyrax/propagate_change_depositor_job.rb +32 -0
  63. data/app/jobs/import_url_job.rb +4 -6
  64. data/app/jobs/inherit_permissions_job.rb +1 -1
  65. data/app/jobs/valkyrie_create_derivatives_job.rb +25 -0
  66. data/app/jobs/valkyrie_ingest_job.rb +41 -35
  67. data/app/models/admin_set.rb +10 -2
  68. data/app/models/collection_branding_info.rb +8 -6
  69. data/app/models/concerns/hyrax/collection_behavior.rb +3 -3
  70. data/app/models/concerns/hyrax/file_set/characterization.rb +7 -1
  71. data/app/models/concerns/hyrax/solr_document/metadata.rb +1 -0
  72. data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -3
  73. data/app/models/concerns/hyrax/user.rb +11 -0
  74. data/app/models/concerns/hyrax/work_behavior.rb +1 -1
  75. data/app/models/featured_work_list.rb +0 -1
  76. data/app/models/hyrax/administrative_set.rb +36 -1
  77. data/app/models/hyrax/collection_type.rb +2 -2
  78. data/app/models/hyrax/file_metadata.rb +37 -3
  79. data/app/models/hyrax/file_set.rb +43 -4
  80. data/app/models/hyrax/group.rb +19 -0
  81. data/app/models/hyrax/pcdm_collection.rb +56 -1
  82. data/app/models/hyrax/permission_template.rb +11 -5
  83. data/app/models/hyrax/work.rb +91 -0
  84. data/app/models/job_io_wrapper.rb +1 -1
  85. data/app/models/proxy_deposit_request.rb +1 -1
  86. data/app/presenters/hyrax/admin_set_presenter.rb +2 -2
  87. data/app/presenters/hyrax/member_presenter_factory.rb +2 -4
  88. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +2 -2
  89. data/app/presenters/hyrax/work_show_presenter.rb +10 -6
  90. data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +2 -2
  91. data/app/search_builders/hyrax/dashboard/managed_search_filters.rb +44 -4
  92. data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +2 -2
  93. data/app/search_builders/hyrax/my/collections_search_builder.rb +11 -4
  94. data/app/services/hyrax/access_control_list.rb +20 -6
  95. data/app/services/hyrax/adapters/nesting_index_adapter.rb +3 -3
  96. data/app/services/hyrax/admin_set_create_service.rb +21 -37
  97. data/app/services/hyrax/change_content_depositor_service.rb +2 -2
  98. data/app/services/hyrax/change_depositor_service.rb +70 -0
  99. data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +4 -6
  100. data/app/services/hyrax/collections/collection_member_service.rb +3 -5
  101. data/app/services/hyrax/collections/nested_collection_query_service.rb +24 -12
  102. data/app/services/hyrax/custom_queries/navigators/child_file_sets_navigator.rb +45 -0
  103. data/app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb +7 -2
  104. data/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +54 -0
  105. data/app/services/hyrax/default_middleware_stack.rb +3 -0
  106. data/app/services/hyrax/file_set_derivatives_service.rb +21 -2
  107. data/app/services/hyrax/file_set_type_service.rb +2 -5
  108. data/app/services/hyrax/listeners/file_metadata_listener.rb +31 -1
  109. data/app/services/hyrax/listeners/member_cleanup_listener.rb +27 -11
  110. data/app/services/hyrax/listeners/metadata_index_listener.rb +39 -0
  111. data/app/services/hyrax/listeners/proxy_deposit_listener.rb +14 -8
  112. data/app/services/hyrax/location_service.rb +33 -0
  113. data/app/services/hyrax/multiple_membership_checker.rb +46 -1
  114. data/app/services/hyrax/resource_visibility_propagator.rb +1 -1
  115. data/app/services/hyrax/simple_schema_loader.rb +5 -1
  116. data/app/services/hyrax/solr_query_service.rb +12 -7
  117. data/app/services/hyrax/thumbnail_path_service.rb +1 -1
  118. data/app/services/hyrax/valkyrie_persist_derivatives.rb +50 -0
  119. data/app/services/hyrax/valkyrie_upload.rb +94 -0
  120. data/app/services/hyrax/work_uploads_handler.rb +0 -10
  121. data/app/services/hyrax/workflow/workflow_importer.rb +7 -9
  122. data/app/services/hyrax/workflow/workflow_schema.rb +3 -5
  123. data/app/strategies/hyrax/strategies/yaml_strategy.rb +4 -6
  124. data/app/uploaders/hyrax/uploaded_file_uploader.rb +4 -4
  125. data/app/utils/hyrax/data_destroyers/collection_branding_destroyer.rb +29 -0
  126. data/app/utils/hyrax/data_destroyers/collection_types_destroyer.rb +26 -0
  127. data/app/utils/hyrax/data_destroyers/default_admin_set_id_cache_destroyer.rb +26 -0
  128. data/app/utils/hyrax/data_destroyers/featured_works_destroyer.rb +27 -0
  129. data/app/utils/hyrax/data_destroyers/permission_templates_destroyer.rb +30 -0
  130. data/app/utils/hyrax/data_destroyers/repository_metadata_destroyer.rb +42 -0
  131. data/app/utils/hyrax/data_destroyers/stats_destroyer.rb +33 -0
  132. data/app/utils/hyrax/data_maintenance.rb +51 -0
  133. data/app/utils/hyrax/required_data_seeder.rb +21 -0
  134. data/app/utils/hyrax/required_data_seeders/collection_seeder.rb +26 -0
  135. data/app/utils/hyrax/required_data_seeders/collection_type_seeder.rb +36 -0
  136. data/app/utils/hyrax/test_data_seeder.rb +24 -0
  137. data/app/utils/hyrax/test_data_seeders/collection_seeder.rb +91 -0
  138. data/app/utils/hyrax/test_data_seeders/collection_type_seeder.rb +72 -0
  139. data/app/utils/hyrax/test_data_seeders/user_seeder.rb +52 -0
  140. data/app/validators/hyrax/collection_membership_validator.rb +39 -0
  141. data/app/views/catalog/_index_header_list_default.html.erb +8 -1
  142. data/app/views/catalog/_thumbnail_list_default.html.erb +8 -3
  143. data/app/views/collections/edit_fields/_based_near.html.erb +7 -7
  144. data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +2 -2
  145. data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +2 -2
  146. data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +2 -2
  147. data/app/views/hyrax/admin/admin_sets/_form_workflow.erb +1 -1
  148. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  149. data/app/views/hyrax/base/_form.html.erb +1 -1
  150. data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
  151. data/app/views/hyrax/dashboard/collections/_default_group.html.erb +2 -2
  152. data/app/views/hyrax/dashboard/collections/_form.html.erb +24 -17
  153. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -0
  154. data/app/views/hyrax/dashboard/collections/_form_discovery.html.erb +6 -3
  155. data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
  156. data/app/views/hyrax/dashboard/collections/_form_share_table.html.erb +3 -3
  157. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +2 -2
  158. data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +1 -1
  159. data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
  160. data/app/views/hyrax/dashboard/works/_list_works.html.erb +1 -1
  161. data/app/views/hyrax/file_sets/_actions.html.erb +2 -2
  162. data/app/views/hyrax/my/_facet_pagination.html.erb +12 -9
  163. data/app/views/hyrax/my/_work_action_menu.html.erb +8 -9
  164. data/app/views/hyrax/my/collections/_default_group.html.erb +2 -2
  165. data/app/views/hyrax/my/collections/_list_collections.html.erb +2 -2
  166. data/app/views/hyrax/my/collections/index.html.erb +3 -2
  167. data/app/views/hyrax/my/works/_default_group.html.erb +1 -1
  168. data/app/views/hyrax/my/works/_list_works.html.erb +1 -2
  169. data/app/views/hyrax/my/works/_tabs.html.erb +6 -1
  170. data/app/views/hyrax/my/works/index.html.erb +4 -2
  171. data/chart/hyrax/Chart.yaml +11 -7
  172. data/chart/hyrax/README.md +22 -1
  173. data/chart/hyrax/templates/_helpers.tpl +4 -0
  174. data/chart/hyrax/templates/cron-embargo.yaml +5 -0
  175. data/chart/hyrax/templates/cron-lease.yaml +5 -0
  176. data/chart/hyrax/templates/deployment-worker.yaml +11 -0
  177. data/chart/hyrax/templates/ingress.yaml +7 -6
  178. data/chart/hyrax/values.yaml +152 -0
  179. data/config/features.rb +48 -50
  180. data/config/initializers/listeners.rb +0 -1
  181. data/config/initializers/{valkryrie_storage.rb → storage_adapter_initializer.rb} +5 -0
  182. data/config/locales/hyrax.de.yml +18 -17
  183. data/config/locales/hyrax.en.yml +30 -28
  184. data/config/locales/hyrax.es.yml +10 -9
  185. data/config/locales/hyrax.fr.yml +2 -1
  186. data/config/locales/hyrax.it.yml +3 -2
  187. data/config/locales/hyrax.pt-BR.yml +2 -1
  188. data/config/locales/hyrax.zh.yml +2 -1
  189. data/config/metadata/basic_metadata.yaml +2 -0
  190. data/config/metadata/core_metadata.yaml +1 -1
  191. data/docker-compose.yml +47 -42
  192. data/documentation/developing-your-hyrax-based-app.md +1 -1
  193. data/documentation/legacyREADME.md +1 -1
  194. data/hyrax.gemspec +5 -3
  195. data/lib/generators/hyrax/collection_resource/USAGE +20 -0
  196. data/lib/generators/hyrax/collection_resource/collection_resource_generator.rb +133 -0
  197. data/lib/generators/hyrax/collection_resource/templates/collection.rb.erb +34 -0
  198. data/lib/generators/hyrax/collection_resource/templates/collection_form.rb.erb +7 -0
  199. data/lib/generators/hyrax/collection_resource/templates/collection_form_spec.rb.erb +13 -0
  200. data/lib/generators/hyrax/collection_resource/templates/collection_indexer.rb.erb +7 -0
  201. data/lib/generators/hyrax/collection_resource/templates/collection_indexer_spec.rb.erb +13 -0
  202. data/lib/generators/hyrax/collection_resource/templates/collection_metadata.yaml +22 -0
  203. data/lib/generators/hyrax/collection_resource/templates/collection_spec.rb.erb +12 -0
  204. data/lib/generators/hyrax/install_generator.rb +9 -0
  205. data/lib/hyrax/administrative_set_name.rb +18 -0
  206. data/lib/hyrax/collection_name.rb +2 -0
  207. data/lib/hyrax/configuration.rb +22 -0
  208. data/lib/hyrax/controlled_vocabularies/location.rb +9 -2
  209. data/lib/hyrax/controlled_vocabularies/resource_label_caching.rb +42 -0
  210. data/lib/hyrax/controlled_vocabularies.rb +1 -0
  211. data/lib/hyrax/publisher.rb +49 -0
  212. data/lib/hyrax/schema.rb +16 -13
  213. data/lib/hyrax/specs/capybara.rb +1 -1
  214. data/lib/hyrax/specs/shared_specs/hydra_works.rb +11 -5
  215. data/lib/hyrax/specs/shared_specs/indexers.rb +117 -3
  216. data/lib/hyrax/transactions/admin_set_create.rb +2 -1
  217. data/lib/hyrax/transactions/admin_set_destroy.rb +22 -0
  218. data/lib/hyrax/transactions/admin_set_update.rb +21 -0
  219. data/lib/hyrax/transactions/collection_destroy.rb +22 -0
  220. data/lib/hyrax/transactions/collection_update.rb +5 -2
  221. data/lib/hyrax/transactions/container.rb +97 -23
  222. data/lib/hyrax/transactions/create_work.rb +3 -0
  223. data/lib/hyrax/transactions/destroy_work.rb +3 -0
  224. data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +2 -0
  225. data/lib/hyrax/transactions/steps/apply_permission_template.rb +2 -0
  226. data/lib/hyrax/transactions/steps/apply_visibility.rb +2 -0
  227. data/lib/hyrax/transactions/steps/change_depositor.rb +46 -0
  228. data/lib/hyrax/transactions/steps/check_for_empty_admin_set.rb +36 -0
  229. data/lib/hyrax/transactions/steps/delete_access_control.rb +32 -0
  230. data/lib/hyrax/transactions/steps/delete_resource.rb +19 -3
  231. data/lib/hyrax/transactions/steps/destroy_work.rb +3 -1
  232. data/lib/hyrax/transactions/steps/ensure_permission_template.rb +2 -0
  233. data/lib/hyrax/transactions/steps/save.rb +24 -6
  234. data/lib/hyrax/transactions/steps/save_access_control.rb +2 -2
  235. data/lib/hyrax/transactions/steps/save_collection_banner.rb +59 -0
  236. data/lib/hyrax/transactions/steps/save_collection_logo.rb +109 -0
  237. data/lib/hyrax/transactions/steps/save_work.rb +3 -0
  238. data/lib/hyrax/transactions/steps/set_user_as_creator.rb +41 -0
  239. data/lib/hyrax/transactions/steps/update_work_members.rb +51 -0
  240. data/lib/hyrax/transactions/update_work.rb +4 -3
  241. data/lib/hyrax/transactions/work_create.rb +1 -1
  242. data/lib/hyrax/transactions/work_destroy.rb +2 -1
  243. data/lib/hyrax/transactions/work_update.rb +19 -0
  244. data/lib/hyrax/version.rb +1 -1
  245. data/lib/wings/active_fedora_converter/file_metadata_node.rb +48 -0
  246. data/lib/wings/active_fedora_converter/instance_builder.rb +68 -0
  247. data/lib/wings/active_fedora_converter.rb +3 -3
  248. data/lib/wings/attribute_transformer.rb +5 -1
  249. data/lib/wings/services/custom_queries/find_file_metadata.rb +19 -8
  250. data/lib/wings/setup.rb +3 -1
  251. data/lib/wings/valkyrie/persister.rb +2 -0
  252. data/lib/wings/valkyrie/query_service.rb +6 -7
  253. data/lib/wings/valkyrie/storage.rb +7 -1
  254. data/template.rb +1 -1
  255. metadata +99 -12
@@ -8,7 +8,7 @@ class TrackingTags {
8
8
  return _paq;
9
9
  }
10
10
  else {
11
- return _gaq
11
+ return _gaq;
12
12
  }
13
13
  }
14
14
 
@@ -42,6 +42,9 @@ function trackAnalyticsEvents() {
42
42
 
43
43
  function setupTracking() {
44
44
  var provider = $('meta[name="analytics-provider"]').prop('content')
45
+ if (provider === undefined) {
46
+ return;
47
+ }
45
48
  window.trackingTags = new TrackingTags(provider)
46
49
  trackPageView()
47
50
  trackAnalyticsEvents()
@@ -59,6 +62,9 @@ if (typeof Turbolinks !== 'undefined') {
59
62
 
60
63
  $(document).on('click', '#file_download', function(e) {
61
64
  var provider = $('meta[name="analytics-provider"]').prop('content')
65
+ if (provider === undefined) {
66
+ return;
67
+ }
62
68
  window.trackingTags = new TrackingTags(provider)
63
69
  window.trackingTags.analytics().push([trackingTags.trackEvent(), 'file-set', 'file-set-download', $(this).data('label')]);
64
70
  window.trackingTags.analytics().push([trackingTags.trackEvent(), 'file-set-in-work', 'file-set-in-work-download', $(this).data('work-id')]);
@@ -66,4 +72,4 @@ $(document).on('click', '#file_download', function(e) {
66
72
  window.trackingTags.analytics().push([trackingTags.trackEvent(), 'file-set-in-collection', 'file-set-in-collection-download', collection]);
67
73
  window.trackingTags.analytics().push([trackingTags.trackEvent(), 'work-in-collection', 'work-in-collection-download', collection]);
68
74
  });
69
- });
75
+ });
@@ -40,11 +40,9 @@ export default class LinkedData {
40
40
  // Called when Select2 is created to allow the user to initialize the
41
41
  // selection based on the value of the element select2 is attached to.
42
42
  // Essentially this is an id->object mapping function.
43
-
44
- // TODO: Presently we're just showing a URI, but we should show the label.
45
43
  var data = {
46
44
  id: element.val(),
47
- label: element.val()
45
+ label: element[0].dataset.label || element.val()
48
46
  };
49
47
  callback(data);
50
48
  },
@@ -1,10 +1,12 @@
1
1
  import CollectionUtilities from 'hyrax/collections_utils';
2
+ import Editor from 'hyrax/editor';
2
3
 
3
4
  export default class CollectionsV2 {
4
5
  constructor() {
5
6
  this.collectionUtilities = new CollectionUtilities();
6
7
  this.setupAddSharingHandler();
7
8
  this.sharingAddButtonDisabler();
9
+ this.setupEditor();
8
10
  }
9
11
 
10
12
  /**
@@ -54,4 +56,15 @@ export default class CollectionsV2 {
54
56
  )
55
57
  );
56
58
  }
59
+
60
+ /**
61
+ * Set up editor to enable Geonames autocomplete for Location data
62
+ * @return {void}
63
+ */
64
+ setupEditor() {
65
+ var element = $("[data-behavior='collection-form']");
66
+ if (element.length > 0) {
67
+ new Editor(element).init();
68
+ }
69
+ }
57
70
  }
@@ -41,9 +41,7 @@ module Hyrax
41
41
  private
42
42
 
43
43
  def presenter
44
- @presenter ||= begin
45
- presenter_class.new(curation_concern, current_ability)
46
- end
44
+ @presenter ||= presenter_class.new(curation_concern, current_ability)
47
45
  end
48
46
 
49
47
  def curation_concern
@@ -17,6 +17,9 @@ module Hyrax::Controller
17
17
  helper_method :create_work_presenter
18
18
  before_action :set_locale
19
19
  before_action :check_read_only, except: [:show, :index]
20
+
21
+ class_attribute :search_service_class
22
+ self.search_service_class = Hyrax::SearchService
20
23
  end
21
24
 
22
25
  # Provide a place for Devise to send the user to after signing in
@@ -51,6 +54,24 @@ module Hyrax::Controller
51
54
  blacklight_config.repository
52
55
  end
53
56
 
57
+ # @note for Blacklight 6/7 compatibility
58
+ def search_results(*args)
59
+ return super if defined?(super) # use the upstream if present (e.g. in BL 6)
60
+
61
+ search_service(*args).search_results
62
+ end
63
+
64
+ ##
65
+ # @note for Blacklight 6/7 compatibility
66
+ def search_service(**search_params)
67
+ return super if defined?(super) && search_params.empty?
68
+
69
+ search_service_class.new(config: blacklight_config,
70
+ scope: self,
71
+ user_params: search_params,
72
+ search_builder_class: search_builder_class)
73
+ end
74
+
54
75
  private
55
76
 
56
77
  ##
@@ -55,21 +55,12 @@ module Hyrax
55
55
  end
56
56
 
57
57
  def create
58
- # Caching the original input params in case the form is not valid
59
- original_input_params_for_form = params[hash_key_for_curation_concern].deep_dup
60
- if create_work
61
- after_create_response
58
+ case curation_concern
59
+ when ActiveFedora::Base
60
+ original_input_params_for_form = params[hash_key_for_curation_concern].deep_dup
61
+ actor.create(actor_environment) ? after_create_response : after_create_error(curation_concern.errors, original_input_params_for_form)
62
62
  else
63
- respond_to do |wants|
64
- wants.html do
65
- build_form
66
- # Creating a form object that can re-render most of the
67
- # submitted parameters
68
- @form = Hyrax::Forms::FailedSubmissionFormWrapper.new(form: @form, input_params: original_input_params_for_form)
69
- render 'new', status: :unprocessable_entity
70
- end
71
- wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
72
- end
63
+ create_valkyrie_work
73
64
  end
74
65
  end
75
66
 
@@ -101,16 +92,11 @@ module Hyrax
101
92
  end
102
93
 
103
94
  def update
104
- if update_work
105
- after_update_response
95
+ case curation_concern
96
+ when ActiveFedora::Base
97
+ actor.update(actor_environment) ? after_update_response : after_update_error(curation_concern.errors)
106
98
  else
107
- respond_to do |wants|
108
- wants.html do
109
- build_form
110
- render 'edit', status: :unprocessable_entity
111
- end
112
- wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
113
- end
99
+ update_valkyrie_work
114
100
  end
115
101
  end
116
102
 
@@ -176,13 +162,7 @@ module Hyrax
176
162
  end
177
163
 
178
164
  def admin_set_id_for_new
179
- # admin_set_id is required on the client, otherwise simple_form renders a blank option.
180
- # however it isn't a required field for someone to submit via json.
181
- # Set the default admin set if it exists; otherwise, set to first admin_set they have access to.
182
- admin_sets = Hyrax::AdminSetService.new(self).search_results(:deposit)
183
- return nil if admin_sets.blank? # shouldn't happen
184
- return AdminSet::DEFAULT_ID if admin_sets.map(&:id).include?(AdminSet::DEFAULT_ID)
185
- admin_sets.first.id
165
+ Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
186
166
  end
187
167
 
188
168
  def build_form
@@ -195,36 +175,45 @@ module Hyrax
195
175
 
196
176
  ##
197
177
  # @return [#errors]
198
- def create_work
199
- case curation_concern
200
- when ActiveFedora::Base
201
- actor.create(actor_environment)
202
- else
203
- form = build_form
204
-
205
- @curation_concern =
206
- form.validate(params[hash_key_for_curation_concern]) &&
207
- transactions['change_set.create_work']
208
- .with_step_args('work_resource.add_to_parent' => { parent_id: params[:parent_id], user: current_user },
209
- 'work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] },
210
- 'change_set.set_user_as_depositor' => { user: current_user })
211
- .call(form).value!
212
- end
178
+ def create_valkyrie_work
179
+ form = build_form
180
+ return after_create_error(form_err_msg(form)) unless form.validate(params[hash_key_for_curation_concern])
181
+
182
+ result =
183
+ transactions['change_set.create_work']
184
+ .with_step_args(
185
+ 'work_resource.add_to_parent' => { parent_id: params[:parent_id], user: current_user },
186
+ 'work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] },
187
+ 'change_set.set_user_as_depositor' => { user: current_user },
188
+ 'work_resource.change_depositor' => { user: ::User.find_by_user_key(form.on_behalf_of) }
189
+ )
190
+ .call(form)
191
+ @curation_concern = result.value_or { return after_create_error(transaction_err_msg(result)) }
192
+ after_create_response
213
193
  end
214
194
 
215
- def update_work
216
- case curation_concern
217
- when ActiveFedora::Base
218
- actor.update(actor_environment)
219
- else
220
- form = build_form
195
+ def update_valkyrie_work
196
+ form = build_form
197
+ return after_update_error(form_err_msg(form)) unless form.validate(params[hash_key_for_curation_concern])
198
+ result =
199
+ transactions['change_set.update_work']
200
+ .with_step_args('work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] },
201
+ 'work_resource.update_work_members' => { work_members_attributes: work_members_attributes })
202
+ .call(form)
203
+ @curation_concern = result.value_or { return after_update_error(transaction_err_msg(result)) }
204
+ after_update_response
205
+ end
221
206
 
222
- @curation_concern =
223
- form.validate(params[hash_key_for_curation_concern]) &&
224
- transactions['change_set.update_work']
225
- .with_step_args('work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] })
226
- .call(form).value!
227
- end
207
+ def work_members_attributes
208
+ params[hash_key_for_curation_concern][:work_members_attributes]&.permit!&.to_h
209
+ end
210
+
211
+ def form_err_msg(form)
212
+ form.errors.messages.values.flatten.to_sentence
213
+ end
214
+
215
+ def transaction_err_msg(result)
216
+ result.failure.first
228
217
  end
229
218
 
230
219
  def presenter
@@ -383,6 +372,26 @@ module Hyrax
383
372
  end
384
373
  end
385
374
 
375
+ def after_create_error(errors, original_input_params_for_form = nil)
376
+ respond_to do |wants|
377
+ wants.html do
378
+ flash[:error] = errors.to_s
379
+ rebuild_form(original_input_params_for_form) if original_input_params_for_form.present?
380
+ render 'new', status: :unprocessable_entity
381
+ end
382
+ wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: errors }) }
383
+ end
384
+ end
385
+
386
+ # Creating a form object that can re-render most of the submitted parameters.
387
+ # Required for ActiveFedora::Base objects only.
388
+ def rebuild_form(original_input_params_for_form)
389
+ build_form
390
+ @form = Hyrax::Forms::FailedSubmissionFormWrapper
391
+ .new(form: @form,
392
+ input_params: original_input_params_for_form)
393
+ end
394
+
386
395
  def after_update_response
387
396
  return redirect_to hyrax.confirm_access_permission_path(curation_concern) if permissions_changed? && concern_has_file_sets?
388
397
 
@@ -392,6 +401,17 @@ module Hyrax
392
401
  end
393
402
  end
394
403
 
404
+ def after_update_error(errors)
405
+ respond_to do |wants|
406
+ wants.html do
407
+ flash[:error] = errors.to_s
408
+ build_form unless @form.is_a? Hyrax::ChangeSet
409
+ render 'edit', status: :unprocessable_entity
410
+ end
411
+ wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: errors }) }
412
+ end
413
+ end
414
+
395
415
  def after_destroy_response(title)
396
416
  respond_to do |wants|
397
417
  wants.html { redirect_to hyrax.my_works_path, notice: "Deleted #{title}" }
@@ -432,7 +452,7 @@ module Hyrax
432
452
  when ActiveFedora::Common
433
453
  curation_concern.file_sets.present?
434
454
  else
435
- Hyrax.custom_queries.find_child_fileset_ids(resource: curation_concern).any?
455
+ Hyrax.custom_queries.find_child_file_set_ids(resource: curation_concern).any?
436
456
  end
437
457
  end
438
458
 
@@ -441,12 +461,16 @@ module Hyrax
441
461
  end
442
462
 
443
463
  def available_admin_sets
464
+ # only returns admin sets in which the user can deposit
444
465
  admin_set_results = Hyrax::AdminSetService.new(self).search_results(:deposit)
466
+
445
467
  # get all the templates at once, reducing query load
446
- templates = PermissionTemplate.where(id: admin_set_results.map(&:id)).to_a
468
+ templates = PermissionTemplate.where(source_id: admin_set_results.map(&:id)).to_a
447
469
 
448
470
  admin_sets = admin_set_results.map do |admin_set_doc|
449
471
  template = templates.find { |temp| temp.source_id == admin_set_doc.id.to_s }
472
+
473
+ # determine if sharing tab should be visible
450
474
  sharing = can?(:manage, template) || !!template&.active_workflow&.allows_access_grant?
451
475
 
452
476
  AdminSetSelectionPresenter::OptionsEntry
@@ -4,7 +4,8 @@ module Hyrax
4
4
  include Hyrax::CollectionsControllerBehavior
5
5
 
6
6
  before_action :authenticate_user!
7
- load_and_authorize_resource
7
+ load_and_authorize_resource instance_name: :admin_set,
8
+ class: Hyrax.config.admin_set_model
8
9
 
9
10
  # Catch permission errors
10
11
  rescue_from Hydra::AccessDenied, CanCan::AccessDenied, with: :deny_adminset_access
@@ -61,28 +62,52 @@ module Hyrax
61
62
  end
62
63
 
63
64
  def update
64
- if @admin_set.update(admin_set_params)
65
- redirect_to update_referer, notice: I18n.t('updated_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
65
+ case @admin_set
66
+ when Valkyrie::Resource
67
+ valkyrie_update
66
68
  else
67
- setup_form
68
- render :edit
69
+ active_fedora_update
69
70
  end
70
71
  end
71
72
 
73
+ def after_create
74
+ Hyrax::SolrService.commit
75
+ redirect_to hyrax.edit_admin_admin_set_path(admin_set_id),
76
+ notice: I18n.t('new_admin_set',
77
+ scope: 'hyrax.admin.admin_sets.form.permission_update_notices',
78
+ name: @admin_set.title.first)
79
+ end
80
+
81
+ def after_create_error(err_msg: "")
82
+ msg = "Failed to create admin set: #{err_msg}"
83
+ setup_form
84
+ flash[:error] = msg
85
+ Hyrax.logger.error(msg)
86
+ render :new
87
+ end
88
+
72
89
  def create
73
- if create_admin_set
74
- redirect_to hyrax.edit_admin_admin_set_path(@admin_set), notice: I18n.t('new_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
90
+ case @admin_set
91
+ when Valkyrie::Resource
92
+ valkyrie_create
75
93
  else
76
- setup_form
77
- render :new
94
+ active_fedora_create
78
95
  end
79
96
  end
80
97
 
81
98
  def destroy
82
- if @admin_set.destroy
99
+ case @admin_set
100
+ when Valkyrie::Resource
101
+ transactions['admin_set_resource.destroy'].call(@admin_set).value_or do |failure|
102
+ redirect_to hyrax.admin_admin_set_path(admin_set_id), alert: failure.first
103
+ end
83
104
  after_delete_success
84
105
  else
85
- redirect_to hyrax.admin_admin_set_path(@admin_set), alert: @admin_set.errors.full_messages.to_sentence
106
+ if @admin_set.destroy
107
+ after_delete_success
108
+ else
109
+ redirect_to hyrax.admin_admin_set_path(admin_set_id), alert: @admin_set.errors.full_messages.to_sentence
110
+ end
86
111
  end
87
112
  end
88
113
 
@@ -98,12 +123,50 @@ module Hyrax
98
123
 
99
124
  private
100
125
 
101
- def update_referer
102
- hyrax.edit_admin_admin_set_path(@admin_set) + (params[:referer_anchor] || '')
126
+ def valkyrie_update
127
+ @admin_set = form.validate(admin_set_params) && transactions['admin_set_resource.update'].call(form).value_or do |_failure|
128
+ setup_form # probably should do some real error handling here
129
+ render :edit
130
+ end
131
+ redirect_to update_referer, notice: I18n.t('updated_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
132
+ end
133
+
134
+ def active_fedora_update
135
+ if @admin_set.update(admin_set_params)
136
+ redirect_to update_referer, notice: I18n.t('updated_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
137
+ else
138
+ setup_form
139
+ render :edit
140
+ end
103
141
  end
104
142
 
105
- def create_admin_set
106
- admin_set_create_service.call(admin_set: @admin_set, creating_user: current_user)
143
+ def update_referer
144
+ hyrax.edit_admin_admin_set_path(admin_set_id) + (params[:referer_anchor] || '')
145
+ end
146
+
147
+ def valkyrie_create
148
+ form.validate(admin_set_params) &&
149
+ @admin_set = transactions['change_set.create_admin_set']
150
+ .with_step_args(
151
+ 'change_set.set_user_as_creator' => { user: current_user },
152
+ 'admin_set_resource.apply_collection_type_permissions' => { user: current_user }
153
+ )
154
+ .call(form).value_or do |_failure|
155
+ setup_form # probably should do some real error handling here
156
+ render :edit
157
+ end
158
+ @admin_set = admin_set_create_service.call!(admin_set: @admin_set, creating_user: current_user)
159
+ after_create
160
+ rescue RuntimeError => err
161
+ after_create_error(err_msg: err.message)
162
+ end
163
+
164
+ def active_fedora_create
165
+ updated_admin_set = admin_set_create_service.call!(admin_set: admin_set_resource, creating_user: current_user)
166
+ @admin_set = Wings::ActiveFedoraConverter.convert(resource: updated_admin_set)
167
+ after_create
168
+ rescue RuntimeError => err
169
+ after_create_error(err_msg: err.message)
107
170
  end
108
171
 
109
172
  def setup_form
@@ -116,7 +179,13 @@ module Hyrax
116
179
 
117
180
  # initialize the form object
118
181
  def form
119
- @form ||= form_class.new(@admin_set, current_ability, repository)
182
+ @form ||=
183
+ case @admin_set
184
+ when Valkyrie::Resource
185
+ Hyrax::Forms::ResourceForm.for(@admin_set)
186
+ else
187
+ form_class.new(@admin_set, current_ability, repository)
188
+ end
120
189
  end
121
190
 
122
191
  def action_breadcrumb
@@ -129,7 +198,11 @@ module Hyrax
129
198
  end
130
199
 
131
200
  def admin_set_params
132
- form_class.model_attributes(params[:admin_set])
201
+ if Hyrax.config.admin_set_class < ActiveFedora::Base
202
+ form_class.model_attributes(params[:admin_set])
203
+ else
204
+ params.permit(admin_set: {})[:admin_set]
205
+ end
133
206
  end
134
207
 
135
208
  def repository_class
@@ -137,13 +210,26 @@ module Hyrax
137
210
  end
138
211
 
139
212
  def after_delete_success
140
- if request.referer.include? "my/collections"
213
+ if request.referer&.include? "my/collections"
141
214
  redirect_to hyrax.my_collections_path, notice: t(:'hyrax.admin.admin_sets.delete.notification')
142
- elsif request.referer.include? "collections"
215
+ elsif request.referer&.include? "collections"
143
216
  redirect_to hyrax.dashboard_collections_path, notice: t(:'hyrax.admin.admin_sets.delete.notification')
144
217
  else
145
218
  redirect_to hyrax.my_collections_path, notice: t(:'hyrax.admin.admin_sets.delete.notification')
146
219
  end
147
220
  end
221
+
222
+ def admin_set_id
223
+ @admin_set&.id&.to_s
224
+ end
225
+
226
+ def admin_set_resource
227
+ case @admin_set
228
+ when Valkyrie::Resource
229
+ @admin_set
230
+ else
231
+ @admin_set.valkyrie_resource
232
+ end
233
+ end
148
234
  end
149
235
  end
@@ -5,11 +5,11 @@ module Hyrax
5
5
  load_and_authorize_resource class: 'Hyrax::PermissionTemplateAccess'
6
6
 
7
7
  def destroy
8
+ authorize! :destroy, @permission_template_access
8
9
  ActiveRecord::Base.transaction do
9
- @permission_template_access.destroy if valid_delete?
10
+ @permission_template_access.destroy
10
11
  remove_access!
11
12
  end
12
-
13
13
  if @permission_template_access.destroyed?
14
14
  after_destroy_success
15
15
  else
@@ -19,38 +19,31 @@ module Hyrax
19
19
 
20
20
  private
21
21
 
22
- # This is a controller validation rather than a model validation
23
- # because we don't want to prevent the ability to remove the whole
24
- # PermissionTemplate and all of its associated PermissionTemplateAccesses
25
- # @return [Boolean] true if it's valid
26
- def valid_delete?
27
- return true unless @permission_template_access.admin_group?
28
- @permission_template_access.errors[:base] <<
29
- t('hyrax.admin.admin_sets.form.permission_destroy_errors.admin_group')
30
- false
31
- end
32
-
33
- def after_destroy_success
22
+ def after_destroy_error
34
23
  if source.admin_set?
24
+ @permission_template_access.errors[:base] <<
25
+ t('hyrax.admin.admin_sets.form.permission_destroy_errors.participants')
35
26
  redirect_to hyrax.edit_admin_admin_set_path(source_id,
36
27
  anchor: 'participants'),
37
- notice: translate('participants', scope: 'hyrax.admin.admin_sets.form.permission_update_notices')
28
+ alert: @permission_template_access.errors.full_messages.to_sentence
38
29
  else
30
+ @permission_template_access.errors[:base] <<
31
+ t('hyrax.dashboard.collections.form.permission_update_errors.sharing')
39
32
  redirect_to hyrax.edit_dashboard_collection_path(source_id,
40
33
  anchor: 'sharing'),
41
- notice: translate('sharing', scope: 'hyrax.dashboard.collections.form.permission_update_notices')
34
+ alert: @permission_template_access.errors.full_messages.to_sentence
42
35
  end
43
36
  end
44
37
 
45
- def after_destroy_error
38
+ def after_destroy_success
46
39
  if source.admin_set?
47
40
  redirect_to hyrax.edit_admin_admin_set_path(source_id,
48
41
  anchor: 'participants'),
49
- alert: @permission_template_access.errors.full_messages.to_sentence
42
+ notice: translate('participants', scope: 'hyrax.admin.admin_sets.form.permission_update_notices')
50
43
  else
51
44
  redirect_to hyrax.edit_dashboard_collection_path(source_id,
52
45
  anchor: 'sharing'),
53
- alert: @permission_template_access.errors.full_messages.to_sentence
46
+ notice: translate('sharing', scope: 'hyrax.dashboard.collections.form.permission_update_notices')
54
47
  end
55
48
  end
56
49
 
@@ -39,8 +39,11 @@ module Hyrax
39
39
 
40
40
  def destroy_collection
41
41
  batch.each do |doc_id|
42
- obj = Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: doc_id, use_valkyrie: false)
43
- obj.destroy
42
+ resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(doc_id))
43
+ transactions['collection_resource.destroy']
44
+ .with_step_args('collection_resource.delete' => { user: current_user })
45
+ .call(resource)
46
+ .value!
44
47
  end
45
48
  flash[:notice] = "Batch delete complete"
46
49
  after_destroy_collection
@@ -83,7 +86,13 @@ module Hyrax
83
86
  end
84
87
 
85
88
  def destroy_batch
86
- batch.each { |id| Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: id, use_valkyrie: false).destroy }
89
+ batch.each do |id|
90
+ resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(id))
91
+ transactions['work_resource.destroy']
92
+ .with_step_args('work_resource.delete' => { user: current_user })
93
+ .call(resource)
94
+ .value!
95
+ end
87
96
  after_update
88
97
  end
89
98
 
@@ -44,6 +44,10 @@ module Hyrax
44
44
  end
45
45
 
46
46
  def build_form
47
+ add_breadcrumb t('hyrax.controls.home'), root_path
48
+ add_breadcrumb t('hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
49
+ add_breadcrumb t('hyrax.admin.sidebar.works'), hyrax.my_works_path
50
+ add_breadcrumb t('hyrax.batch_uploads.new.breadcrumb'), request.path
47
51
  super
48
52
  @form.payload_concern = params[:payload_concern]
49
53
  end
@@ -2,8 +2,8 @@
2
2
  module Hyrax
3
3
  class CitationsController < ApplicationController
4
4
  include WorksControllerBehavior
5
+ include DenyAccessOverrideBehavior
5
6
  include Breadcrumbs
6
- include SingularSubresourceController
7
7
 
8
8
  # Overrides decide_layout from WorksControllerBehavior
9
9
  with_themed_layout '1_column'