hyrax 3.0.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (287) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +46 -13
  3. data/.dassie/Gemfile +11 -6
  4. data/.dassie/app/controllers/catalog_controller.rb +6 -0
  5. data/.dassie/config/initializers/hyrax.rb +5 -0
  6. data/.dassie/config/initializers/riiif.rb +22 -20
  7. data/.dassie/config/role_map.yml +2 -0
  8. data/.dassie/db/seeds.rb +1 -1
  9. data/.dassie/package.json +3 -5
  10. data/.dockerignore +3 -0
  11. data/.env +1 -2
  12. data/.rubocop.yml +4 -0
  13. data/CONTAINERS.md +21 -1
  14. data/Dockerfile +42 -17
  15. data/Gemfile +21 -27
  16. data/app/actors/hyrax/actors/base_actor.rb +2 -2
  17. data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -3
  18. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
  19. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
  20. data/app/actors/hyrax/actors/file_set_actor.rb +12 -5
  21. data/app/assets/stylesheets/hyrax/_styles.scss +5 -0
  22. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +30 -10
  23. data/app/controllers/concerns/hyrax/controller.rb +13 -2
  24. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
  25. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
  26. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
  27. data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -19
  28. data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +5 -6
  29. data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
  30. data/app/controllers/hyrax/collections_controller.rb +3 -1
  31. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +24 -17
  32. data/app/controllers/hyrax/dashboard/collections_controller.rb +99 -35
  33. data/app/controllers/hyrax/dashboard/nest_collections_controller.rb +75 -39
  34. data/app/controllers/hyrax/file_sets_controller.rb +49 -13
  35. data/app/controllers/hyrax/my_controller.rb +4 -4
  36. data/app/controllers/hyrax/permissions_controller.rb +3 -4
  37. data/app/controllers/hyrax/workflow_actions_controller.rb +11 -6
  38. data/app/forms/hyrax/forms/administrative_set_form.rb +62 -0
  39. data/app/forms/hyrax/forms/collection_form.rb +14 -8
  40. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +38 -6
  41. data/app/forms/hyrax/forms/file_set_form.rb +46 -0
  42. data/app/forms/hyrax/forms/pcdm_collection_form.rb +64 -0
  43. data/app/forms/hyrax/forms/permission.rb +23 -0
  44. data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
  45. data/app/forms/hyrax/forms/resource_form.rb +34 -26
  46. data/app/forms/hyrax/forms/work_form.rb +5 -2
  47. data/app/forms/hyrax/forms/workflow_action_form.rb +4 -0
  48. data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
  49. data/app/helpers/hyrax/collections_helper.rb +88 -2
  50. data/app/helpers/hyrax/dashboard_helper_behavior.rb +16 -5
  51. data/app/helpers/hyrax/embargo_helper.rb +4 -0
  52. data/app/helpers/hyrax/file_set_helper.rb +25 -6
  53. data/app/helpers/hyrax/hyrax_helper_behavior.rb +9 -0
  54. data/app/helpers/hyrax/lease_helper.rb +4 -0
  55. data/app/helpers/hyrax/url_helper.rb +4 -1
  56. data/app/helpers/hyrax/work_form_helper.rb +53 -0
  57. data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
  58. data/app/indexers/hyrax/pcdm_collection_indexer.rb +2 -0
  59. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +2 -0
  60. data/app/indexers/hyrax/valkyrie_indexer.rb +4 -3
  61. data/app/indexers/hyrax/valkyrie_work_indexer.rb +1 -1
  62. data/app/inputs/controlled_vocabulary_input.rb +2 -5
  63. data/app/jobs/attach_files_to_work_job.rb +19 -10
  64. data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
  65. data/app/jobs/ingest_local_file_job.rb +18 -2
  66. data/app/jobs/inherit_permissions_job.rb +9 -5
  67. data/app/models/admin_set.rb +22 -30
  68. data/app/models/collection_branding_info.rb +25 -9
  69. data/app/models/concerns/hyrax/ability/admin_set_ability.rb +31 -7
  70. data/app/models/concerns/hyrax/ability/collection_ability.rb +35 -20
  71. data/app/models/concerns/hyrax/ability/collection_type_ability.rb +1 -1
  72. data/app/models/concerns/hyrax/ability.rb +5 -3
  73. data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
  74. data/app/models/concerns/hyrax/embargoable.rb +24 -0
  75. data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
  76. data/app/models/concerns/hyrax/solr_document_behavior.rb +11 -54
  77. data/app/models/concerns/hyrax/suppressible.rb +5 -0
  78. data/app/models/concerns/hyrax/user.rb +9 -3
  79. data/app/models/concerns/hyrax/work_behavior.rb +1 -1
  80. data/app/models/hyrax/administrative_set.rb +7 -1
  81. data/app/models/hyrax/file_set.rb +6 -0
  82. data/app/models/hyrax/pcdm_collection.rb +1 -0
  83. data/app/models/hyrax/permission.rb +1 -1
  84. data/app/models/hyrax/permission_template.rb +112 -12
  85. data/app/models/hyrax/virus_scanner.rb +27 -18
  86. data/app/models/hyrax/work.rb +1 -0
  87. data/app/models/hyrax/workflow_action_info.rb +16 -0
  88. data/app/models/sipity/agent.rb +1 -0
  89. data/app/models/sipity/comment.rb +17 -0
  90. data/app/models/sipity/entity.rb +30 -8
  91. data/app/models/sipity/workflow.rb +1 -0
  92. data/app/models/sipity.rb +53 -2
  93. data/app/presenters/hyrax/admin_set_options_presenter.rb +12 -8
  94. data/app/presenters/hyrax/admin_set_presenter.rb +13 -4
  95. data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
  96. data/app/presenters/hyrax/collection_presenter.rb +44 -23
  97. data/app/presenters/hyrax/file_set_presenter.rb +6 -1
  98. data/app/presenters/hyrax/file_usage.rb +3 -2
  99. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +119 -0
  100. data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
  101. data/app/presenters/hyrax/trophy_presenter.rb +33 -4
  102. data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
  103. data/app/presenters/hyrax/version_list_presenter.rb +19 -0
  104. data/app/presenters/hyrax/version_presenter.rb +3 -2
  105. data/app/presenters/hyrax/work_show_presenter.rb +32 -6
  106. data/app/presenters/hyrax/work_usage.rb +5 -3
  107. data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
  108. data/app/search_builders/hyrax/abstract_type_relation.rb +4 -2
  109. data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
  110. data/app/search_builders/hyrax/collection_member_search_builder.rb +6 -1
  111. data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +1 -1
  112. data/app/search_builders/hyrax/exposed_models_relation.rb +1 -1
  113. data/app/search_builders/hyrax/filter_by_type.rb +1 -2
  114. data/app/search_builders/hyrax/my/collections_search_builder.rb +2 -2
  115. data/app/search_builders/hyrax/nested_collections_parent_search_builder.rb +1 -1
  116. data/app/search_builders/hyrax/single_collection_search_builder.rb +1 -1
  117. data/app/services/hyrax/admin_set_create_service.rb +136 -52
  118. data/app/services/hyrax/collection_types/permissions_service.rb +1 -1
  119. data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
  120. data/app/services/hyrax/collections/collection_member_service.rb +122 -27
  121. data/app/services/hyrax/collections/migration_service.rb +4 -2
  122. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
  123. data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
  124. data/app/services/hyrax/collections/permissions_create_service.rb +82 -78
  125. data/app/services/hyrax/collections/permissions_service.rb +1 -1
  126. data/app/services/hyrax/contextual_path.rb +24 -1
  127. data/app/services/hyrax/curation_concern.rb +24 -2
  128. data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
  129. data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
  130. data/app/services/hyrax/default_middleware_stack.rb +11 -0
  131. data/app/services/hyrax/edit_permissions_service.rb +74 -41
  132. data/app/services/hyrax/ensure_well_formed_admin_set_service.rb +3 -3
  133. data/app/services/hyrax/find_objects_via_solr_service.rb +31 -0
  134. data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +1 -0
  135. data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -0
  136. data/app/services/hyrax/listeners/metadata_index_listener.rb +25 -9
  137. data/app/services/hyrax/listeners/object_lifecycle_listener.rb +1 -1
  138. data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +17 -0
  139. data/app/services/hyrax/listeners.rb +2 -0
  140. data/app/services/hyrax/multiple_membership_checker.rb +53 -29
  141. data/app/services/hyrax/permission_manager.rb +4 -4
  142. data/app/services/hyrax/persist_derivatives.rb +3 -1
  143. data/app/services/hyrax/resource_status.rb +7 -0
  144. data/app/services/hyrax/search_service.rb +4 -2
  145. data/app/services/hyrax/solr_query_builder_service.rb +45 -8
  146. data/app/services/hyrax/solr_query_service.rb +224 -0
  147. data/app/services/hyrax/solr_service.rb +9 -2
  148. data/app/services/hyrax/statistics/collections/over_time.rb +2 -1
  149. data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
  150. data/app/services/hyrax/thumbnail_path_service.rb +1 -1
  151. data/app/services/hyrax/visibility_intention.rb +20 -2
  152. data/app/services/hyrax/visibility_propagator.rb +30 -1
  153. data/app/services/hyrax/work_uploads_handler.rb +17 -2
  154. data/app/services/hyrax/workflow/abstract_notification.rb +2 -2
  155. data/app/services/hyrax/workflow/action_taken_service.rb +16 -4
  156. data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
  157. data/app/services/hyrax/workflow/activate_object.rb +5 -4
  158. data/app/services/hyrax/workflow/changes_required_notification.rb +5 -4
  159. data/app/services/hyrax/workflow/deactivate_object.rb +7 -5
  160. data/app/services/hyrax/workflow/deposited_notification.rb +8 -4
  161. data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +7 -3
  162. data/app/services/hyrax/workflow/grant_read_to_depositor.rb +10 -3
  163. data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
  164. data/app/services/hyrax/workflow/revoke_edit_from_depositor.rb +8 -2
  165. data/app/services/hyrax/workflow/status_list_service.rb +43 -13
  166. data/app/services/hyrax/workflow/workflow_action_service.rb +4 -1
  167. data/app/views/hyrax/admin/admin_sets/_form.html.erb +1 -1
  168. data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
  169. data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
  170. data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
  171. data/app/views/hyrax/base/_form_representative.html.erb +1 -1
  172. data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
  173. data/app/views/hyrax/base/_form_visibility_error.html.erb +2 -0
  174. data/app/views/hyrax/base/_guts4form.html.erb +3 -3
  175. data/app/views/hyrax/base/_representative_media.html.erb +1 -1
  176. data/app/views/hyrax/base/_show_actions.html.erb +2 -2
  177. data/app/views/hyrax/base/_work_button_row.html.erb +1 -1
  178. data/app/views/hyrax/batch_uploads/_form.html.erb +1 -1
  179. data/app/views/hyrax/collections/show.html.erb +1 -1
  180. data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +1 -1
  181. data/app/views/hyrax/dashboard/collections/_form.html.erb +4 -4
  182. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -1
  183. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  184. data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +1 -1
  185. data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
  186. data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
  187. data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
  188. data/app/views/hyrax/file_sets/_actions.html.erb +10 -0
  189. data/app/views/hyrax/file_sets/edit.html.erb +1 -1
  190. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  191. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  192. data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
  193. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
  194. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
  195. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  196. data/app/views/hyrax/file_sets/show.html.erb +1 -1
  197. data/app/views/hyrax/homepage/index.html.erb +1 -1
  198. data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
  199. data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
  200. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  201. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
  202. data/app/views/hyrax/my/collections/_modal_collection_types_to_create.html.erb +1 -1
  203. data/app/views/layouts/hyrax/dashboard.html.erb +1 -0
  204. data/app/views/layouts/hyrax.html.erb +1 -0
  205. data/app/views/shared/_read_only.html.erb +5 -0
  206. data/bin/db-migrate-seed.sh +3 -1
  207. data/bin/hyrax-entrypoint.sh +0 -14
  208. data/bin/solrcloud-assign-configset.sh +11 -3
  209. data/bin/solrcloud-upload-configset.sh +17 -6
  210. data/chart/hyrax/Chart.yaml +9 -5
  211. data/chart/hyrax/README.md +52 -5
  212. data/chart/hyrax/templates/_helpers.tpl +23 -1
  213. data/chart/hyrax/templates/branding-pvc.yaml +14 -0
  214. data/chart/hyrax/templates/configmap-env.yaml +14 -3
  215. data/chart/hyrax/templates/deployment-worker.yaml +129 -0
  216. data/chart/hyrax/templates/deployment.yaml +95 -0
  217. data/chart/hyrax/templates/derivatives-pvc.yaml +14 -0
  218. data/chart/hyrax/templates/ingress.yaml +13 -4
  219. data/chart/hyrax/templates/secrets.yaml +9 -0
  220. data/chart/hyrax/templates/uploads-pvc.yaml +14 -0
  221. data/chart/hyrax/values.yaml +114 -1
  222. data/config/brakeman.ignore +2 -2
  223. data/config/features.rb +50 -43
  224. data/config/initializers/1_healthz.rb +1 -0
  225. data/config/initializers/listeners.rb +4 -1
  226. data/config/initializers/valkryrie_storage.rb +7 -0
  227. data/config/locales/hyrax.de.yml +1 -1
  228. data/config/locales/hyrax.en.yml +2 -1
  229. data/config/locales/hyrax.es.yml +1 -1
  230. data/config/locales/hyrax.fr.yml +1 -1
  231. data/config/locales/hyrax.it.yml +1 -1
  232. data/config/locales/hyrax.pt-BR.yml +1 -1
  233. data/config/locales/hyrax.zh.yml +1 -1
  234. data/db/seeds.rb +1 -1
  235. data/docker-compose.yml +39 -8
  236. data/documentation/developing-your-hyrax-based-app.md +3 -3
  237. data/documentation/legacyREADME.md +3 -3
  238. data/hyrax.gemspec +1 -1
  239. data/lib/generators/hyrax/templates/catalog_controller.rb +3 -1
  240. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +15 -0
  241. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +22 -20
  242. data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +1 -1
  243. data/lib/generators/hyrax/work_resource/templates/indexer_spec.rb.erb +1 -0
  244. data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
  245. data/lib/hyrax/collection_name.rb +6 -2
  246. data/lib/hyrax/configuration.rb +56 -0
  247. data/lib/hyrax/engine.rb +3 -1
  248. data/lib/hyrax/errors.rb +2 -0
  249. data/lib/hyrax/form_fields.rb +1 -0
  250. data/lib/hyrax/publisher.rb +12 -0
  251. data/lib/hyrax/resource_name.rb +1 -0
  252. data/lib/hyrax/resource_sync/change_list_writer.rb +2 -2
  253. data/lib/hyrax/resource_sync/resource_list_writer.rb +2 -2
  254. data/lib/hyrax/specs/capybara.rb +5 -3
  255. data/lib/hyrax/specs/shared_specs/hydra_works.rb +2 -0
  256. data/lib/hyrax/specs/shared_specs/indexers.rb +6 -0
  257. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
  258. data/lib/hyrax/transactions/collection_create.rb +25 -0
  259. data/lib/hyrax/transactions/collection_update.rb +20 -0
  260. data/lib/hyrax/transactions/container.rb +47 -0
  261. data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
  262. data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
  263. data/lib/hyrax/transactions/steps/add_to_collections.rb +13 -1
  264. data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
  265. data/lib/hyrax/transactions/steps/apply_collection_type_permissions.rb +29 -0
  266. data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
  267. data/lib/hyrax/transactions/steps/save.rb +18 -6
  268. data/lib/hyrax/transactions/steps/set_collection_type_gid.rb +35 -0
  269. data/lib/hyrax/transactions/work_create.rb +2 -1
  270. data/lib/hyrax/valkyrie_can_can_adapter.rb +3 -0
  271. data/lib/hyrax/valkyrie_simple_path_generator.rb +20 -0
  272. data/lib/hyrax/version.rb +1 -1
  273. data/lib/hyrax.rb +9 -0
  274. data/lib/tasks/collection_type_global_id.rake +1 -1
  275. data/lib/tasks/default_admin_set.rake +12 -11
  276. data/lib/tasks/regenerate_derivatives.rake +12 -0
  277. data/lib/wings/active_fedora_converter/default_work.rb +15 -0
  278. data/lib/wings/converter_value_mapper.rb +2 -2
  279. data/lib/wings/model_transformer.rb +17 -1
  280. data/lib/wings/orm_converter.rb +18 -2
  281. data/lib/wings/setup.rb +2 -0
  282. data/lib/wings/valkyrie/persister.rb +7 -5
  283. data/lib/wings/valkyrie/query_service.rb +60 -17
  284. data/lib/wings/valkyrie/storage.rb +56 -1
  285. data/lib/wings.rb +0 -21
  286. data/template.rb +1 -1
  287. metadata +42 -9
