hyrax 2.0.3 → 2.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (703) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc +0 -1
  3. data/.github/CONTRIBUTING.md +1 -1
  4. data/.rubocop.yml +8 -4
  5. data/.rubocop_fixme.yml +20 -2
  6. data/.travis.yml +3 -3
  7. data/README.md +12 -4
  8. data/app/actors/hyrax/actors/abstract_actor.rb +1 -1
  9. data/app/actors/hyrax/actors/apply_permission_template_actor.rb +17 -1
  10. data/app/actors/hyrax/actors/attach_members_actor.rb +2 -2
  11. data/app/actors/hyrax/actors/collections_membership_actor.rb +147 -12
  12. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +15 -9
  13. data/app/actors/hyrax/actors/default_admin_set_actor.rb +3 -3
  14. data/app/actors/hyrax/actors/file_set_actor.rb +10 -6
  15. data/app/actors/hyrax/actors/interpret_visibility_actor.rb +1 -1
  16. data/app/assets/javascripts/hyrax.js +13 -7
  17. data/app/assets/javascripts/hyrax/admin/admin_set_controls.es6 +5 -3
  18. data/app/assets/javascripts/hyrax/admin/collection_type/participants.es6 +13 -0
  19. data/app/assets/javascripts/hyrax/admin/collection_type/settings.es6 +60 -0
  20. data/app/assets/javascripts/hyrax/admin/collection_type_controls.es6 +15 -0
  21. data/app/assets/javascripts/hyrax/app.js.erb +29 -7
  22. data/app/assets/javascripts/hyrax/autocomplete.es6 +10 -5
  23. data/app/assets/javascripts/hyrax/autocomplete/default.es6 +1 -1
  24. data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +1 -1
  25. data/app/assets/javascripts/hyrax/autocomplete/{work.es6 → resource.es6} +10 -4
  26. data/app/assets/javascripts/hyrax/collection_types.es6 +65 -0
  27. data/app/assets/javascripts/hyrax/collections.js +168 -3
  28. data/app/assets/javascripts/hyrax/collections/editor.es6 +7 -1
  29. data/app/assets/javascripts/hyrax/collections_forms.js +108 -0
  30. data/app/assets/javascripts/hyrax/editor.es6 +17 -3
  31. data/app/assets/javascripts/hyrax/fileupload.js +1 -0
  32. data/app/assets/javascripts/hyrax/relationships.js +2 -1
  33. data/app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6 +45 -0
  34. data/app/assets/javascripts/hyrax/relationships/control.es6 +25 -10
  35. data/app/assets/javascripts/hyrax/relationships/registry.es6 +28 -25
  36. data/app/assets/javascripts/hyrax/relationships/registry_entry.es6 +40 -33
  37. data/app/assets/javascripts/hyrax/relationships/resource.es6 +10 -0
  38. data/app/assets/javascripts/hyrax/select_collection_type.es6 +39 -0
  39. data/app/assets/javascripts/hyrax/{per_page.es6 → sort_and_per_page.es6} +1 -1
  40. data/app/assets/javascripts/hyrax/tabbed_form.es6 +35 -0
  41. data/app/assets/stylesheets/_bootstrap-default-overrides.scss +15 -0
  42. data/app/assets/stylesheets/fileupload/jquery.fileupload-ui.scss +6 -0
  43. data/app/assets/stylesheets/hyrax/_accessibility.scss +16 -0
  44. data/app/assets/stylesheets/hyrax/_catalog.scss +88 -1
  45. data/app/assets/stylesheets/hyrax/_collection_types.scss +53 -0
  46. data/app/assets/stylesheets/hyrax/_collections.scss +616 -22
  47. data/app/assets/stylesheets/hyrax/_featured.scss +16 -0
  48. data/app/assets/stylesheets/hyrax/_file-listing.scss +9 -2
  49. data/app/assets/stylesheets/hyrax/_forms.scss +46 -0
  50. data/app/assets/stylesheets/hyrax/_home-page.scss +10 -0
  51. data/app/assets/stylesheets/hyrax/_hyrax.scss +3 -2
  52. data/app/assets/stylesheets/hyrax/_positioning.scss +0 -11
  53. data/app/assets/stylesheets/hyrax/_recent.scss +26 -0
  54. data/app/assets/stylesheets/hyrax/_representative-media.scss +7 -0
  55. data/app/assets/stylesheets/hyrax/_select_collection_type.scss +45 -0
  56. data/app/assets/stylesheets/hyrax/_select_work_type.scss +0 -4
  57. data/app/assets/stylesheets/hyrax/_styles.scss +2 -17
  58. data/app/assets/stylesheets/hyrax/_variables.scss +2 -2
  59. data/app/assets/stylesheets/hyrax/_viewer.scss +8 -0
  60. data/app/assets/stylesheets/hyrax/_work-show.scss +44 -6
  61. data/app/assets/stylesheets/hyrax/dashboard.scss +7 -2
  62. data/app/authorities/qa/authorities/collections.rb +30 -0
  63. data/app/builders/hyrax/manifest_helper.rb +36 -0
  64. data/app/controllers/concerns/hyrax/admin/stats_behavior.rb +1 -1
  65. data/app/controllers/concerns/hyrax/admin/users_controller_behavior.rb +1 -1
  66. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +37 -40
  67. data/app/controllers/concerns/hyrax/controller.rb +0 -9
  68. data/app/controllers/concerns/hyrax/themed_layout_controller.rb +4 -1
  69. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -11
  70. data/app/controllers/hyrax/admin/admin_sets_controller.rb +24 -15
  71. data/app/controllers/hyrax/admin/appearances_controller.rb +1 -1
  72. data/app/controllers/hyrax/admin/collection_type_participants_controller.rb +44 -0
  73. data/app/controllers/hyrax/admin/collection_types_controller.rb +97 -0
  74. data/app/controllers/hyrax/admin/features_controller.rb +1 -1
  75. data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +55 -13
  76. data/app/controllers/hyrax/admin/permission_templates_controller.rb +66 -23
  77. data/app/controllers/hyrax/admin/workflow_roles_controller.rb +1 -1
  78. data/app/controllers/hyrax/admin/workflows_controller.rb +1 -1
  79. data/app/controllers/hyrax/batch_edits_controller.rb +1 -1
  80. data/app/controllers/hyrax/batch_uploads_controller.rb +1 -1
  81. data/app/controllers/hyrax/citations_controller.rb +3 -12
  82. data/app/controllers/hyrax/collections_controller.rb +8 -9
  83. data/app/controllers/hyrax/content_blocks_controller.rb +1 -1
  84. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +73 -0
  85. data/app/controllers/hyrax/dashboard/collections_controller.rb +210 -54
  86. data/app/controllers/hyrax/dashboard/nest_collections_controller.rb +106 -0
  87. data/app/controllers/hyrax/dashboard/profiles_controller.rb +1 -1
  88. data/app/controllers/hyrax/dashboard/works_controller.rb +1 -9
  89. data/app/controllers/hyrax/dashboard_controller.rb +1 -1
  90. data/app/controllers/hyrax/file_sets_controller.rb +7 -75
  91. data/app/controllers/hyrax/my/collections_controller.rb +26 -1
  92. data/app/controllers/hyrax/my/works_controller.rb +16 -1
  93. data/app/controllers/hyrax/my_controller.rb +5 -19
  94. data/app/controllers/hyrax/notifications_controller.rb +1 -1
  95. data/app/controllers/hyrax/pages_controller.rb +3 -2
  96. data/app/controllers/hyrax/stats_controller.rb +3 -0
  97. data/app/controllers/hyrax/transfers_controller.rb +1 -1
  98. data/app/forms/hyrax/forms/admin/appearance.rb +2 -2
  99. data/app/forms/hyrax/forms/admin/collection_type_form.rb +24 -0
  100. data/app/forms/hyrax/forms/admin/collection_type_participant_form.rb +16 -0
  101. data/app/forms/hyrax/forms/admin_set_form.rb +1 -1
  102. data/app/forms/hyrax/forms/batch_edit_form.rb +28 -7
  103. data/app/forms/hyrax/forms/collection_form.rb +71 -13
  104. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +98 -0
  105. data/app/forms/hyrax/forms/permission_template_form.rb +13 -13
  106. data/app/forms/hyrax/forms/work_form.rb +58 -14
  107. data/app/helpers/hyrax/ability_helper.rb +3 -0
  108. data/app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb +3 -10
  109. data/app/helpers/hyrax/collections_helper.rb +10 -2
  110. data/app/helpers/hyrax/dashboard_helper_behavior.rb +0 -4
  111. data/app/helpers/hyrax/hyrax_helper_behavior.rb +19 -5
  112. data/app/helpers/hyrax/trophy_helper.rb +0 -1
  113. data/app/indexers/hyrax/indexes_workflow.rb +1 -1
  114. data/app/indexers/hyrax/repository_reindexer.rb +19 -0
  115. data/app/jobs/hyrax/application_job.rb +1 -1
  116. data/app/jobs/import_export_job.rb +1 -1
  117. data/app/jobs/user_edit_profile_event_job.rb +1 -1
  118. data/app/models/admin_set.rb +5 -2
  119. data/app/models/collection_branding_info.rb +39 -0
  120. data/app/models/concerns/hyrax/ability.rb +26 -49
  121. data/app/models/concerns/hyrax/ability/admin_set_ability.rb +40 -0
  122. data/app/models/concerns/hyrax/ability/collection_ability.rb +40 -0
  123. data/app/models/concerns/hyrax/ability/collection_type_ability.rb +16 -0
  124. data/app/models/concerns/hyrax/ability/permission_template_ability.rb +18 -0
  125. data/app/models/concerns/hyrax/ability/solr_document_ability.rb +18 -0
  126. data/app/models/concerns/hyrax/collection_behavior.rb +86 -3
  127. data/app/models/concerns/hyrax/collection_nesting.rb +41 -0
  128. data/app/models/concerns/hyrax/file_set/belongs_to_works.rb +0 -15
  129. data/app/models/concerns/hyrax/file_set_behavior.rb +0 -1
  130. data/app/models/concerns/hyrax/has_rendering.rb +11 -0
  131. data/app/models/concerns/hyrax/human_readable_type.rb +3 -0
  132. data/app/models/concerns/hyrax/solr_document/metadata.rb +3 -0
  133. data/app/models/concerns/hyrax/solr_document_behavior.rb +8 -2
  134. data/app/models/concerns/hyrax/user.rb +11 -6
  135. data/app/models/concerns/hyrax/with_events.rb +12 -6
  136. data/app/models/concerns/hyrax/work_behavior.rb +3 -1
  137. data/app/models/hyrax/batch_create_operation.rb +1 -1
  138. data/app/models/hyrax/collection_type.rb +155 -0
  139. data/app/models/hyrax/collection_type_participant.rb +39 -0
  140. data/app/models/hyrax/operation.rb +14 -2
  141. data/app/models/hyrax/permission_template.rb +23 -1
  142. data/app/models/hyrax/permission_template_access.rb +56 -7
  143. data/app/models/hyrax/uploaded_file.rb +4 -1
  144. data/app/models/sipity/workflow.rb +6 -4
  145. data/app/presenters/hyrax/admin/workflow_role_presenter.rb +3 -3
  146. data/app/presenters/hyrax/admin_set_options_presenter.rb +1 -1
  147. data/app/presenters/hyrax/admin_set_presenter.rb +16 -0
  148. data/app/presenters/hyrax/collection_options_presenter.rb +1 -0
  149. data/app/presenters/hyrax/collection_presenter.rb +134 -6
  150. data/app/presenters/hyrax/displays_image.rb +39 -0
  151. data/app/presenters/hyrax/file_set_presenter.rb +1 -4
  152. data/app/presenters/hyrax/fixity_status_presenter.rb +2 -2
  153. data/app/presenters/hyrax/homepage_presenter.rb +20 -0
  154. data/app/presenters/hyrax/menu_presenter.rb +2 -1
  155. data/app/presenters/hyrax/select_collection_type_list_presenter.rb +42 -0
  156. data/app/presenters/hyrax/select_collection_type_presenter.rb +11 -0
  157. data/app/presenters/hyrax/select_type_presenter.rb +13 -4
  158. data/app/presenters/hyrax/work_show_presenter.rb +52 -1
  159. data/app/renderers/hyrax/renderers/attribute_renderer.rb +1 -1
  160. data/app/renderers/hyrax/renderers/license_attribute_renderer.rb +1 -1
  161. data/app/renderers/hyrax/renderers/rights_statement_attribute_renderer.rb +3 -2
  162. data/app/search_builders/hyrax/admin_admin_set_member_search_builder.rb +10 -1
  163. data/app/search_builders/hyrax/admin_set_search_builder.rb +9 -2
  164. data/app/search_builders/hyrax/collection_member_search_builder.rb +21 -8
  165. data/app/search_builders/hyrax/collection_search_builder.rb +37 -0
  166. data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +42 -0
  167. data/app/search_builders/hyrax/dashboard/managed_search_filters.rb +24 -0
  168. data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +123 -0
  169. data/app/search_builders/hyrax/dashboard/works_search_builder.rb +18 -0
  170. data/app/search_builders/hyrax/filter_suppressed_with_roles.rb +5 -1
  171. data/app/search_builders/hyrax/my/collections_search_builder.rb +20 -3
  172. data/app/search_builders/hyrax/nested_collections_parent_search_builder.rb +27 -0
  173. data/app/search_builders/hyrax/search_filters.rb +8 -0
  174. data/app/services/hyrax/adapters/nesting_index_adapter.rb +192 -0
  175. data/app/services/hyrax/admin_set_create_service.rb +3 -2
  176. data/app/services/hyrax/admin_set_member_service.rb +40 -0
  177. data/app/services/hyrax/batch_create_failure_service.rb +4 -3
  178. data/app/services/hyrax/collection_types/create_service.rb +143 -0
  179. data/app/services/hyrax/collection_types/permissions_service.rb +233 -0
  180. data/app/services/hyrax/collections/collection_member_service.rb +91 -0
  181. data/app/services/hyrax/collections/managed_collections_service.rb +16 -0
  182. data/app/services/hyrax/collections/migration_service.rb +81 -0
  183. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +26 -0
  184. data/app/services/hyrax/collections/nested_collection_query_service.rb +187 -0
  185. data/app/services/hyrax/collections/permissions_create_service.rb +71 -0
  186. data/app/services/hyrax/collections/permissions_service.rb +234 -0
  187. data/app/services/hyrax/collections_service.rb +3 -3
  188. data/app/services/hyrax/default_middleware_stack.rb +35 -0
  189. data/app/services/hyrax/file_set_fixity_check_service.rb +1 -1
  190. data/app/services/hyrax/graph_exporter.rb +19 -15
  191. data/app/services/hyrax/iiif_authorization_service.rb +19 -0
  192. data/app/services/hyrax/multiple_membership_checker.rb +78 -0
  193. data/app/services/hyrax/noid.rb +1 -3
  194. data/app/services/hyrax/qa_select_service.rb +11 -2
  195. data/app/services/hyrax/workflow/status_list_service.rb +1 -1
  196. data/app/services/hyrax/working_directory.rb +0 -8
  197. data/app/services/hyrax/works/managed_works_service.rb +16 -0
  198. data/app/views/_flash_msg.html.erb +1 -1
  199. data/app/views/_masthead.html.erb +0 -1
  200. data/app/views/catalog/_document.html.erb +3 -1
  201. data/app/views/catalog/_document_list.html.erb +2 -2
  202. data/app/views/catalog/_index_header_list_collection.html.erb +4 -3
  203. data/app/views/catalog/_index_header_list_default.html.erb +3 -3
  204. data/app/views/catalog/_index_list_default.html.erb +29 -14
  205. data/app/views/catalog/_thumbnail_list_collection.html.erb +3 -4
  206. data/app/views/catalog/_thumbnail_list_default.html.erb +5 -3
  207. data/app/views/hyrax/admin/admin_sets/_form.html.erb +2 -1
  208. data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +1 -1
  209. data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +1 -1
  210. data/app/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb +3 -3
  211. data/app/views/hyrax/admin/admin_sets/edit.html.erb +1 -1
  212. data/app/views/hyrax/admin/collection_types/_form.html.erb +61 -0
  213. data/app/views/hyrax/admin/collection_types/_form_metadata.html.erb +2 -0
  214. data/app/views/hyrax/admin/collection_types/_form_metadata_admin_set.html.erb +2 -0
  215. data/app/views/hyrax/admin/collection_types/_form_participant_table.html.erb +26 -0
  216. data/app/views/hyrax/admin/collection_types/_form_participants.html.erb +62 -0
  217. data/app/views/hyrax/admin/collection_types/_form_settings.html.erb +39 -0
  218. data/app/views/hyrax/admin/collection_types/edit.html.erb +10 -0
  219. data/app/views/hyrax/admin/collection_types/index.html.erb +88 -0
  220. data/app/views/hyrax/admin/collection_types/new.html.erb +10 -0
  221. data/app/views/hyrax/base/_attribute_rows.html.erb +1 -0
  222. data/app/views/hyrax/base/_citations.html.erb +10 -6
  223. data/app/views/hyrax/base/_form_child_work_relationships.html.erb +22 -29
  224. data/app/views/hyrax/base/_form_files.html.erb +29 -16
  225. data/app/views/hyrax/base/_form_media.html.erb +1 -0
  226. data/app/views/hyrax/base/_form_member_of_collections.html.erb +44 -6
  227. data/app/views/hyrax/base/_form_metadata.html.erb +0 -3
  228. data/app/views/hyrax/base/_form_progress.html.erb +2 -1
  229. data/app/views/hyrax/base/_form_relationships.html.erb +3 -2
  230. data/app/views/hyrax/base/_form_rendering.html.erb +14 -0
  231. data/app/views/hyrax/base/_form_representative.html.erb +2 -2
  232. data/app/views/hyrax/base/_form_share.html.erb +44 -41
  233. data/app/views/hyrax/base/_form_thumbnail.html.erb +2 -2
  234. data/app/views/hyrax/base/_guts4form.html.erb +2 -2
  235. data/app/views/hyrax/base/_member.html.erb +3 -4
  236. data/app/views/hyrax/base/_metadata.html.erb +1 -5
  237. data/app/views/hyrax/base/_relationships.html.erb +1 -1
  238. data/app/views/hyrax/base/_relationships_parent_row.html.erb +1 -1
  239. data/app/views/hyrax/base/_representative_media.html.erb +8 -2
  240. data/app/views/hyrax/base/_work_title.erb +14 -7
  241. data/app/views/hyrax/base/_work_type.html.erb +4 -0
  242. data/app/views/hyrax/base/_workflow_actions.html.erb +7 -7
  243. data/app/views/hyrax/base/_workflow_actions_widget.erb +4 -2
  244. data/app/views/hyrax/base/show.html.erb +35 -26
  245. data/app/views/hyrax/batch_edits/edit.html.erb +1 -1
  246. data/app/views/hyrax/collections/_collection_description.erb +1 -1
  247. data/app/views/hyrax/collections/_default_group.html.erb +9 -11
  248. data/app/views/hyrax/collections/_list_collections.html.erb +19 -12
  249. data/app/views/hyrax/collections/_paginate.html.erb +5 -4
  250. data/app/views/hyrax/collections/_search_form.html.erb +1 -1
  251. data/app/views/hyrax/collections/_search_results.html.erb +0 -2
  252. data/app/views/hyrax/collections/_show_descriptions.html.erb +7 -6
  253. data/app/views/hyrax/collections/_show_document_list.html.erb +3 -3
  254. data/app/views/hyrax/collections/_show_document_list_row.html.erb +3 -3
  255. data/app/views/hyrax/collections/_show_parent_collections.html.erb +41 -0
  256. data/app/views/hyrax/collections/_sort_and_per_page.html.erb +16 -24
  257. data/app/views/hyrax/collections/_subcollection_list.html.erb +13 -0
  258. data/app/views/hyrax/collections/_view_type_group.html.erb +1 -1
  259. data/app/views/hyrax/collections/show.html.erb +120 -31
  260. data/app/views/hyrax/dashboard/collections/_button_for_batch_delete_collection.html.erb +4 -0
  261. data/app/views/hyrax/dashboard/collections/_button_for_remove_selected_from_collection.html.erb +0 -1
  262. data/app/views/hyrax/dashboard/collections/_button_for_update_collection.html.erb +1 -1
  263. data/app/views/hyrax/dashboard/collections/_button_remove_from_collection.html.erb +1 -1
  264. data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +25 -0
  265. data/app/views/hyrax/dashboard/collections/_document_list.html.erb +1 -5
  266. data/app/views/hyrax/dashboard/collections/_edit_actions.html.erb +2 -2
  267. data/app/views/hyrax/dashboard/collections/_flash_msg.html.erb +9 -0
  268. data/app/views/hyrax/dashboard/collections/_form.html.erb +46 -24
  269. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +153 -0
  270. data/app/views/hyrax/dashboard/collections/_form_default_group_delt.html.erb +27 -0
  271. data/app/views/hyrax/dashboard/collections/_form_discovery.html.erb +18 -0
  272. data/app/views/hyrax/dashboard/collections/_form_share.html.erb +69 -81
  273. data/app/views/hyrax/dashboard/collections/_form_share_table.html.erb +31 -0
  274. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +54 -37
  275. data/app/views/hyrax/dashboard/collections/_modal_remove_from_collection.html.erb +17 -0
  276. data/app/views/hyrax/dashboard/collections/_modal_remove_sub_collection.html.erb +17 -0
  277. data/app/views/hyrax/dashboard/collections/_show_actions.html.erb +27 -21
  278. data/app/views/hyrax/dashboard/collections/_show_add_items_actions.html.erb +25 -0
  279. data/app/views/hyrax/dashboard/collections/_show_document_list.html.erb +4 -3
  280. data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +6 -5
  281. data/app/views/hyrax/dashboard/collections/_show_parent_collection_row.html.erb +6 -0
  282. data/app/views/hyrax/dashboard/collections/_show_parent_collections.html.erb +37 -0
  283. data/app/views/hyrax/dashboard/collections/_show_subcollection_actions.html.erb +26 -0
  284. data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +28 -27
  285. data/app/views/hyrax/dashboard/collections/_subcollection_list.html.erb +21 -0
  286. data/app/views/hyrax/dashboard/collections/_work_action_menu.html.erb +1 -1
  287. data/app/views/hyrax/dashboard/collections/edit.html.erb +8 -31
  288. data/app/views/hyrax/dashboard/collections/new.html.erb +2 -3
  289. data/app/views/hyrax/dashboard/collections/show.html.erb +102 -35
  290. data/app/views/hyrax/dashboard/sidebar/_configuration.html.erb +5 -0
  291. data/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb +0 -5
  292. data/app/views/hyrax/dashboard/sidebar/_tasks.html.erb +10 -0
  293. data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -0
  294. data/app/views/hyrax/dashboard/works/_list_works.html.erb +4 -0
  295. data/app/views/hyrax/file_sets/_extra_fields_modal.html.erb +1 -1
  296. data/app/views/hyrax/file_sets/_form.html.erb +2 -2
  297. data/app/views/hyrax/file_sets/_show_characterization_details.html.erb +1 -1
  298. data/app/views/hyrax/file_sets/media_display/_image.html.erb +3 -5
  299. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +3 -5
  300. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +3 -5
  301. data/app/views/hyrax/homepage/_featured.html.erb +5 -5
  302. data/app/views/hyrax/homepage/_featured_fields.html.erb +10 -14
  303. data/app/views/hyrax/homepage/_featured_works.html.erb +1 -1
  304. data/app/views/hyrax/homepage/_home_content.html.erb +2 -2
  305. data/app/views/hyrax/homepage/_recent_document.html.erb +14 -12
  306. data/app/views/hyrax/homepage/_recently_uploaded.html.erb +2 -6
  307. data/app/views/hyrax/homepage/index.html.erb +4 -2
  308. data/app/views/hyrax/my/_admin_set_action_menu.html.erb +54 -0
  309. data/app/views/hyrax/my/_collection_action_menu.html.erb +41 -9
  310. data/app/views/hyrax/my/_facet_pivot.html.erb +26 -0
  311. data/app/views/hyrax/my/_search_header.html.erb +1 -15
  312. data/app/views/hyrax/my/_sort_and_per_page.html.erb +12 -13
  313. data/app/views/hyrax/my/_work_action_menu.html.erb +17 -15
  314. data/app/views/hyrax/my/collections/_batch_actions.html.erb +5 -0
  315. data/app/views/hyrax/my/collections/_default_group.html.erb +21 -12
  316. data/app/views/hyrax/my/collections/_list_collections.html.erb +57 -35
  317. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +38 -0
  318. data/app/views/hyrax/my/collections/_modal_add_to_collection.html.erb +31 -0
  319. data/app/views/hyrax/my/collections/_modal_add_to_collection_deny.html.erb +12 -0
  320. data/app/views/hyrax/my/collections/_modal_add_to_collection_permission_deny.html.erb +12 -0
  321. data/app/views/hyrax/my/collections/_modal_collection_types_to_create.html.erb +36 -0
  322. data/app/views/hyrax/my/collections/_modal_delete_admin_set_deny.html.erb +12 -0
  323. data/app/views/hyrax/my/collections/_modal_delete_collection.html.erb +19 -0
  324. data/app/views/hyrax/my/collections/_modal_delete_collection_deny.html.erb +14 -0
  325. data/app/views/hyrax/my/collections/_modal_delete_deny.html.erb +14 -0
  326. data/app/views/hyrax/my/collections/_modal_delete_empty_collection.html.erb +18 -0
  327. data/app/views/hyrax/my/collections/_modal_delete_selected_collections.html.erb +17 -0
  328. data/app/views/hyrax/my/collections/_modal_edit_deny.html.erb +14 -0
  329. data/app/views/hyrax/my/collections/_tabs.html.erb +3 -3
  330. data/app/views/hyrax/my/collections/index.html.erb +46 -21
  331. data/app/views/hyrax/my/works/_batch_actions.html.erb +14 -0
  332. data/app/views/hyrax/my/works/_default_group.html.erb +10 -12
  333. data/app/views/hyrax/my/works/_tabs.html.erb +1 -1
  334. data/app/views/hyrax/my/works/index.html.erb +7 -5
  335. data/app/views/hyrax/notifications/_notifications.html.erb +3 -3
  336. data/app/views/hyrax/permissions/confirm_access.html.erb +1 -1
  337. data/app/views/hyrax/stats/file.html.erb +1 -1
  338. data/app/views/hyrax/stats/work.html.erb +1 -1
  339. data/app/views/hyrax/transfers/_received.html.erb +1 -1
  340. data/app/views/hyrax/transfers/_sent.html.erb +1 -1
  341. data/app/views/hyrax/uploads/_js_templates_branding.html.erb +120 -0
  342. data/app/views/hyrax/users/_activity_log.html.erb +3 -3
  343. data/app/views/kaminari/blacklight_compact/_paginator.html.erb +23 -0
  344. data/app/views/layouts/hyrax.html.erb +9 -11
  345. data/app/views/layouts/{dashboard.html.erb → hyrax/dashboard.html.erb} +0 -0
  346. data/app/views/shared/_select_work_type_modal.html.erb +25 -26
  347. data/config/features.rb +4 -0
  348. data/config/initializers/hyrax_callbacks.rb +2 -2
  349. data/config/initializers/samvera-nesting_indexer_initializer.rb +15 -0
  350. data/config/locales/hyrax.de.yml +364 -79
  351. data/config/locales/hyrax.en.yml +874 -584
  352. data/config/locales/hyrax.es.yml +323 -35
  353. data/config/locales/hyrax.fr.yml +323 -39
  354. data/config/locales/hyrax.it.yml +322 -39
  355. data/config/locales/hyrax.pt-BR.yml +317 -39
  356. data/config/locales/hyrax.zh.yml +420 -142
  357. data/config/routes.rb +17 -0
  358. data/hyrax.gemspec +58 -57
  359. data/lib/generators/hyrax/assets_generator.rb +2 -4
  360. data/lib/generators/hyrax/clamav_generator.rb +0 -2
  361. data/lib/generators/hyrax/config_generator.rb +0 -2
  362. data/lib/generators/hyrax/install_generator.rb +12 -3
  363. data/lib/generators/hyrax/riiif_generator.rb +54 -0
  364. data/lib/generators/hyrax/templates/app/assets/images/us_404.svg +91 -0
  365. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +48 -3
  366. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +26 -0
  367. data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +4 -4
  368. data/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +0 -4
  369. data/lib/generators/hyrax/templates/db/migrate/20170808160431_create_collection_types.rb.erb +17 -0
  370. data/lib/generators/hyrax/templates/db/migrate/20170808160432_update_collection_type_column_names.rb.erb +9 -0
  371. data/lib/generators/hyrax/templates/db/migrate/20170810190549_update_collection_type_column_options.rb.erb +9 -0
  372. data/lib/generators/hyrax/templates/db/migrate/20170816180307_create_collection_branding_infos.rb.erb +15 -0
  373. data/lib/generators/hyrax/templates/db/migrate/20170817152654_create_collection_type_participants.rb.erb +11 -0
  374. data/lib/generators/hyrax/templates/db/migrate/20170821152307_rename_admin_set_id_to_source_id.rb.erb +5 -0
  375. data/lib/generators/hyrax/templates/db/migrate/20171103080032_add_collection_type_sharing_options.rb.erb +5 -0
  376. data/lib/generators/hyrax/templates/db/seeds.rb +226 -22
  377. data/lib/generators/hyrax/work/templates/controller.rb.erb +1 -1
  378. data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +37 -1
  379. data/lib/generators/hyrax/work/templates/form.rb.erb +1 -0
  380. data/lib/generators/hyrax/work/templates/indexer.rb.erb +0 -1
  381. data/lib/generators/hyrax/work/templates/locale.de.yml.erb +1 -1
  382. data/lib/generators/hyrax/work/templates/locale.en.yml.erb +1 -1
  383. data/lib/generators/hyrax/work/templates/locale.es.yml.erb +1 -1
  384. data/lib/generators/hyrax/work/templates/locale.fr.yml.erb +1 -1
  385. data/lib/generators/hyrax/work/templates/locale.it.yml.erb +1 -1
  386. data/lib/generators/hyrax/work/templates/locale.pt-BR.yml.erb +1 -1
  387. data/lib/generators/hyrax/work/templates/locale.zh.yml.erb +1 -1
  388. data/lib/generators/hyrax/work/templates/model.rb.erb +0 -2
  389. data/lib/hyrax.rb +1 -1
  390. data/lib/hyrax/configuration.rb +96 -7
  391. data/lib/hyrax/engine.rb +5 -4
  392. data/lib/hyrax/rails/routes.rb +1 -1
  393. data/lib/hyrax/version.rb +1 -1
  394. data/lib/tasks/default_admin_set.rake +5 -3
  395. data/lib/tasks/default_collection_type.rake +19 -0
  396. data/lib/tasks/migrate.rake +8 -0
  397. data/spec/abilities/ability_spec.rb +4 -1
  398. data/spec/abilities/admin_set_ability_spec.rb +172 -0
  399. data/spec/abilities/collection_ability_spec.rb +194 -0
  400. data/spec/abilities/collection_type_ability_spec.rb +72 -0
  401. data/spec/abilities/file_set_abilities_spec.rb +3 -3
  402. data/spec/abilities/generic_work_abilities_spec.rb +5 -5
  403. data/spec/abilities/permission_template_ability_spec.rb +145 -0
  404. data/spec/abilities/solr_document_ability_spec.rb +27 -0
  405. data/spec/actors/hyrax/actors/apply_permission_template_actor_spec.rb +96 -28
  406. data/spec/actors/hyrax/actors/collections_membership_actor_spec.rb +283 -15
  407. data/spec/actors/hyrax/actors/create_with_remote_files_actor_spec.rb +7 -7
  408. data/spec/actors/hyrax/actors/default_admin_set_actor_spec.rb +1 -1
  409. data/spec/actors/hyrax/actors/file_actor_spec.rb +0 -1
  410. data/spec/actors/hyrax/actors/file_set_actor_spec.rb +8 -6
  411. data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +11 -39
  412. data/spec/actors/hyrax/actors/interpret_visibility_actor_spec.rb +15 -15
  413. data/spec/actors/hyrax/actors/model_actor_spec.rb +0 -2
  414. data/spec/authorities/qa/authorities/collections_spec.rb +68 -0
  415. data/spec/channels/hyrax/application_cable/channel_spec.rb +1 -1
  416. data/spec/channels/hyrax/application_cable/connection_spec.rb +1 -1
  417. data/spec/channels/hyrax/notifications_channel_spec.rb +1 -1
  418. data/spec/controllers/catalog_controller_spec.rb +1 -1
  419. data/spec/controllers/hyrax/admin/admin_sets_controller_spec.rb +27 -1
  420. data/spec/controllers/hyrax/admin/collection_type_participants_controller_spec.rb +152 -0
  421. data/spec/controllers/hyrax/admin/collection_types_controller_spec.rb +320 -0
  422. data/spec/controllers/hyrax/admin/permission_template_accesses_controller_spec.rb +68 -29
  423. data/spec/controllers/hyrax/admin/permission_templates_controller_spec.rb +37 -10
  424. data/spec/controllers/hyrax/admin/strategies_controller_spec.rb +2 -13
  425. data/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb +52 -2
  426. data/spec/controllers/hyrax/batch_edits_controller_spec.rb +75 -4
  427. data/spec/controllers/hyrax/batch_uploads_controller_spec.rb +2 -2
  428. data/spec/controllers/hyrax/collections_controller_spec.rb +15 -6
  429. data/spec/controllers/hyrax/content_blocks_controller_spec.rb +5 -5
  430. data/spec/controllers/hyrax/dashboard/collection_members_controller_spec.rb +408 -0
  431. data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +114 -18
  432. data/spec/controllers/hyrax/dashboard/nest_collections_controller_spec.rb +360 -0
  433. data/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb +2 -2
  434. data/spec/controllers/hyrax/dashboard/works_controller_spec.rb +1 -1
  435. data/spec/controllers/hyrax/downloads_controller_spec.rb +3 -3
  436. data/spec/controllers/hyrax/featured_work_lists_controller_spec.rb +2 -2
  437. data/spec/controllers/hyrax/file_sets_controller_spec.rb +8 -136
  438. data/spec/controllers/hyrax/fixity_checks_controller_spec.rb +1 -1
  439. data/spec/controllers/hyrax/generic_works_controller_spec.rb +64 -2
  440. data/spec/controllers/hyrax/homepage_controller_spec.rb +1 -1
  441. data/spec/controllers/hyrax/my/works_controller_spec.rb +4 -1
  442. data/spec/controllers/hyrax/pages_controller_spec.rb +11 -11
  443. data/spec/controllers/hyrax/users_controller_spec.rb +1 -1
  444. data/spec/controllers/hyrax/workflow_actions_controller_spec.rb +1 -1
  445. data/spec/conversions/power_converters/polymorphic_type_spec.rb +2 -2
  446. data/spec/conversions/power_converters/sipity_agent_spec.rb +1 -1
  447. data/spec/conversions/power_converters/sipity_role_spec.rb +1 -1
  448. data/spec/conversions/power_converters/sipity_workflow_state_spec.rb +1 -1
  449. data/spec/factories/admin_sets.rb +3 -3
  450. data/spec/factories/collection_branding_infos.rb +11 -0
  451. data/spec/factories/collection_type_participants.rb +8 -0
  452. data/spec/factories/collection_types.rb +104 -0
  453. data/spec/factories/collections.rb +323 -0
  454. data/spec/factories/collections_factory.rb +106 -3
  455. data/spec/factories/file_sets.rb +2 -2
  456. data/spec/factories/generic_works.rb +22 -14
  457. data/spec/factories/object_id.rb +6 -0
  458. data/spec/factories/permission_templates.rb +46 -8
  459. data/spec/factories/users.rb +1 -1
  460. data/spec/factory_tests/collections_factory_spec.rb +211 -0
  461. data/spec/features/admin_spec.rb +1 -1
  462. data/spec/features/batch_create_spec.rb +1 -1
  463. data/spec/features/batch_edit_spec.rb +0 -1
  464. data/spec/features/browse_catalog_spec.rb +1 -3
  465. data/spec/features/browse_dashboard_works_spec.rb +0 -1
  466. data/spec/features/collection_multi_membership_spec.rb +188 -0
  467. data/spec/features/collection_spec.rb +45 -7
  468. data/spec/features/collection_type_spec.rb +338 -0
  469. data/spec/features/create_child_work_spec.rb +1 -1
  470. data/spec/features/create_work_admin_spec.rb +44 -0
  471. data/spec/features/create_work_spec.rb +1 -1
  472. data/spec/features/dashboard/all_works.rb +1 -1
  473. data/spec/features/dashboard/collection_spec.rb +724 -115
  474. data/spec/features/delete_work_spec.rb +1 -1
  475. data/spec/features/edit_file_spec.rb +1 -1
  476. data/spec/features/edit_work_spec.rb +1 -1
  477. data/spec/features/embargo_spec.rb +1 -1
  478. data/spec/features/homepage_spec.rb +3 -3
  479. data/spec/features/lease_spec.rb +1 -1
  480. data/spec/features/notifications_spec.rb +2 -2
  481. data/spec/features/ownership_transfer_spec.rb +1 -2
  482. data/spec/features/proxy_spec.rb +1 -1
  483. data/spec/features/search_spec.rb +12 -11
  484. data/spec/features/static_pages_spec.rb +1 -1
  485. data/spec/features/users_spec.rb +1 -1
  486. data/spec/features/work_generator_spec.rb +1 -1
  487. data/spec/features/work_show_spec.rb +4 -4
  488. data/spec/features/workflow_roles_spec.rb +1 -1
  489. data/spec/features/workflow_state_changes_spec.rb +2 -2
  490. data/spec/forms/hyrax/forms/admin/collection_type_form_spec.rb +106 -0
  491. data/spec/forms/hyrax/forms/admin/collection_type_participant_form_spec.rb +10 -0
  492. data/spec/forms/hyrax/forms/admin_set_form_spec.rb +1 -1
  493. data/spec/forms/hyrax/forms/batch_edit_form_spec.rb +1 -1
  494. data/spec/forms/hyrax/forms/batch_upload_form_spec.rb +1 -0
  495. data/spec/forms/hyrax/forms/collection_form_spec.rb +52 -4
  496. data/spec/forms/hyrax/forms/dashboard/nest_collection_form_spec.rb +159 -0
  497. data/spec/forms/hyrax/forms/permission_template_form_spec.rb +15 -12
  498. data/spec/forms/hyrax/forms/work_form_spec.rb +61 -12
  499. data/spec/forms/hyrax/forms/workflow_action_form_spec.rb +1 -1
  500. data/spec/forms/hyrax/generic_work_form_spec.rb +6 -3
  501. data/spec/helpers/hyrax/ability_helper_spec.rb +11 -0
  502. data/spec/helpers/hyrax/collections_helper_spec.rb +17 -39
  503. data/spec/helpers/hyrax/content_block_helper_spec.rb +1 -1
  504. data/spec/helpers/{dashboard_helper_spec.rb → hyrax/dashboard_helper_behavior_spec.rb} +1 -12
  505. data/spec/helpers/hyrax/trophy_helper_spec.rb +1 -1
  506. data/spec/helpers/hyrax_helper_spec.rb +0 -3
  507. data/spec/indexers/hyrax/generic_work_indexer_spec.rb +4 -4
  508. data/spec/indexers/hyrax/repository_reindexer_spec.rb +8 -0
  509. data/spec/javascripts/relationships_control_spec.js.coffee +3 -3
  510. data/spec/javascripts/settings_spec.js +73 -0
  511. data/spec/jobs/user_edit_profile_event_job_spec.rb +1 -1
  512. data/spec/lib/hyrax/configuration_spec.rb +16 -0
  513. data/spec/models/admin_set_spec.rb +42 -4
  514. data/spec/models/collection_branding_info_spec.rb +61 -0
  515. data/spec/models/collection_spec.rb +228 -3
  516. data/spec/models/concerns/hyrax/collection_nesting_spec.rb +64 -0
  517. data/spec/models/file_set_spec.rb +4 -4
  518. data/spec/models/generic_work_spec.rb +1 -1
  519. data/spec/models/hyrax/batch_create_operation_spec.rb +59 -0
  520. data/spec/models/hyrax/collection_type_participant_spec.rb +43 -0
  521. data/spec/models/hyrax/collection_type_spec.rb +235 -0
  522. data/spec/models/hyrax/operation_spec.rb +27 -1
  523. data/spec/models/hyrax/permission_template_access_spec.rb +128 -5
  524. data/spec/models/hyrax/permission_template_spec.rb +85 -29
  525. data/spec/models/hyrax/user_usage_stats_spec.rb +1 -1
  526. data/spec/models/hyrax/work_behavior_spec.rb +12 -2
  527. data/spec/models/sipity/agent_spec.rb +1 -1
  528. data/spec/models/sipity/comment_spec.rb +1 -1
  529. data/spec/models/sipity/entity_spec.rb +3 -3
  530. data/spec/models/sipity/entity_specific_responsibility_spec.rb +1 -1
  531. data/spec/models/sipity/notifiable_context_spec.rb +1 -1
  532. data/spec/models/sipity/notification_recipient_spec.rb +1 -1
  533. data/spec/models/sipity/notification_spec.rb +1 -1
  534. data/spec/models/sipity/role_spec.rb +1 -1
  535. data/spec/models/sipity/workflow_action_spec.rb +1 -1
  536. data/spec/models/sipity/workflow_responsibility_spec.rb +1 -1
  537. data/spec/models/sipity/workflow_role_spec.rb +1 -1
  538. data/spec/models/sipity/workflow_spec.rb +7 -7
  539. data/spec/models/sipity/workflow_state_action_permission_spec.rb +1 -1
  540. data/spec/models/sipity/workflow_state_action_spec.rb +1 -1
  541. data/spec/models/sipity/workflow_state_spec.rb +1 -1
  542. data/spec/models/solr_document_spec.rb +24 -0
  543. data/spec/models/user_mailbox_spec.rb +0 -2
  544. data/spec/models/user_spec.rb +7 -7
  545. data/spec/presenters/hyrax/admin/users_presenter_spec.rb +2 -2
  546. data/spec/presenters/hyrax/admin_set_options_presenter_spec.rb +7 -7
  547. data/spec/presenters/hyrax/admin_set_presenter_spec.rb +20 -0
  548. data/spec/presenters/hyrax/collection_options_presenter_spec.rb +2 -0
  549. data/spec/presenters/hyrax/collection_presenter_spec.rb +375 -6
  550. data/spec/presenters/hyrax/file_set_presenter_spec.rb +124 -5
  551. data/spec/presenters/hyrax/inspect_work_presenter_spec.rb +1 -1
  552. data/spec/presenters/hyrax/menu_presenter_spec.rb +5 -0
  553. data/spec/presenters/hyrax/select_collection_type_list_presenter_spec.rb +59 -0
  554. data/spec/presenters/hyrax/select_collection_type_presenter_spec.rb +10 -0
  555. data/spec/presenters/hyrax/select_type_presenter_spec.rb +12 -0
  556. data/spec/presenters/hyrax/work_show_presenter_spec.rb +116 -1
  557. data/spec/presenters/hyrax/workflow_presenter_spec.rb +1 -1
  558. data/spec/renderers/hyrax/renderers/attribute_renderer_spec.rb +6 -6
  559. data/spec/renderers/hyrax/renderers/date_attribute_renderer_spec.rb +2 -2
  560. data/spec/renderers/hyrax/renderers/external_link_attribute_renderer_spec.rb +1 -1
  561. data/spec/renderers/hyrax/renderers/faceted_attribute_renderer_spec.rb +2 -2
  562. data/spec/renderers/hyrax/renderers/license_attribute_renderer_spec.rb +2 -2
  563. data/spec/renderers/hyrax/renderers/linked_attribute_renderer_spec.rb +2 -2
  564. data/spec/renderers/hyrax/renderers/rights_statement_attribute_renderer_spec.rb +10 -1
  565. data/spec/requests/riiif_spec.rb +32 -0
  566. data/spec/routing/collection_permission_templates_routes_spec.rb +31 -0
  567. data/spec/routing/collection_types_routes.rb +35 -0
  568. data/spec/routing/dashboard_routes_spec.rb +37 -0
  569. data/spec/routing/route_spec.rb +4 -10
  570. data/spec/search_builders/hyrax/admin_admin_set_member_search_builder_spec.rb +2 -2
  571. data/spec/search_builders/hyrax/admin_set_search_builder_spec.rb +4 -40
  572. data/spec/search_builders/hyrax/collection_member_search_builder_spec.rb +53 -0
  573. data/spec/search_builders/hyrax/collection_search_builder_spec.rb +74 -0
  574. data/spec/search_builders/hyrax/dashboard/collections_search_builder_spec.rb +92 -0
  575. data/spec/search_builders/hyrax/dashboard/nested_collections_search_builder_spec.rb +85 -0
  576. data/spec/search_builders/hyrax/dashboard/works_search_builder_spec.rb +44 -0
  577. data/spec/search_builders/hyrax/my/collections_search_builder_spec.rb +35 -0
  578. data/spec/search_builders/hyrax/work_search_builder_spec.rb +47 -10
  579. data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +191 -0
  580. data/spec/services/hyrax/admin_set_create_service_spec.rb +6 -2
  581. data/spec/services/hyrax/admin_set_member_service_spec.rb +21 -0
  582. data/spec/services/hyrax/batch_create_failure_service_spec.rb +6 -2
  583. data/spec/services/hyrax/collection_types/create_service_spec.rb +91 -0
  584. data/spec/services/hyrax/collection_types/permissions_service_spec.rb +297 -0
  585. data/spec/services/hyrax/collections/collection_member_service_spec.rb +49 -0
  586. data/spec/services/hyrax/collections/managed_collections_service_spec.rb +17 -0
  587. data/spec/services/hyrax/collections/migration_service_spec.rb +280 -0
  588. data/spec/services/hyrax/collections/nested_collection_persistence_service_spec.rb +28 -0
  589. data/spec/services/hyrax/collections/nested_collection_query_service_spec.rb +353 -0
  590. data/spec/services/hyrax/collections/permissions_create_service_spec.rb +41 -0
  591. data/spec/services/hyrax/collections/permissions_service_spec.rb +278 -0
  592. data/spec/services/hyrax/collections_service_spec.rb +30 -8
  593. data/spec/services/hyrax/embargo_service_spec.rb +26 -5
  594. data/spec/services/hyrax/iiif_authorization_service_spec.rb +43 -0
  595. data/spec/services/hyrax/multiple_membership_checker_spec.rb +155 -0
  596. data/spec/services/hyrax/qa_select_service_spec.rb +8 -2
  597. data/spec/services/hyrax/workflow/notification_configuration_parameter_spec.rb +1 -1
  598. data/spec/services/hyrax/workflow/notification_generator_spec.rb +1 -1
  599. data/spec/services/hyrax/workflow/permission_generator_spec.rb +1 -1
  600. data/spec/services/hyrax/workflow/permission_query_spec.rb +2 -2
  601. data/spec/services/hyrax/workflow/status_list_service_spec.rb +1 -1
  602. data/spec/services/hyrax/workflow/workflow_factory_spec.rb +1 -1
  603. data/spec/services/hyrax/workflow/workflow_schema_spec.rb +1 -1
  604. data/spec/services/hyrax/works/managed_works_service_spec.rb +17 -0
  605. data/spec/spec_helper.rb +34 -4
  606. data/spec/support/features/session_helpers.rb +1 -1
  607. data/spec/support/matchers/collection_type_property_matchers.rb +29 -0
  608. data/spec/test_app_templates/lib/generators/test_app_generator.rb +64 -24
  609. data/spec/views/_flash_msg.html.erb_spec.rb +0 -2
  610. data/spec/views/_user_util_links.html.erb_spec.rb +0 -2
  611. data/spec/views/catalog/_index_list_default.html.erb_spec.rb +9 -9
  612. data/spec/views/hyrax/admin/admin_sets/_form_participant_table.html.erb_spec.rb +42 -20
  613. data/spec/views/hyrax/admin/collection_types/_form.html.erb_spec.rb +43 -0
  614. data/spec/views/hyrax/admin/collection_types/_form_metadata.html.erb_spec.rb +27 -0
  615. data/spec/views/hyrax/admin/collection_types/_form_metadata_admin_set.html.erb_spec.rb +27 -0
  616. data/spec/views/hyrax/admin/collection_types/_form_participants.html.erb_spec.rb +16 -0
  617. data/spec/views/hyrax/admin/collection_types/_form_participants_table.html.erb_spec.rb +73 -0
  618. data/spec/views/hyrax/admin/collection_types/_form_settings.html.erb_spec.rb +106 -0
  619. data/spec/views/hyrax/admin/collection_types/index.html.erb_spec.rb +41 -0
  620. data/spec/views/hyrax/admin/users/index.html.erb_spec.rb +1 -1
  621. data/spec/views/hyrax/base/_form.html.erb_spec.rb +18 -42
  622. data/spec/views/hyrax/base/_form_child_work_relationships.html.erb_spec.rb +11 -22
  623. data/spec/views/hyrax/base/_form_files.html.erb_spec.rb +38 -0
  624. data/spec/views/hyrax/base/_form_progress.html.erb_spec.rb +1 -1
  625. data/spec/views/hyrax/base/_form_relationships.html.erb_spec.rb +1 -2
  626. data/spec/views/hyrax/base/_form_rendering.html.erb_spec.rb +18 -0
  627. data/spec/views/hyrax/base/file_manager.html.erb_spec.rb +1 -1
  628. data/spec/views/hyrax/base/show.html.erb_spec.rb +24 -5
  629. data/spec/views/hyrax/collections/_show_descriptions.html.erb_spec.rb +1 -1
  630. data/spec/views/hyrax/collections/_show_parent_collections.html.erb_spec.rb +124 -0
  631. data/spec/views/hyrax/collections/_sort_and_per_page.html.erb_spec.rb +60 -0
  632. data/spec/views/hyrax/collections/_subcollection_list.html.erb_spec.rb +39 -0
  633. data/spec/views/hyrax/collections/show.html.erb_spec.rb +20 -23
  634. data/spec/views/hyrax/dashboard/_sidebar.html.erb_spec.rb +14 -9
  635. data/spec/views/hyrax/dashboard/collections/_form.html.erb_spec.rb +5 -1
  636. data/spec/views/hyrax/dashboard/collections/_form_branding.html.erb_spec.rb +23 -0
  637. data/spec/views/hyrax/dashboard/collections/_form_discovery.erb_spec.rb +67 -0
  638. data/spec/views/hyrax/dashboard/collections/_form_share.erb_spec.rb +13 -34
  639. data/spec/views/hyrax/dashboard/collections/_form_share_table.html.erb_spec.rb +108 -0
  640. data/spec/views/hyrax/dashboard/collections/_show_actions.html.erb_spec.rb +64 -0
  641. data/spec/views/hyrax/dashboard/collections/_show_add_items_actions.html.erb_spec.rb +44 -0
  642. data/spec/views/hyrax/dashboard/collections/_show_descriptions.html.erb_spec.rb +1 -1
  643. data/spec/views/hyrax/dashboard/collections/_show_parent_collection_row.html.erb_spec.rb +23 -0
  644. data/spec/views/hyrax/dashboard/collections/_show_parent_collections.html.erb_spec.rb +118 -0
  645. data/spec/views/hyrax/dashboard/collections/_show_subcollection_actions.html.erb_spec.rb +62 -0
  646. data/spec/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb_spec.rb +60 -0
  647. data/spec/views/hyrax/dashboard/collections/_subcollection_list.html.erb_spec.rb +63 -0
  648. data/spec/views/hyrax/dashboard/collections/_work_action_menu.html.erb_spec.rb +18 -0
  649. data/spec/views/hyrax/dashboard/collections/edit.html.erb_spec.rb +5 -13
  650. data/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb +86 -9
  651. data/spec/views/hyrax/file_sets/_show_actions.html.erb_spec.rb +1 -1
  652. data/spec/views/hyrax/homepage/_featured_works.html.erb_spec.rb +1 -1
  653. data/spec/views/hyrax/homepage/index.html.erb_spec.rb +14 -5
  654. data/spec/views/hyrax/my/_collection_action_menu.html.erb_spec.rb +65 -0
  655. data/spec/views/hyrax/my/_search_header.html.erb_spec.rb +6 -6
  656. data/spec/views/hyrax/my/_work_action_menu.html.erb_spec.rb +6 -4
  657. data/spec/views/hyrax/my/collections/_list_collections.html.erb_spec.rb +90 -22
  658. data/spec/views/hyrax/my/works/index.html.erb_spec.rb +3 -1
  659. data/spec/views/hyrax/users/_user_info.html.erb_spec.rb +16 -18
  660. data/spec/views/pages/show.html.erb_spec.rb +1 -1
  661. data/spec/views/shared/select_work_type_modal.html.erb_spec.rb +36 -10
  662. data/tasks/hyrax_dev.rake +27 -4
  663. data/template.rb +2 -1
  664. metadata +578 -290
  665. data/.solr_wrapper +0 -6
  666. data/app/assets/javascripts/hyrax/relationships/work.es6 +0 -7
  667. data/app/assets/javascripts/hyrax/workflow_actions_affix.js +0 -14
  668. data/app/assets/stylesheets/hyrax/_work_editor.scss +0 -17
  669. data/app/controllers/concerns/hyrax/parent_container.rb +0 -35
  670. data/app/helpers/dashboard_helper.rb +0 -3
  671. data/app/services/hyrax/parent_service.rb +0 -19
  672. data/app/views/catalog/_show_partials/_default.html.erb +0 -21
  673. data/app/views/catalog/_show_partials/_default_details.html.erb +0 -15
  674. data/app/views/catalog/_show_partials/_facets.html.erb +0 -52
  675. data/app/views/hyrax/base/_browse_everything.html.erb +0 -6
  676. data/app/views/hyrax/base/_find_work_widget.html.erb +0 -10
  677. data/app/views/hyrax/dashboard/collections/_form_default_group.html.erb +0 -25
  678. data/app/views/hyrax/dashboard/collections/_form_permission.html.erb +0 -24
  679. data/app/views/hyrax/file_sets/jq_upload.json.jbuilder +0 -8
  680. data/solr/config/_rest_managed.json +0 -3
  681. data/solr/config/admin-extra.html +0 -31
  682. data/solr/config/elevate.xml +0 -36
  683. data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
  684. data/solr/config/protwords.txt +0 -21
  685. data/solr/config/schema.xml +0 -366
  686. data/solr/config/scripts.conf +0 -24
  687. data/solr/config/solrconfig.xml +0 -322
  688. data/solr/config/spellings.txt +0 -2
  689. data/solr/config/stopwords.txt +0 -58
  690. data/solr/config/stopwords_en.txt +0 -58
  691. data/solr/config/synonyms.txt +0 -31
  692. data/solr/config/xslt/example.xsl +0 -132
  693. data/solr/config/xslt/example_atom.xsl +0 -67
  694. data/solr/config/xslt/example_rss.xsl +0 -66
  695. data/solr/config/xslt/luke.xsl +0 -337
  696. data/spec/abilities/admin_set_abilities_spec.rb +0 -15
  697. data/spec/abilities/collection_abilities_spec.rb +0 -51
  698. data/spec/features/admin_admin_set_spec.rb +0 -30
  699. data/spec/helpers/hyrax/citations_behaviors/formatters/chicago_formatter_spec.rb +0 -10
  700. data/spec/services/hyrax/parent_service_spec.rb +0 -11
  701. data/spec/support/uploaded_file_monkeypatch.rb +0 -6
  702. data/spec/views/hyrax/base/_browse_everything.html.erb_spec.rb +0 -17
  703. data/spec/views/hyrax/base/_find_work_widget.html.erb_spec.rb +0 -20