@@ -1,6 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
3
  class WorkflowActionsController < ApplicationController
4
+ DEFAULT_FORM_CLASS = Hyrax::Forms::WorkflowActionForm
5
+
6
+ ##
7
+ # @!attribute [r] curation_concern
8
+ # @api private
9
+ # @return [Hyrax::Resource]
10
+ attr_reader :curation_concern
11
+
12
+ load_resource class: Hyrax::Resource, instance_name: :curation_concern
4
13
  before_action :authenticate_user!
5
14
 
6
15
  def update
@@ -9,19 +18,15 @@ module Hyrax
9
18
  else
10
19
  respond_to do |wants|
11
20
  wants.html { render 'hyrax/base/unauthorized', status: :unauthorized }
12
- wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
21
+ wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: workflow_action_form.errors }) }
13
22
  end
14
23
  end
15
24
  end
16
25
 
17
26
  private
18
27
 
19
- def curation_concern
20
- @curation_concern ||= Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: params[:id], use_valkyrie: false)
21
- end
22
-
23
28
  def workflow_action_form
24
- @workflow_action_form ||= Hyrax::Forms::WorkflowActionForm.new(
29
+ @workflow_action_form ||= DEFAULT_FORM_CLASS.new(
25
30
  current_ability: current_ability,
26
31
  work: curation_concern,
27
32
  attributes: workflow_action_params
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Forms
5
+ ##
6
+ # @api public
7
+ # @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
8
+ class AdministrativeSetForm < Valkyrie::ChangeSet
9
+ property :title, required: true, primary: true
10
+ property :description, primary: true
11
+
12
+ property :human_readable_type, writable: false
13
+ property :date_modified, readable: false
14
+ property :date_uploaded, readable: false
15
+
16
+ property :depositor
17
+
18
+ class << self
19
+ def model_class
20
+ Hyrax::AdministrativeSet
21
+ end
22
+
23
+ ##
24
+ # @return [Array<Symbol>] list of required field names as symbols
25
+ def required_fields
26
+ definitions
27
+ .select { |_, definition| definition[:required] }
28
+ .keys.map(&:to_sym)
29
+ end
30
+ end
31
+
32
+ ##
33
+ # @return [Array<Symbol>] terms for display 'above-the-fold', or in the most
34
+ # prominent form real estate
35
+ def primary_terms
36
+ _form_field_definitions
37
+ .select { |_, definition| definition[:primary] }
38
+ .keys.map(&:to_sym)
39
+ end
40
+
41
+ ##
42
+ # @return [Array<Symbol>] terms for display 'below-the-fold'
43
+ def secondary_terms
44
+ _form_field_definitions
45
+ .select { |_, definition| definition[:display] && !definition[:primary] }
46
+ .keys.map(&:to_sym)
47
+ end
48
+
49
+ ##
50
+ # @return [Boolean] whether there are terms to display 'below-the-fold'
51
+ def display_additional_fields?
52
+ secondary_terms.any?
53
+ end
54
+
55
+ private
56
+
57
+ def _form_field_definitions
58
+ self.class.definitions
59
+ end
60
+ end
61
+ end
62
+ end
@@ -16,9 +16,9 @@ module Hyrax
16
16
  # Required for search builder (FIXME)
17
17
  alias collection model
18
18
 
19
- self.model_class = ::Collection
19
+ self.model_class = Hyrax.config.collection_class
20
20
 
21
- self.membership_service_class = Collections::CollectionMemberService
21
+ self.membership_service_class = Collections::CollectionMemberSearchService
22
22
 
23
23
  delegate :blacklight_config, to: Hyrax::CollectionsController
24
24
 
@@ -80,18 +80,20 @@ module Hyrax
80
80
  def banner_info
81
81
  @banner_info ||= begin
82
82
  # Find Banner filename
83
- banner_info = CollectionBrandingInfo.where(collection_id: id).where(role: "banner")
83
+ banner_info = CollectionBrandingInfo.where(collection_id: id, role: "banner")
84
84
  banner_file = File.split(banner_info.first.local_path).last unless banner_info.empty?
85
+ alttext = banner_info.first.alt_text unless banner_info.empty?
85
86
  file_location = banner_info.first.local_path unless banner_info.empty?
86
87
  relative_path = "/" + banner_info.first.local_path.split("/")[-4..-1].join("/") unless banner_info.empty?
87
- { file: banner_file, full_path: file_location, relative_path: relative_path }
88
+ { file: banner_file, full_path: file_location, relative_path: relative_path, alttext: alttext }
88
89
  end
89
90
  end
90
91
 
91
92
  def logo_info
92
93
  @logo_info ||= begin
93
94
  # Find Logo filename, alttext, linktext
94
- logos_info = CollectionBrandingInfo.where(collection_id: id).where(role: "logo")
95
+ logos_info = CollectionBrandingInfo.where(collection_id: id, role: "logo")
96
+
95
97
  logos_info.map do |logo_info|
96
98
  logo_file = File.split(logo_info.local_path).last
97
99
  relative_path = "/" + logo_info.local_path.split("/")[-4..-1].join("/")
@@ -121,15 +123,19 @@ module Hyrax
121
123
  collection_member_service.available_member_subcollections.documents
122
124
  end
123
125
 
126
+ ##
127
+ # @deprecated this implementation requires an extra db round trip, had a
128
+ # buggy cacheing mechanism, and was largely duplicative of other code.
129
+ # all versions of this code are replaced by
130
+ # {CollectionsHelper#available_parent_collections_data}.
124
131
  def available_parent_collections(scope:)
125
132
  return @available_parents if @available_parents.present?
126
133
 
127
- collection = ::Collection.find(id)
134
+ collection = model_class.find(id)
128
135
  colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
129
136
  @available_parents = colls.map do |col|
130
137
  { "id" => col.id, "title_first" => col.title.first }
131
- end
132
- @available_parents.to_json
138
+ end.to_json
133
139
  end
134
140
 
135
141
  private
@@ -10,18 +10,28 @@ module Hyrax
10
10
  self.default_query_service = Hyrax::Collections::NestedCollectionQueryService
11
11
  self.default_persistence_service = Hyrax::Collections::NestedCollectionPersistenceService
12
12
 
13
+ ##
13
14
  # @param parent [::Collection, NilClass]
14
15
  # @param child [::Collection, NilClass]
16
+ # @param parent_id [String, nil]
17
+ # @param child_id [String, nil]
15
18
  # @param context [#can?,#repository,#blacklight_config]
16
19
  # @param query_service [Hyrax::Collections::NestedCollectionQueryService]
17
20
  # @param persistence_service [Hyrax::Collections::NestedCollectionPersistenceService] responsible for persisting the parent/child relationship
18
- def initialize(parent: nil, child: nil, context:, query_service: default_query_service, persistence_service: default_persistence_service)
19
- self.parent = parent
20
- self.child = child
21
+ # rubocop:disable Metrics/ParameterLists
22
+ def initialize(parent: nil,
23
+ child: nil,
24
+ parent_id: nil,
25
+ child_id: nil,
26
+ context:,
27
+ query_service: default_query_service,
28
+ persistence_service: default_persistence_service)
29
+ self.parent = parent || (parent_id.present? && Hyrax.config.collection_class.find(parent_id))
30
+ self.child = child || (child_id.present? && Hyrax.config.collection_class.find(child_id))
21
31
  self.context = context
22
32
  self.query_service = query_service
23
33
  self.persistence_service = persistence_service
24
- end
34
+ end # rubocop:enable Metrics/ParameterLists
25
35
 
26
36
  attr_accessor :parent, :child
27
37
 
@@ -32,18 +42,40 @@ module Hyrax
32
42
 
33
43
  def save
34
44
  return false unless valid?
35
- persistence_service.persist_nested_collection_for(parent: parent, child: child)
45
+ persistence_service.persist_nested_collection_for(parent: parent, child: child, user: context.current_user)
36
46
  end
37
47
 
48
+ ##
49
+ # @deprecated this method is unused by hyrax, and is effectively a
50
+ # delegation to `Hyrax::Collections::NestedCollectionQueryService`.
51
+ # if you want to be sure to use nested indexing to generate this list,
52
+ # use the query service directly.
53
+ #
38
54
  # For the given parent, what are all of the available collections that
39
55
  # can be added as sub-collection of the parent.
40
56
  def available_child_collections
57
+ Deprecation.warn "#{self.class}#available_child_collections " \
58
+ "is deprecated. the helper of the same name or " \
59
+ "Hyrax::Collections::NestedCollectionQueryService " \
60
+ "instead."
61
+
41
62
  query_service.available_child_collections(parent: parent, scope: context)
42
63
  end
43
64
 
65
+ ##
66
+ # @deprecated this method is unused by hyrax, and is effectively a
67
+ # delegation to `Hyrax::Collections::NestedCollectionQueryService`.
68
+ # if you want to be sure to use nested indexing to generate this list,
69
+ # use the query service directly.
70
+ #
44
71
  # For the given child, what are all of the available collections to
45
72
  # which the child can be added as a sub-collection.
46
73
  def available_parent_collections
74
+ Deprecation.warn "#{self.class}#available_parent_collections " \
75
+ "is deprecated. the helper of the same name or " \
76
+ "Hyrax::Collections::NestedCollectionQueryService " \
77
+ "instead."
78
+
47
79
  query_service.available_parent_collections(child: child, scope: context)
48
80
  end
49
81
 
@@ -61,7 +93,7 @@ module Hyrax
61
93
 
62
94
  def remove
63
95
  if context.can? :edit, parent
64
- persistence_service.remove_nested_relationship_for(parent: parent, child: child)
96
+ persistence_service.remove_nested_relationship_for(parent: parent, child: child, user: context.current_user)
65
97
  else
66
98
  errors.add(:parent, :cannot_remove_relationship)
67
99
  false
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Forms
5
+ ##
6
+ # @api public
7
+ class FileSetForm < Hyrax::ChangeSet
8
+ include Hyrax::FormFields(:core_metadata)
9
+
10
+ class << self
11
+ ##
12
+ # @return [Array<Symbol>] list of required field names as symbols
13
+ def required_fields
14
+ definitions
15
+ .select { |_, definition| definition[:required] }
16
+ .keys.map(&:to_sym)
17
+ end
18
+ end
19
+
20
+ property :creator, required: true
21
+ property :license, required: true
22
+
23
+ property :based_near
24
+ property :contributor
25
+ property :date_created
26
+ property :description
27
+ property :identifier
28
+ property :keyword
29
+ property :language
30
+ property :publisher
31
+ property :related_url
32
+ property :subject
33
+
34
+ property :permissions, virtual: true
35
+ property :visibility, default: VisibilityIntention::PRIVATE
36
+
37
+ # virtual properties for embargo/lease;
38
+ property :embargo_release_date, virtual: true
39
+ property :visibility_after_embargo, virtual: true
40
+ property :visibility_during_embargo, virtual: true
41
+ property :lease_expiration_date, virtual: true
42
+ property :visibility_after_lease, virtual: true
43
+ property :visibility_during_lease, virtual: true
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Forms
5
+ ##
6
+ # @api public
7
+ # @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
8
+ class PcdmCollectionForm < Valkyrie::ChangeSet # rubocop:disable Metrics/ClassLength
9
+ property :title, required: true, primary: true
10
+
11
+ property :human_readable_type, writable: false
12
+ property :date_modified, readable: false
13
+ property :date_uploaded, readable: false
14
+
15
+ property :depositor, required: true
16
+ property :collection_type_gid, required: true
17
+
18
+ property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
19
+
20
+ class << self
21
+ def model_class
22
+ Hyrax::PcdmCollection
23
+ end
24
+
25
+ ##
26
+ # @return [Array<Symbol>] list of required field names as symbols
27
+ def required_fields
28
+ definitions
29
+ .select { |_, definition| definition[:required] }
30
+ .keys.map(&:to_sym)
31
+ end
32
+ end
33
+
34
+ ##
35
+ # @return [Array<Symbol>] terms for display 'above-the-fold', or in the most
36
+ # prominent form real estate
37
+ def primary_terms
38
+ _form_field_definitions
39
+ .select { |_, definition| definition[:primary] }
40
+ .keys.map(&:to_sym)
41
+ end
42
+
43
+ ##
44
+ # @return [Array<Symbol>] terms for display 'below-the-fold'
45
+ def secondary_terms
46
+ _form_field_definitions
47
+ .select { |_, definition| definition[:display] && !definition[:primary] }
48
+ .keys.map(&:to_sym)
49
+ end
50
+
51
+ ##
52
+ # @return [Boolean] whether there are terms to display 'below-the-fold'
53
+ def display_additional_fields?
54
+ secondary_terms.any?
55
+ end
56
+
57
+ private
58
+
59
+ def _form_field_definitions
60
+ self.class.definitions
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module Forms
4
+ ##
5
+ # Nested form for permissions.
6
+ #
7
+ # @note due to historical oddities with Hydra::AccessControls and Hydra
8
+ # Editor, Hyrax's views rely on `agent_name` and `access` as field
9
+ # names. we provide these as virtual fields and prepopulate these from
10
+ # `Hyrax::Permission`.
11
+ class Permission < Hyrax::ChangeSet
12
+ property :agent_name, virtual: true, prepopulator: ->(_opts) { self.agent_name = model.agent }
13
+ property :access, virtual: true, prepopulator: ->(_opts) { self.access = model.mode }
14
+
15
+ ##
16
+ # @note support a {#to_hash} method for compatibility with
17
+ # {Hydra::AccessControl::Permissions}
18
+ def to_hash
19
+ { name: agent_name, access: access }
20
+ end
21
+ end
22
+ end
23
+ end
@@ -12,7 +12,13 @@ module Hyrax
12
12
  # @return [#to_s] the primary key of the associated admin_set or collection
13
13
  # def source_id (because you might come looking for this method)
14
14
  delegate :id, to: :source_model, prefix: :source
15
- delegate :reset_access_controls!, to: :source_model
15
+
16
+ ##
17
+ # @deprecated use PermissionTemplate#reset_access_controls instead.
18
+ def reset_access_controls!
19
+ Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
20
+ source_model.reset_access_controls!
21
+ end
16
22
 
17
23
  # Stores which radio button under release "Varies" option is selected
18
24
  attr_accessor :release_varies
@@ -67,7 +73,7 @@ module Hyrax
67
73
  # Copy this access to the permissions of the Admin Set or Collection and to
68
74
  # the WorkflowResponsibilities of the active workflow if this is an Admin Set
69
75
  def update_access(remove_agent: false)
70
- reset_access_controls!
76
+ source_model.reset_access_controls!
71
77
  update_workflow_responsibilities(remove_agent: remove_agent) if source_model.is_a?(AdminSet)
72
78
  end
73
79
 
@@ -30,19 +30,7 @@ module Hyrax
30
30
  # @api public
31
31
  #
32
32
  # This form wraps `Hyrax::ChangeSet` in the `HydraEditor::Form` interface.
33
- class ResourceForm < Hyrax::ChangeSet
34
- ##
35
- # Nested form for permissions.
36
- #
37
- # @note due to historical oddities with Hydra::AccessControls and Hydra
38
- # Editor, Hyrax's views rely on `agent_name` and `access` as field
39
- # names. we provide these as virtual fields and prepopulate these from
40
- # `Hyrax::Permission`.
41
- class Permission < Hyrax::ChangeSet
42
- property :agent_name, virtual: true, prepopulator: ->(_opts) { self.agent_name = model.agent }
43
- property :access, virtual: true, prepopulator: ->(_opts) { self.access = model.mode }
44
- end
45
-
33
+ class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength
46
34
  ##
47
35
  # @api private
48
36
  InWorksPopulator = lambda do |_options|
@@ -65,16 +53,15 @@ module Hyrax
65
53
  # we want to move away from application side lock validation and rely
66
54
  # on the adapter/database features instead.
67
55
  LockKeyPopulator = lambda do |_options|
68
- self.version =
69
- case Hyrax.metadata_adapter
70
- when Wings::Valkyrie::MetadataAdapter
56
+ if Hyrax.config.disable_wings || !Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
57
+ Hyrax.logger.info "trying to prepopulate a lock token for " \
58
+ "#{self.class.inspect}, but optimistic locking isn't " \
59
+ "supported for the configured adapter: #{Hyrax.metadata_adapter.class}"
60
+ self.version = ''
61
+ else
62
+ self.version =
71
63
  model.persisted? ? Wings::ActiveFedoraConverter.convert(resource: model).etag : ''
72
- else
73
- Hyrax.logger.info 'trying to prepopulate a lock token for ' \
74
- "#{self.class.inspect}, but optimistic locking isn't " \
75
- "supported for the configured adapter: #{Hyrax.metadata_adapter.class}"
76
- ''
77
- end
64
+ end
78
65
  end
79
66
 
80
67
  class_attribute :model_class
@@ -91,7 +78,12 @@ module Hyrax
91
78
  property :date_uploaded, readable: false
92
79
  property :agreement_accepted, virtual: true, default: false, prepopulator: ->(_opts) { self.agreement_accepted = !model.new_record }
93
80
 
94
- collection :permissions, virtual: true, default: [], form: Permission, prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions }
81
+ collection(:permissions,
82
+ virtual: true,
83
+ default: [],
84
+ form: Hyrax::Forms::Permission,
85
+ populator: :permission_populator,
86
+ prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions })
95
87
 
96
88
  # virtual properties for embargo/lease;
97
89
  property :embargo_release_date, virtual: true, prepopulator: ->(_opts) { self.embargo_release_date = model.embargo&.embargo_release_date }
@@ -108,6 +100,10 @@ module Hyrax
108
100
  property :member_ids, default: [], type: Valkyrie::Types::Array
109
101
  property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
110
102
 
103
+ property :representative_id, type: Valkyrie::Types::String
104
+ property :thumbnail_id, type: Valkyrie::Types::String
105
+ property :rendering_ids, default: [], type: Valkyrie::Types::Array
106
+
111
107
  # provide a lock token for optimistic locking; we name this `version` for
112
108
  # backwards compatibility
113
109
  #
@@ -131,10 +127,17 @@ module Hyrax
131
127
  # @example
132
128
  # monograph = Monograph.new
133
129
  # change_set = Hyrax::Forms::ResourceForm.for(monograph)
134
- def for(work)
135
- "#{work.class}Form".constantize.new(work)
130
+ def for(resource)
131
+ "#{resource.class.name}Form".constantize.new(resource)
136
132
  rescue NameError => _err
137
- Hyrax::Forms::ResourceForm(work.class).new(work)
133
+ case resource
134
+ when Hyrax::FileSet
135
+ Hyrax::Forms::FileSetForm.new(resource)
136
+ when Hyrax::PcdmCollection
137
+ Hyrax::Forms::PcdmCollectionForm.new(resource)
138
+ else
139
+ Hyrax::Forms::ResourceForm(resource.class).new(resource)
140
+ end
138
141
  end