@@ -0,0 +1,233 @@
1
+ module Hyrax
2
+ module CollectionTypes
3
+ class PermissionsService
4
+ # @api public
5
+ #
6
+ # Ids of collection types that a user can create or manage
7
+ #
8
+ # @param roles [String] type of access, Hyrax::CollectionTypeParticipant::MANAGE_ACCESS and/or Hyrax::CollectionTypeParticipant::CREATE_ACCESS
9
+ # @param user [User] user (required if ability is nil)
10
+ # @param ability [Ability] the ability coming from cancan ability check (default: nil) (required if user is nil)
11
+ # @return [Array<String>] ids for collection types for which a user has the specified role
12
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
13
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
14
+ def self.collection_type_ids_for_user(roles:, user: nil, ability: nil)
15
+ return false unless user.present? || ability.present?
16
+ return Hyrax::CollectionType.all.pluck('DISTINCT id') if user_admin?(user, ability)
17
+ Hyrax::CollectionTypeParticipant.where(agent_type: Hyrax::CollectionTypeParticipant::USER_TYPE,
18
+ agent_id: user_id(user, ability),
19
+ access: roles)
20
+ .or(
21
+ Hyrax::CollectionTypeParticipant.where(agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE,
22
+ agent_id: user_groups(user, ability),
23
+ access: roles)
24
+ ).pluck('DISTINCT hyrax_collection_type_id')
25
+ end
26
+
27
+ # @api public
28
+ #
29
+ # Instances of collection types that a user can create or manage
30
+ #
31
+ # @param roles [String] type of access, Hyrax::CollectionTypeParticipant::MANAGE_ACCESS and/or Hyrax::CollectionTypeParticipant::CREATE_ACCESS
32
+ # @param user [User] user (required if ability is nil)
33
+ # @param ability [Ability] the ability coming from cancan ability check (default: nil) (required if user is nil)
34
+ # @return [Array<Hyrax::CollectionType>] instances of collection types for which a user has the specified role
35
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
36
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
37
+ def self.collection_types_for_user(roles:, user: nil, ability: nil)
38
+ return false unless user.present? || ability.present?
39
+ return Hyrax::CollectionType.all if user_admin?(user, ability)
40
+ Hyrax::CollectionType.where(id: collection_type_ids_for_user(user: user, roles: roles, ability: ability))
41
+ end
42
+
43
+ # @api public
44
+ #
45
+ # Is the user a creator for any collection types?
46
+ #
47
+ # @param user [User] user (required if ability is nil)
48
+ # @param ability [Ability] the ability coming from cancan ability check (default: nil) (required if user is nil)
49
+ # @return [Boolean] true if the user has permission to create collections of at least one collection type
50
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
51
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
52
+ def self.can_create_any_collection_type?(user: nil, ability: nil)
53
+ return false unless user.present? || ability.present?
54
+ return true if user_admin?(user, ability)
55
+ # both manage and create access can create collections of a type, so no need to include access in the query
56
+ return true if Hyrax::CollectionTypeParticipant.where(agent_type: Hyrax::CollectionTypeParticipant::USER_TYPE,
57
+ agent_id: user_id(user, ability)).any?
58
+ return true if Hyrax::CollectionTypeParticipant.where(agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE,
59
+ agent_id: user_groups(user, ability)).any?
60
+ false
61
+ end
62
+
63
+ # @api public
64
+ #
65
+ # Is the user a creator for admin sets collection types?
66
+ #
67
+ # @param user [User] user (required if ability is nil)
68
+ # @param ability [Ability] the ability coming from cancan ability check (default: nil) (required if user is nil)
69
+ # @return [Boolean] true if the user has permission to create collections of type admin_set
70
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
71
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
72
+ def self.can_create_admin_set_collection_type?(user: nil, ability: nil)
73
+ return false unless user.present? || ability.present?
74
+ return true if user_admin?(user, ability)
75
+ # both manage and create access can create collections of a type, so no need to include access in the query
76
+ return true if Hyrax::CollectionTypeParticipant.joins(:hyrax_collection_type)
77
+ .where(agent_type: Hyrax::CollectionTypeParticipant::USER_TYPE,
78
+ agent_id: user_id(user, ability),
79
+ hyrax_collection_types: { machine_id: Hyrax::CollectionType::ADMIN_SET_MACHINE_ID }).present?
80
+ return true if Hyrax::CollectionTypeParticipant.joins(:hyrax_collection_type)
81
+ .where(agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE,
82
+ agent_id: user_groups(user, ability),
83
+ hyrax_collection_types: { machine_id: Hyrax::CollectionType::ADMIN_SET_MACHINE_ID }).present?
84
+ false
85
+ end
86
+
87
+ # @api public
88
+ #
89
+ # Get a list of collection types that a user can create
90
+ #
91
+ # @param user [User] user (required if ability is nil)
92
+ # @param ability [Ability] the ability coming from cancan ability check (default: nil) (required if user is nil)
93
+ # @return [Array<Hyrax::CollectionType>] array of collection types the user can create
94
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
95
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
96
+ def self.can_create_collection_types(user: nil, ability: nil)
97
+ collection_types_for_user(user: user, ability: ability, roles: [Hyrax::CollectionTypeParticipant::MANAGE_ACCESS, Hyrax::CollectionTypeParticipant::CREATE_ACCESS])
98
+ end
99
+
100
+ # @api public
101
+ #
102
+ # Get a list of collection types that a user can create
103
+ #
104
+ # @param collection_type [Hyrax::CollectionType] the type of the collection being created
105
+ # @param user [User] user (required if ability is nil)
106
+ # @param ability [Ability] the ability coming from cancan ability check (default: nil) (required if user is nil)
107
+ # @return [Boolean] true if the user has permission to create collections of specified type
108
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
109
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
110
+ def self.can_create_collection_of_type?(collection_type:, user: nil, ability: nil)
111
+ manage_access_for_collection_type?(user: user, ability: ability, collection_type: collection_type) ||
112
+ create_access_for_collection_type?(user: user, ability: ability, collection_type: collection_type)
113
+ end
114
+
115
+ # @api private
116
+ #
117
+ # Determine if the given user has :manage access for the given collection type
118
+ #
119
+ # @param collection_type [Hyrax::CollectionType] the collection type we are checking permissions on
120
+ # @param user [User] user (required if ability is nil)
121
+ # @param ability [Ability] the ability coming from cancan ability check (default: nil) (required if user is nil)
122
+ # @return [Boolean] true if the user has permission to manage collections of the specified collection type
123
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
124
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
125
+ def self.manage_access_for_collection_type?(collection_type:, user: nil, ability: nil)
126
+ access_to_collection_type?(user: user, ability: ability, collection_type: collection_type, access: 'manage')
127
+ end
128
+ private_class_method :manage_access_for_collection_type?
129
+
130
+ # @api private
131
+ #
132
+ # Determine if the given user has :create access for the given collection type
133
+ #
134
+ # @param collection_type [Hyrax::CollectionType] the collection type we are checking permissions on
135
+ # @param user [User] user (required if ability is nil)
136
+ # @param ability [Ability] the ability coming from cancan ability check (default: nil) (required if user is nil)
137
+ # @return [Boolean] true if the user has permission to create collections of the specified collection type
138
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
139
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
140
+ def self.create_access_for_collection_type?(collection_type:, user: nil, ability: nil)
141
+ access_to_collection_type?(user: user, ability: ability, collection_type: collection_type, access: 'create')
142
+ end
143
+ private_class_method :create_access_for_collection_type?
144
+
145
+ # @api private
146
+ #
147
+ # Determine if the given user has specified access for the given collection type
148
+ #
149
+ # @param collection_type [Hyrax::CollectionType] the collection type we are checking permissions on
150
+ # @param access [Symbol] the access level to check
151
+ # @param user [User] user (required if ability is nil)
152
+ # @param ability [Ability] the ability coming from cancan ability check (default: nil) (required if user is nil)
153
+ # @return [Boolean] true if the user has permission to create collections of the specified collection type
154
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
155
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
156
+ def self.access_to_collection_type?(collection_type:, access:, user: nil, ability: nil) # rubocop:disable Metrics/CyclomaticComplexity
157
+ return false unless user.present? || ability.present?
158
+ return false unless user && collection_type
159
+ return true if ([user_id(user, ability)] & agent_ids_for(collection_type: collection_type, agent_type: 'user', access: access)).present?
160
+ return true if (user_groups(user, ability) & agent_ids_for(collection_type: collection_type, agent_type: 'group', access: access)).present?
161
+ false
162
+ end
163
+ private_class_method :access_to_collection_type?
164
+
165
+ # @api public
166
+ #
167
+ # What types of collection can the user create or manage
168
+ #
169
+ # @param user [User] user - The user requesting to create/manage a Collection
170
+ # @param roles [String] type of access, Hyrax::CollectionTypeParticipant::MANAGE_ACCESS and/or Hyrax::CollectionTypeParticipant::CREATE_ACCESS
171
+ # @return [Array<Hyrax::CollectionType>]
172
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
173
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
174
+ def self.agent_ids_for(collection_type:, agent_type:, access:)
175
+ Hyrax::CollectionTypeParticipant.where(hyrax_collection_type_id: collection_type.id,
176
+ agent_type: agent_type,
177
+ access: access).pluck('DISTINCT agent_id')
178
+ end
179
+ private_class_method :agent_ids_for
180
+
181
+ # @api public
182
+ #
183
+ # Get a list of users who should be added as user editors for a new collection of the specified collection type
184
+ #
185
+ # @param collection_type [Hyrax::CollectionType] the type of the collection being created
186
+ # @return [Array<String>] array of user identifiers (typically emails) for users who can edit collections of this type
187
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
188
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
189
+ def self.user_edit_grants_for_collection_of_type(collection_type: nil)
190
+ return [] unless collection_type
191
+ Hyrax::CollectionTypeParticipant.joins(:hyrax_collection_type).where(hyrax_collection_type_id: collection_type.id,
192
+ agent_type: Hyrax::CollectionTypeParticipant::USER_TYPE,
193
+ access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS).pluck('DISTINCT agent_id')
194
+ end
195
+
196
+ # @api public
197
+ #
198
+ # Get a list of group that should be added as group editors for a new collection of the specified collection type
199
+ #
200
+ # @param collection_type [Hyrax::CollectionType] the type of the collection being created
201
+ # @return [Array<String>] array of group identifiers (typically groupname) for groups who can edit collections of this type
202
+ # @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
203
+ # If calling from Abilities, pass the ability. If you try to get the ability from the user, you end up in an infinit loop.
204
+ def self.group_edit_grants_for_collection_of_type(collection_type: nil)
205
+ return [] unless collection_type
206
+ groups = Hyrax::CollectionTypeParticipant.joins(:hyrax_collection_type).where(hyrax_collection_type_id: collection_type.id,
207
+ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE,
208
+ access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS).pluck('DISTINCT agent_id')
209
+ groups | ['admin']
210
+ end
211
+
212
+ def self.user_groups(user, ability)
213
+ # if called from abilities class, use ability instead of user; otherwise, you end up in an infinite loop
214
+ return ability.user_groups if ability.present?
215
+ user.ability.user_groups
216
+ end
217
+ private_class_method :user_groups
218
+
219
+ def self.user_admin?(user, ability)
220
+ # if called from abilities class, use ability instead of user; otherwise, you end up in an infinite loop
221
+ return ability.admin? if ability.present?
222
+ user.ability.admin?
223
+ end
224
+ private_class_method :user_groups
225
+
226
+ def self.user_id(user, ability)
227
+ return ability.current_user.user_key if ability.present?
228
+ user.user_key
229
+ end
230
+ private_class_method :user_id
231
+ end
232
+ end
233
+ end
@@ -0,0 +1,91 @@
1
+ module Hyrax
2
+ module Collections
3
+ # Responsible for retrieving collection members
4
+ class CollectionMemberService
5
+ attr_reader :scope, :params, :collection
6
+ delegate :repository, to: :scope
7
+
8
+ # @param scope [#repository] Typically a controller object which responds to :repository
9
+ # @param [Collection]
10
+ # @param [ActionController::Parameters] query params
11
+ def initialize(scope:, collection:, params:)
12
+ @scope = scope
13
+ @collection = collection
14
+ @params = params
15
+ end
16
+
17
+ # @api public
18
+ #
19
+ # Collections which are members of the given collection
20
+ # @return [Blacklight::Solr::Response] {up to 50 solr documents}
21
+ def available_member_subcollections
22
+ query_solr(query_builder: subcollections_search_builder, query_params: params_for_subcollections)
23
+ end
24
+
25
+ # @api public
26
+ #
27
+ # Works which are members of the given collection
28
+ # @return [Blacklight::Solr::Response]
29
+ def available_member_works
30
+ query_solr(query_builder: works_search_builder, query_params: params)
31
+ end
32
+
33
+ # @api public
34
+ #
35
+ # Work ids of the works which are members of the given collection
36
+ # @return [Blacklight::Solr::Response]
37
+ def available_member_work_ids
38
+ query_solr_with_field_selection(query_builder: work_ids_search_builder, fl: 'id')
39
+ end
40
+
41
+ private
42
+
43
+ # @api private
44
+ #
45
+ # set up a member search builder for works only
46
+ # @return [CollectionMemberSearchBuilder] new or existing
47
+ def works_search_builder
48
+ @works_search_builder ||= Hyrax::CollectionMemberSearchBuilder.new(scope: scope, collection: collection, search_includes_models: :works)
49
+ end
50
+
51
+ # @api private
52
+ #
53
+ # set up a member search builder for collections only
54
+ # @return [CollectionMemberSearchBuilder] new or existing
55
+ def subcollections_search_builder
56
+ @subcollections_search_builder ||= Hyrax::CollectionMemberSearchBuilder.new(scope: scope, collection: collection, search_includes_models: :collections)
57
+ end
58
+
59
+ # @api private
60
+ #
61
+ # set up a member search builder for returning work ids only
62
+ # @return [CollectionMemberSearchBuilder] new or existing
63
+ def work_ids_search_builder
64
+ @work_ids_search_builder ||= Hyrax::CollectionMemberSearchBuilder.new(scope: scope, collection: collection, search_includes_models: :works)
65
+ end
66
+
67
+ # @api private
68
+ #
69
+ def query_solr(query_builder:, query_params:)
70
+ repository.search(query_builder.with(query_params).query)
71
+ end
72
+
73
+ # @api private
74
+ #
75
+ def query_solr_with_field_selection(query_builder:, fl:)
76
+ repository.search(query_builder.merge(fl: fl).query)
77
+ end
78
+
79
+ # @api private
80
+ #
81
+ # Blacklight pagination still needs to be overridden and set up for the subcollections.
82
+ # @return <Hash> the additional inputs required for the subcollection member search builder
83
+ def params_for_subcollections
84
+ # To differentiate current page for works vs subcollections, we have to use a sub_collection_page
85
+ # param. Map this to the page param before querying for subcollections, if it's present
86
+ params[:page] = params.delete(:sub_collection_page)
87
+ params
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,16 @@
1
+ module Hyrax
2
+ module Collections
3
+ module ManagedCollectionsService
4
+ # @api public
5
+ #
6
+ # Count of collections the current user can manage.
7
+ #
8
+ # @param scope [Object] Typically a controller object that responds to `repository`, `can?`, `blacklight_config`, `current_ability`
9
+ # @return [Array<SolrDocument>]
10
+ def self.managed_collections_count(scope:)
11
+ query_builder = Hyrax::Dashboard::CollectionsSearchBuilder.new(scope).rows(0)
12
+ scope.repository.search(query_builder.query).response["numFound"]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,81 @@
1
+ module Hyrax
2
+ module Collections
3
+ # Responsible for migrating legacy collections. Legacy collections are those created before Hyrax 2.1.0 and
4
+ # are identified by the lack of the collection having a collection type gid.
5
+ class MigrationService
6
+ # @api public
7
+ #
8
+ # Migrate all legacy collections to extended collections with collection type assigned. Legacy collections are those
9
+ # created before Hyrax 2.1.0 and are identified by the lack of the collection having a collection type gid.
10
+ def self.migrate_all_collections
11
+ Rails.logger.info "*** Migrating #{Collection.count} collections"
12
+ Collection.all.each do |col|
13
+ migrate_collection(col)
14
+ Rails.logger.info " migrating collection - id: #{col.id}, title: #{col.title}"
15
+ end
16
+ Rails.logger.info "--- Migration Complete"
17
+ end
18
+
19
+ # @api private
20
+ #
21
+ # Migrate a single legacy collection to extended collections with collection type assigned. Legacy collections are those
22
+ # created before Hyrax 2.1.0 and are identified by the lack of the collection having a collection type gid.
23
+ #
24
+ # @param collection [Collection] collection object to be migrated
25
+ def self.migrate_collection(collection)
26
+ return if collection.collection_type_gid.present? # already migrated
27
+ collection.collection_type_gid = Hyrax::CollectionType.find_or_create_default_collection_type.gid
28
+ create_permissions(collection)
29
+ collection.save
30
+ end
31
+ private_class_method :migrate_collection
32
+
33
+ # @api public
34
+ #
35
+ # Validate that migrated collections have both the collection type gid assigned and the permission template with
36
+ # access created and associated with the collection. Any collection without collection type gid as nil or assigned
37
+ # the default collection type are ignored.
38
+ def self.repair_migrated_collections
39
+ Rails.logger.info "*** Repairing migrated collections"
40
+ Collection.all.each do |col|
41
+ repair_migrated_collection(col)
42
+ Rails.logger.info " migrating collection - id: #{col.id}, title: #{col.title}"
43
+ end
44
+ Rails.logger.info "--- Migration Complete"
45
+ end
46
+
47
+ # @api private
48
+ #
49
+ # Validate and repair a migrated collection if needed.
50
+ #
51
+ # @param collection [Collection] collection object to be migrated/repaired
52
+ def self.repair_migrated_collection(collection)
53
+ return if collection.collection_type_gid.present? && collection.collection_type_gid != Hyrax::CollectionType.find_or_create_default_collection_type.gid
54
+ collection.collection_type_gid = Hyrax::CollectionType.find_or_create_default_collection_type.gid
55
+ permission_template = Hyrax::PermissionTemplate.find_by(source_id: collection.id)
56
+ if permission_template.present?
57
+ collection.reset_access_controls!
58
+ else
59
+ create_permissions(collection)
60
+ end
61
+ collection.save
62
+ end
63
+ private_class_method :repair_migrated_collection
64
+
65
+ # @api private
66
+ #
67
+ # Determine if collection was already migrated.
68
+ #
69
+ # @param [Collection] collection object to be validated
70
+ def self.create_permissions(collection)
71
+ grants = []
72
+ collection.edit_groups.each { |g| grants << { agent_type: 'group', agent_id: g, access: Hyrax::PermissionTemplateAccess::MANAGE } }
73
+ collection.edit_users.each { |u| grants << { agent_type: 'user', agent_id: u, access: Hyrax::PermissionTemplateAccess::MANAGE } }
74
+ collection.read_groups.each { |g| grants << { agent_type: 'group', agent_id: g, access: Hyrax::PermissionTemplateAccess::VIEW } }
75
+ collection.read_users.each { |u| grants << { agent_type: 'user', agent_id: u, access: Hyrax::PermissionTemplateAccess::VIEW } }
76
+ Hyrax::Collections::PermissionsCreateService.create_default(collection: collection, creating_user: ::User.find_by_user_key(collection.depositor), grants: grants)
77
+ end
78
+ private_class_method :create_permissions
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,26 @@
1
+ module Hyrax
2
+ module Collections
3
+ module NestedCollectionPersistenceService
4
+ # @api public
5
+ #
6
+ # Responsible for persisting the relationship between the parent and the child.
7
+ # @see Hyrax::Collections::NestedCollectionQueryService
8
+ #
9
+ # @param parent [Collection]
10
+ # @param child [Collection]
11
+ # @note There is odd permission arrangement based on the NestedCollectionQueryService:
12
+ # You can nest the child within a parent if you can edit the parent and read the child.
13
+ # See https://wiki.duraspace.org/display/samvera/Samvera+Tech+Call+2017-08-23 for tech discussion.
14
+ def self.persist_nested_collection_for(parent:, child:)
15
+ child.member_of_collections << parent
16
+ child.save
17
+ end
18
+
19
+ def self.remove_nested_relationship_for(parent:, child:)
20
+ child.member_of_collections.delete(parent)
21
+ child.save
22
+ true
23
+ end
24
+ end
25
+ end
26
+ end