139
142
 
140
143
  ##
@@ -201,6 +204,11 @@ module Hyrax
201
204
 
202
205
  private
203
206
 
207
+ # https://trailblazer.to/2.1/docs/reform.html#reform-populators-populator-collections
208
+ def permission_populator(collection:, index:, **)
209
+ Hyrax::Forms::Permission.new(collection[index])
210
+ end
211
+
204
212
  def _form_field_definitions
205
213
  self.class.definitions
206
214
  end
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
- # rubocop:disable Metrics/ClassLength
3
2
  module Hyrax
4
3
  module Forms
5
4
  # @abstract
6
- class WorkForm
5
+ class WorkForm # rubocop:disable Metrics/ClassLength
7
6
  include HydraEditor::Form
8
7
  include HydraEditor::Form::Permissions
9
8
  attr_accessor :current_ability
@@ -176,6 +175,10 @@ module Hyrax
176
175
  based_near_attributes: [:id, :_destroy],
177
176
  member_of_collections_attributes: [:id, :_destroy],
178
177
  work_members_attributes: [:id, :_destroy]
178
+ },
179
+ {
180
+ file_set: [:visibility, :visibility_during_embargo, :embargo_release_date, :visibility_after_embargo,
181
+ :visibility_during_lease, :lease_expiration_date, :visibility_after_lease, :uploaded_file_id]
179
182
  }
180
183
  ]
181
184
  end
@@ -17,6 +17,10 @@ module Hyrax
17
17
  include ActiveModel::Validations
18
18
  extend ActiveModel::Translation
19
19
 
20
+ ##
21
+ # @param current_ability [::Ability]
22
+ # @param work [ActiveFedora::Base, Valkyrie::Resource]
23
+ # @param attributes [Hash{Symbol => String}]
20
24
  def initialize(current_ability:, work:, attributes: {})
21
25
  @current_ability = current_ability
22
26
  @work = work
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
- # View Helpers for Hydra Batch Edit functionality
2
+
3
3
  module Hyrax
4
+ ##
5
+ # View Helpers for Hydra Batch Edit functionality
4
6
  module BatchEditsHelper
5
7
  # Displays the delete button for batch editing
6
8
  def batch_delete
@@ -1,6 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
- module CollectionsHelper
3
+ module CollectionsHelper # rubocop:disable Metrics/ModuleLength
4
+ ##
5
+ # @since 3.1.0
6
+ # @return [Array<SolrDocument>]
7
+ def available_child_collections(collection:)
8
+ Hyrax::Collections::NestedCollectionQueryService
9
+ .available_child_collections(parent: collection, scope: controller, limit_to_id: nil)
10
+ end
11
+
12
+ ##
13
+ # @since 3.1.0
14
+ #
15
+ # @note provides data for handleAddToCollection javascript
16
+ #
17
+ # @return [String] JSON document containing id/title pairs for eligible
18
+ # parent collections to be displayed in an "Add to Collection" dropdown
19
+ def available_parent_collections_data(collection:)
20
+ Hyrax::Collections::NestedCollectionQueryService
21
+ .available_parent_collections(child: collection, scope: controller, limit_to_id: nil)
22
+ .map do |result|
23
+ { "id" => result.id, "title_first" => result.title.first }
24
+ end.to_json
25
+ end
26
+
4
27
  ##
5
28
  # @since 3.0.0
6
29
  # @return [#to_s]
@@ -97,6 +120,69 @@ module Hyrax
97
120
  single_item_action_form_fields(form, document, 'remove')
98
121
  end
99
122
 
123
+ ##
124
+ # @param collection [Object]
125
+ def collection_type_label_for(collection:)
126
+ case collection
127
+ when Valkyrie::Resource
128
+ CollectionType
129
+ .find_by_gid!(collection.collection_type_gid)
130
+ .title
131
+ else
132
+ collection.collection_type.title
133
+ end
134
+ end
135
+
136
+ ##
137
+ # @param collection [Object]
138
+ #
139
+ # @return [Boolean]
140
+ def collection_brandable?(collection:)
141
+ case collection
142
+ when Valkyrie::Resource
143
+ CollectionType
144
+ .find_by_gid!(collection.collection_type_gid)
145
+ .brandable?
146
+ else
147
+ collection.try(:brandable?)
148
+ end
149
+ end
150
+
151
+ ##
152
+ # @param collection [Object]
153
+ #
154
+ # @return [Boolean]
155
+ def collection_discoverable?(collection:)
156
+ case collection
157
+ when Valkyrie::Resource
158
+ CollectionType
159
+ .find_by_gid!(collection.collection_type_gid)
160
+ .discoverable?
161
+ else
162
+ collection.try(:discoverable?)
163
+ end
164
+ end
165
+
166
+ ##
167
+ # @param collection [Object]
168
+ #
169
+ # @return [Boolean]
170
+ def collection_sharable?(collection:)
171
+ case collection
172
+ when Valkyrie::Resource
173
+ CollectionType
174
+ .find_by_gid!(collection.collection_type_gid)
175
+ .sharable?
176
+ else
177
+ collection.try(:sharable?)
178
+ end
179
+ end
180
+
181
+ ##
182
+ # @note this helper is primarily intended for use with blacklight facet
183
+ # fields. it assumes we index a `collection_type_gid` and the helper
184
+ # can be passed as as a `helper_method:` to `add_facet_field`.
185
+ #
100
186
  # @param collection_type_gid [String] The gid of the CollectionType to be looked up
101
187
  # @return [String] The CollectionType's title if found, else the gid
102
188
  def collection_type_label(collection_type_gid)
@@ -112,4 +198,4 @@ module Hyrax
112
198
  render 'hyrax/dashboard/collections/single_item_action_fields', form: form, document: document, action: action
113
199
  end
114
200
  end
115
- end
201
+ end # rubocop:enable Metrics/ModuleLength