hyrax 2.3.3 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/.github/stale.yml +19 -0
  4. data/README.md +2 -2
  5. data/app/actors/hyrax/actors/apply_permission_template_actor.rb +2 -4
  6. data/app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb +45 -0
  7. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +96 -0
  8. data/app/actors/hyrax/actors/file_set_ordered_members_actor.rb +16 -0
  9. data/app/actors/hyrax/actors/ordered_members_actor.rb +28 -0
  10. data/app/assets/javascripts/hyrax/collections.js +2 -0
  11. data/app/assets/stylesheets/hyrax/_file-listing.scss +2 -1
  12. data/app/assets/stylesheets/hyrax/_work-show.scss +4 -0
  13. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +1 -1
  14. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +5 -2
  15. data/app/controllers/hyrax/dashboard/nest_collections_controller.rb +2 -9
  16. data/app/helpers/hyrax/batch_edits_helper.rb +0 -1
  17. data/app/helpers/hyrax/hyrax_helper_behavior.rb +1 -0
  18. data/app/helpers/hyrax/iiif_helper.rb +12 -0
  19. data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +41 -0
  20. data/app/presenters/hyrax/work_show_presenter.rb +29 -2
  21. data/app/services/hyrax/permission_template_applicator.rb +48 -0
  22. data/app/views/hyrax/admin/collection_types/_form_settings.html.erb +1 -1
  23. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  24. data/app/views/hyrax/base/_form_rendering.html.erb +7 -5
  25. data/app/views/hyrax/base/_form_representative.html.erb +4 -2
  26. data/app/views/hyrax/base/_form_thumbnail.html.erb +4 -2
  27. data/app/views/hyrax/base/_member.html.erb +1 -1
  28. data/app/views/hyrax/base/_representative_media.html.erb +1 -4
  29. data/app/views/hyrax/base/_show_actions.html.erb +6 -4
  30. data/app/views/hyrax/base/iiif_viewers/_universal_viewer.html.erb +4 -0
  31. data/app/views/hyrax/base/show.html.erb +2 -2
  32. data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
  33. data/app/views/hyrax/file_sets/_file_set_title.erb +2 -2
  34. data/app/views/hyrax/homepage/_featured.html.erb +0 -3
  35. data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -0
  36. data/app/views/hyrax/my/collections/_default_group.html.erb +1 -9
  37. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  38. data/app/views/hyrax/users/_activity_log.html.erb +1 -1
  39. data/config/locales/hyrax.de.yml +2 -0
  40. data/config/locales/hyrax.en.yml +2 -0
  41. data/config/locales/hyrax.es.yml +2 -0
  42. data/config/locales/hyrax.fr.yml +2 -0
  43. data/config/locales/hyrax.it.yml +2 -0
  44. data/config/locales/hyrax.pt-BR.yml +2 -0
  45. data/config/locales/hyrax.zh.yml +2 -0
  46. data/hyrax.gemspec +1 -0
  47. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +1 -1
  48. data/lib/generators/hyrax/templates/config/locales/hyrax.de.yml +1 -1
  49. data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +1 -1
  50. data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +1 -1
  51. data/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +1 -1
  52. data/lib/generators/hyrax/templates/config/locales/hyrax.it.yml +1 -1
  53. data/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +1 -1
  54. data/lib/hyrax/configuration.rb +1 -1
  55. data/lib/hyrax/transactions.rb +23 -0
  56. data/lib/hyrax/transactions/container.rb +63 -0
  57. data/lib/hyrax/transactions/create_work.rb +47 -0
  58. data/lib/hyrax/transactions/steps/apply_permission_template.rb +29 -0
  59. data/lib/hyrax/transactions/steps/ensure_admin_set.rb +23 -0
  60. data/lib/hyrax/transactions/steps/ensure_permission_template.rb +27 -0
  61. data/lib/hyrax/transactions/steps/save_work.rb +35 -0
  62. data/lib/hyrax/transactions/steps/set_default_admin_set.rb +25 -0
  63. data/lib/hyrax/transactions/steps/set_modified_date.rb +25 -0
  64. data/lib/hyrax/transactions/steps/set_uploaded_date.rb +28 -0
  65. data/lib/hyrax/version.rb +1 -1
  66. data/spec/actors/hyrax/actors/create_with_files_ordered_members_actor_spec.rb +41 -0
  67. data/spec/actors/hyrax/actors/create_with_remote_files_ordered_members_actor_spec.rb +49 -0
  68. data/spec/actors/hyrax/actors/file_set_ordered_members_actor_spec.rb +35 -0
  69. data/spec/actors/hyrax/actors/ordered_members_actor_spec.rb +59 -0
  70. data/spec/controllers/hyrax/embargoes_controller_spec.rb +2 -0
  71. data/spec/controllers/hyrax/generic_works_controller_spec.rb +6 -1
  72. data/spec/factories/generic_works.rb +6 -0
  73. data/spec/features/collection_multi_membership_spec.rb +6 -6
  74. data/spec/features/work_show_spec.rb +58 -5
  75. data/spec/helpers/hyrax/batch_edits_helper_spec.rb +4 -2
  76. data/spec/helpers/hyrax/iiif_helper_spec.rb +44 -0
  77. data/spec/hyrax/transactions/create_work_spec.rb +155 -0
  78. data/spec/hyrax/transactions/steps/apply_permission_template_spec.rb +72 -0
  79. data/spec/hyrax/transactions/steps/ensure_admin_set_spec.rb +25 -0
  80. data/spec/hyrax/transactions/steps/ensure_permission_template_spec.rb +33 -0
  81. data/spec/hyrax/transactions/steps/save_work_spec.rb +32 -0
  82. data/spec/hyrax/transactions/steps/set_default_admin_set_spec.rb +38 -0
  83. data/spec/hyrax/transactions/steps/set_modified_date_spec.rb +22 -0
  84. data/spec/hyrax/transactions/steps/set_uploaded_date_spec.rb +32 -0
  85. data/spec/jobs/attach_files_to_work_with_ordered_members_job_spec.rb +13 -0
  86. data/spec/presenters/hyrax/presenter_renderer_spec.rb +4 -2
  87. data/spec/presenters/hyrax/work_show_presenter_spec.rb +46 -2
  88. data/spec/services/hyrax/permission_template_applicator_spec.rb +69 -0
  89. data/spec/spec_helper.rb +13 -2
  90. data/spec/views/catalog/index.html.erb_spec.rb +7 -4
  91. data/spec/views/hyrax/admin/admin_sets/_show_actions.html.erb_spec.rb +2 -0
  92. data/spec/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb_spec.rb +4 -1
  93. data/spec/views/hyrax/admin/admin_sets/index.html.erb_spec.rb +6 -2
  94. data/spec/views/hyrax/admin/admin_sets/index.json.erb_spec.rb +1 -2
  95. data/spec/views/hyrax/admin/collection_types/_form_metadata_admin_set.html.erb_spec.rb +1 -1
  96. data/spec/views/hyrax/admin/collection_types/_form_settings.html.erb_spec.rb +5 -26
  97. data/spec/views/hyrax/admin/collection_types/index.html.erb_spec.rb +26 -5
  98. data/spec/views/hyrax/admin/stats/show.html.erb_spec.rb +1 -0
  99. data/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb +5 -1
  100. data/spec/views/hyrax/base/_attributes.html.erb_spec.rb +1 -0
  101. data/spec/views/hyrax/base/_form_rendering.html.erb_spec.rb +5 -1
  102. data/spec/views/hyrax/base/_items.html.erb_spec.rb +2 -0
  103. data/spec/views/hyrax/base/_relationships.html.erb_spec.rb +2 -1
  104. data/spec/views/hyrax/base/_show_actions.html.erb_spec.rb +71 -0
  105. data/spec/views/hyrax/base/file_manager.html.erb_spec.rb +11 -14
  106. data/spec/views/hyrax/base/show.html.erb_spec.rb +2 -2
  107. data/spec/views/hyrax/base/show.json.jbuilder_spec.rb +3 -1
  108. data/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb +6 -1
  109. data/spec/views/hyrax/collections/_show_parent_collections.html.erb_spec.rb +5 -5
  110. data/spec/views/hyrax/collections/_subcollection_list.html.erb_spec.rb +1 -1
  111. data/spec/views/hyrax/collections/show.html.erb_spec.rb +3 -2
  112. data/spec/views/hyrax/dashboard/collections/_form_share.erb_spec.rb +1 -1
  113. data/spec/views/hyrax/dashboard/collections/_form_share_table.html.erb_spec.rb +1 -1
  114. data/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb +6 -1
  115. data/spec/views/hyrax/dashboard/collections/_subcollection_list.html.erb_spec.rb +1 -1
  116. data/spec/views/hyrax/dashboard/collections/edit.html.erb_spec.rb +3 -1
  117. data/spec/views/hyrax/dashboard/profiles/show.html.erb_spec.rb +2 -3
  118. data/spec/views/hyrax/file_sets/_show_characterization_details.html.erb_spec.rb +1 -2
  119. data/spec/views/hyrax/file_sets/_single_use_links.html.erb_spec.rb +1 -2
  120. data/spec/views/hyrax/homepage/_sortable_featured.html.erb_spec.rb +1 -1
  121. data/spec/views/hyrax/my/_collection_action_menu.html.erb_spec.rb +5 -5
  122. data/spec/views/hyrax/my/collections/_list_collections.html.erb_spec.rb +11 -8
  123. data/spec/views/hyrax/users/index.html.erb_spec.rb +1 -0
  124. data/spec/views/hyrax/users/show.html.erb_spec.rb +3 -0
  125. data/template.rb +1 -1
  126. metadata +65 -3
  127. data/app/views/hyrax/dashboard/collections/_form_default_group_delt.html.erb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8958d9121950df386c4f7d5cb5bcc9095711589c
4
- data.tar.gz: 151738983808dfd64b6144babd565a4a315d1c6f
3
+ metadata.gz: d34c51d077dddcd6a5932d22a633104906b17e30
4
+ data.tar.gz: f61e880d0705b2863c0edf50e0066b8cf4df41c3
5
5
  SHA512:
6
- metadata.gz: 7fac71e43de81973e966ab8ac058b7f127153cb1160f162b92a2a7125543e2f641b5738dc0d4c5b59d234058e21f707c61f3510b6b9d222d2b643fdd8d905ed3
7
- data.tar.gz: 8798a1276dea980bbc2945f4e7629f663a9df0905c19c97f881c4650df2251c77998a2f8fe25ac61e23f755649706424059d5c74fd6f55d76d9834f61a937467
6
+ metadata.gz: bcda312829b2581af6d701b0a57cc11e99d26e12c4405fc5f8ecb814328cdc94a5ed74cb5deb0583b995b8ffd64127f806c4b7fb64a37372610ddf2d0e477d44
7
+ data.tar.gz: 70e85336f1286e3749f22f8cd4ee8d3607a4f06bc9dda48429cf37f53041b7d9012ddb1628bc97ae1de8d17622019e6f20d37f66bd920adb272fe1996a96954c
@@ -12,7 +12,7 @@ jobs:
12
12
  - image: ualbertalib/docker-fcrepo4:4.7
13
13
  environment:
14
14
  CATALINA_OPTS: "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
15
- - image: solr:7
15
+ - image: solr:7-alpine
16
16
  command: bin/solr -cloud -noprompt -f -p 8985
17
17
 
18
18
  # Specify service dependencies here if necessary
@@ -0,0 +1,19 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 30
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 14
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: stale
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ activity for 30 days. It will be closed if no further activity occurs within 14 days. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
18
+ # Limit to only `issues` or `pulls`
19
+ only: pulls
data/README.md CHANGED
@@ -64,7 +64,7 @@ The Samvera community is here to help. Please see our [support guide](./.github/
64
64
  # Getting started
65
65
 
66
66
  This document contains instructions specific to setting up an app with __Hyrax
67
- v2.3.3__. If you are looking for instructions on installing a different
67
+ v2.4.0__. If you are looking for instructions on installing a different
68
68
  version, be sure to select the appropriate branch or tag from the drop-down
69
69
  menu above.
70
70
 
@@ -163,7 +163,7 @@ NOTE: The steps need to be done in order to create a new Hyrax based app.
163
163
  Generate a new Rails application using the template.
164
164
 
165
165
  ```
166
- rails _5.1.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v2.3.3/template.rb
166
+ rails _5.1.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v2.4.0/template.rb
167
167
  ```
168
168
 
169
169
  Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
@@ -31,10 +31,8 @@ module Hyrax
31
31
  end
32
32
 
33
33
  def set_curation_concern_access(env, template)
34
- env.curation_concern.edit_users += template.agent_ids_for(agent_type: 'user', access: 'manage')
35
- env.curation_concern.edit_groups += template.agent_ids_for(agent_type: 'group', access: 'manage')
36
- env.curation_concern.read_users += template.agent_ids_for(agent_type: 'user', access: 'view')
37
- env.curation_concern.read_groups += template.agent_ids_for(agent_type: 'group', access: 'view')
34
+ PermissionTemplateApplicator
35
+ .apply(template).to(model: env.curation_concern)
38
36
  end
39
37
  end
40
38
  end
@@ -0,0 +1,45 @@
1
+ module Hyrax
2
+ module Actors
3
+ # When adding member FileSets to a Work, Hyrax saves
4
+ # and reloads the work for each new member FileSet.
5
+ # This can significantly slow down ingest for Works
6
+ # with many member FileSets. The saving and reloading
7
+ # happens in FileSetActor#attach_to_work.
8
+ #
9
+ # This is a 'swappable' alternative approach. It will
10
+ # be of most value to Hyrax applications dealing with
11
+ # works with many filesets. Anecdotally, a work with
12
+ # 600 filesets can be processed in ~15 mins versus
13
+ # > 3 hours with the standard approach.
14
+ #
15
+ # The tradeoff is that the ordered members are now added in a
16
+ # single step after the creation of all the FileSets, thus
17
+ # introducing a slight risk of orphan filesets if the upload
18
+ # fails before the addition of the ordered members. This
19
+ # has not been observed in practice.
20
+ #
21
+ # Swapping out the actors can be achieved thus:
22
+ #
23
+ # In `config/initializers/hyrax.rb`:
24
+ # ```
25
+ # Hyrax::CurationConcern.actor_factory.swap(Hyrax::Actors::CreateWithFilesActor,
26
+ # Hyrax::Actors::CreateWithFilesOrderedMembersActor)
27
+ # ```
28
+ # Alternatively, in `config/application.rb`:
29
+ # ```
30
+ # config.to_prepare
31
+ # Hyrax::CurationConcern.actor_factory.swap(Hyrax::Actors::CreateWithFilesActor,
32
+ # Hyrax::Actors::CreateWithFilesOrderedMembersActor)
33
+ # end
34
+ # ```
35
+ # Creates a work and attaches files to the work
36
+ class CreateWithFilesOrderedMembersActor < CreateWithFilesActor
37
+ # @return [TrueClass]
38
+ def attach_files(files, env)
39
+ return true if files.blank?
40
+ AttachFilesToWorkWithOrderedMembersJob.perform_later(env.curation_concern, files, env.attributes.to_h.symbolize_keys)
41
+ true
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,96 @@
1
+ module Hyrax
2
+ module Actors
3
+ # When adding member FileSets to a Work, Hyrax saves
4
+ # and reloads the work for each new member FileSet.
5
+ # This can significantly slow down ingest for Works
6
+ # with many member FileSets. The saving and reloading
7
+ # happens in FileSetActor#attach_to_work.
8
+ #
9
+ # This is a 'swappable' alternative approach. It will
10
+ # be of most value to Hyrax applications dealing with
11
+ # works with many filesets. Anecdotally, a 600 fileset
12
+ # can be processed in ~15 mins versus >3 hours
13
+ # with the standard approach.
14
+ #
15
+ # The tradeoff is that the ordered members are now added in a
16
+ # single step after the creation of all the FileSets, thus
17
+ # introducing a slight risk of orphan filesets if the upload
18
+ # fails before the addition of the ordered members. This
19
+ # has not been observed in practice.
20
+ #
21
+ # Swapping out the actors can be achieved thus:
22
+ #
23
+ # In `config/initializers/hyrax.rb`:
24
+ # ```
25
+ # Hyrax::CurationConcern.actor_factory.swap(Hyrax::Actors::CreateWithFilesActor,
26
+ # Hyrax::Actors::CreateWithRemoteFilesOrderedMembersActor)
27
+ # ```
28
+ # Alternatively, in `config/application.rb`:
29
+ # ```
30
+ # config.to_prepare
31
+ # Hyrax::CurationConcern.actor_factory.swap(Hyrax::Actors::CreateWithFilesActor,
32
+ # Hyrax::Actors::CreateWithRemoteFilesOrderedMembersActor)
33
+ # end
34
+ # ```
35
+ #
36
+ # If there is a key `:remote_files' in the attributes, it attaches the files at the specified URIs
37
+ # to the work. e.g.:
38
+ # attributes[:remote_files] = filenames.map do |name|
39
+ # { url: "https://example.com/file/#{name}", file_name: name }
40
+ # end
41
+ #
42
+ # Browse everything may also return a local file. And although it's in the
43
+ # url property, it may have spaces, and not be a valid URI.
44
+ class CreateWithRemoteFilesOrderedMembersActor < CreateWithRemoteFilesActor
45
+ attr_reader :ordered_members
46
+
47
+ # @param [HashWithIndifferentAccess] remote_files
48
+ # @return [TrueClass]
49
+ def attach_files(env, remote_files)
50
+ return true unless remote_files
51
+ @ordered_members = env.curation_concern.ordered_members.to_a
52
+ remote_files.each do |file_info|
53
+ next if file_info.blank? || file_info[:url].blank?
54
+ # Escape any space characters, so that this is a legal URI
55
+ uri = URI.parse(Addressable::URI.escape(file_info[:url]))
56
+ unless validate_remote_url(uri)
57
+ Rails.logger.error "User #{env.user.user_key} attempted to ingest file from url #{file_info[:url]}, which doesn't pass validation"
58
+ return false
59
+ end
60
+ auth_header = file_info.fetch(:auth_header, {})
61
+ create_file_from_url(env, uri, file_info[:file_name], auth_header)
62
+ end
63
+ add_ordered_members(env.user, env.curation_concern)
64
+ true
65
+ end
66
+
67
+ # Generic utility for creating FileSet from a URL
68
+ # Used in to import files using URLs from a file picker like browse_everything
69
+ def create_file_from_url(env, uri, file_name, auth_header = {})
70
+ ::FileSet.new(import_url: uri.to_s, label: file_name) do |fs|
71
+ actor = file_set_actor_class.new(fs, env.user)
72
+ actor.create_metadata(visibility: env.curation_concern.visibility)
73
+ actor.attach_to_work(env.curation_concern)
74
+ fs.save!
75
+ ordered_members << fs
76
+ if uri.scheme == 'file'
77
+ # Turn any %20 into spaces.
78
+ file_path = CGI.unescape(uri.path)
79
+ IngestLocalFileJob.perform_later(fs, file_path, env.user)
80
+ else
81
+ ImportUrlJob.perform_later(fs, operation_for(user: actor.user), auth_header)
82
+ end
83
+ end
84
+ end
85
+
86
+ # Add all file_sets as ordered_members in a single action
87
+ def add_ordered_members(user, work)
88
+ actor = Hyrax::Actors::OrderedMembersActor.new(ordered_members, user)
89
+ actor.attach_ordered_members_to_work(work)
90
+ end
91
+
92
+ class_attribute :file_set_actor_class
93
+ self.file_set_actor_class = Hyrax::Actors::FileSetOrderedMembersActor
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Actors
5
+ class FileSetOrderedMembersActor < FileSetActor
6
+ # Adds representative and thumbnail to work; sets file_set visibility
7
+ # @param [ActiveFedora::Base] work the parent work
8
+ # @param [Hash] file_set_params
9
+ def attach_to_work(work, file_set_params = {})
10
+ file_set.visibility = work.visibility unless assign_visibility?(file_set_params)
11
+ work.representative = file_set if work.representative_id.blank?
12
+ work.thumbnail = file_set if work.thumbnail_id.blank?
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Actors
5
+ class OrderedMembersActor < FileSetActor
6
+ include Lockable
7
+ attr_reader :ordered_members, :user
8
+
9
+ def initialize(ordered_members, user)
10
+ @ordered_members = ordered_members
11
+ @user = user
12
+ end
13
+
14
+ # Adds FileSets to the work using ore:Aggregations.
15
+ # Locks to ensure that only one process is operating on the list at a time.
16
+ # @param [ActiveFedora::Base] work the parent work
17
+ def attach_ordered_members_to_work(work)
18
+ acquire_lock_for(work.id) do
19
+ work.ordered_members = ordered_members
20
+ work.save
21
+ ordered_members.each do |file_set|
22
+ Hyrax.config.callback.run(:after_create_fileset, file_set, user)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -289,6 +289,7 @@ Blacklight.onLoad(function () {
289
289
  parentId = $modal.find('[name="parent_id"]').val(),
290
290
  data = {
291
291
  parent_id: parentId,
292
+ // source parameter is used by NestCollectionsController#redirect_path
292
293
  source: $self.data('source')
293
294
  };
294
295
  if (url.length === 0) {
@@ -308,6 +309,7 @@ Blacklight.onLoad(function () {
308
309
  childId = $(this).closest('.modal').find('[name="child_id"]').val(),
309
310
  data = {
310
311
  child_id: childId,
312
+ // source parameter is used by NestCollectionsController#redirect_path
311
313
  source: $(this).data('source')
312
314
  };
313
315
  if (url.length === 0) {
@@ -97,7 +97,8 @@ h4 .small {
97
97
  text-decoration: none;
98
98
  }
99
99
 
100
- input.batch_document_selector {
100
+ input.batch_document_selector,
101
+ input.disabled {
101
102
  margin: 10px 10px 2px 10px;
102
103
  padding: 0px;
103
104
  }
@@ -18,6 +18,10 @@ header > h1 .label {
18
18
  padding: $panel-body-padding;
19
19
  }
20
20
 
21
+ .ensure-wrapped {
22
+ word-break: break-all;
23
+ }
24
+
21
25
  .relationships,
22
26
  .attributes {
23
27
  tbody th {
@@ -36,7 +36,7 @@ module Hyrax
36
36
  curation_concern.copy_visibility_to_files
37
37
  end
38
38
  end
39
- redirect_to embargoes_path
39
+ redirect_to embargoes_path, notice: t('.embargo_deactivated')
40
40
  end
41
41
 
42
42
  # This allows us to use the unauthorized template in curation_concerns/base
@@ -127,13 +127,16 @@ module Hyrax
127
127
 
128
128
  def manifest
129
129
  headers['Access-Control-Allow-Origin'] = '*'
130
- render json: manifest_builder.to_h
130
+ respond_to do |wants|
131
+ wants.json { render json: manifest_builder.to_h }
132
+ wants.html { render json: manifest_builder.to_h }
133
+ end
131
134
  end
132
135
 
133
136
  private
134
137
 
135
138
  def user_collections
136
- collections_service.search_results(:deposit) if presenter.editor?
139
+ collections_service.search_results(:deposit)
137
140
  end
138
141
 
139
142
  def collections_service
@@ -91,15 +91,8 @@ module Hyrax
91
91
 
92
92
  # determine appropriate redirect location depending on specified source
93
93
  def redirect_path(item:)
94
- from = params[:source] || 'none'
95
- case from
96
- when "my"
97
- my_collections_path
98
- when "show"
99
- dashboard_collection_path(item)
100
- else
101
- dashboard_collection_path(item)
102
- end
94
+ return my_collections_path if params[:source] == 'my'
95
+ dashboard_collection_path(item)
103
96
  end
104
97
  end
105
98
  end
@@ -9,7 +9,6 @@ module Hyrax
9
9
  # Displays a "check all" button with a dropdown that has "Select None"
10
10
  # and "Select current page" actions
11
11
  def render_check_all
12
- return if params[:controller] == "hyrax/my/collections"
13
12
  render 'hyrax/batch_edits/check_all'
14
13
  end
15
14
  end
@@ -11,6 +11,7 @@ module Hyrax
11
11
  include Hyrax::CollectionsHelper
12
12
  include Hyrax::ChartsHelper
13
13
  include Hyrax::DashboardHelperBehavior
14
+ include Hyrax::IiifHelper
14
15
 
15
16
  # Which translations are available for the user to select
16
17
  # @return [Hash<String,String>] locale abbreviations as keys and flags as values
@@ -0,0 +1,12 @@
1
+ module Hyrax
2
+ module IiifHelper
3
+ def iiif_viewer_display(work_presenter, locals = {})
4
+ render iiif_viewer_display_partial(work_presenter),
5
+ locals.merge(presenter: work_presenter)
6
+ end
7
+
8
+ def iiif_viewer_display_partial(work_presenter)
9
+ 'hyrax/base/iiif_viewers/' + work_presenter.iiif_viewer.to_s
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,41 @@
1
+ # Converts UploadedFiles into FileSets and attaches them to works.
2
+ class AttachFilesToWorkWithOrderedMembersJob < AttachFilesToWorkJob
3
+ attr_reader :ordered_members, :uploaded_files
4
+
5
+ # @param [ActiveFedora::Base] work - the work object
6
+ # @param [Array<Hyrax::UploadedFile>] uploaded_files - an array of files to attach
7
+ def perform(work, uploaded_files, **work_attributes)
8
+ @uploaded_files = uploaded_files
9
+ validate_files!(uploaded_files)
10
+ @ordered_members = work.ordered_members.to_a # Build array of ordered members
11
+ depositor = proxy_or_depositor(work)
12
+ user = User.find_by_user_key(depositor)
13
+ metadata = visibility_attributes(work_attributes)
14
+ add_uploaded_files(user, metadata, work)
15
+ add_ordered_members(user, work)
16
+ end
17
+
18
+ private
19
+
20
+ def add_uploaded_files(user, metadata, work)
21
+ work_permissions = work.permissions.map(&:to_hash)
22
+ uploaded_files.each do |uploaded_file|
23
+ actor = file_set_actor_class.new(FileSet.create, user)
24
+ actor.create_metadata(metadata)
25
+ actor.create_content(uploaded_file)
26
+ actor.attach_to_work(work)
27
+ actor.file_set.permissions_attributes = work_permissions
28
+ ordered_members << actor.file_set
29
+ uploaded_file.update(file_set_uri: actor.file_set.uri)
30
+ end
31
+ end
32
+
33
+ # Add all file_sets as ordered_members in a single action
34
+ def add_ordered_members(user, work)
35
+ actor = Hyrax::Actors::OrderedMembersActor.new(ordered_members, user)
36
+ actor.attach_ordered_members_to_work(work)
37
+ end
38
+
39
+ class_attribute :file_set_actor_class
40
+ self.file_set_actor_class = Hyrax::Actors::FileSetOrderedMembersActor
41
+ end
@@ -55,8 +55,8 @@ module Hyrax
55
55
  Hyrax::Engine.routes.url_helpers.download_url(representative_presenter, host: request.host)
56
56
  end
57
57
 
58
- # @return [Boolean] render the UniversalViewer
59
- def universal_viewer?
58
+ # @return [Boolean] render a IIIF viewer
59
+ def iiif_viewer?
60
60
  representative_id.present? &&
61
61
  representative_presenter.present? &&
62
62
  representative_presenter.image? &&
@@ -64,6 +64,26 @@ module Hyrax
64
64
  members_include_viewable_image?
65
65
  end
66
66
 
67
+ alias universal_viewer? iiif_viewer?
68
+ deprecation_deprecate universal_viewer?: "use iiif_viewer? instead"
69
+
70
+ # @return [Symbol] the name of the IIIF viewer partial to render
71
+ # @example A work presenter with a custom iiif viewer
72
+ # module Hyrax
73
+ # class GenericWorkPresenter < Hyrax::WorkShowPresenter
74
+ # def iiif_viewer
75
+ # :my_iiif_viewer
76
+ # end
77
+ # end
78
+ # end
79
+ #
80
+ # Custom iiif viewer partial at app/views/hyrax/base/iiif_viewers/_my_iiif_viewer.html.erb
81
+ # <h3>My IIIF Viewer!</h3>
82
+ # <a href=<%= main_app.polymorphic_url([main_app, :manifest, presenter], { locale: nil }) %>>Manifest</a>
83
+ def iiif_viewer
84
+ :universal_viewer
85
+ end
86
+
67
87
  # @return FileSetPresenter presenter for the representative FileSets
68
88
  def representative_presenter
69
89
  return nil if representative_id.blank?
@@ -204,6 +224,13 @@ module Hyrax
204
224
  metadata
205
225
  end
206
226
 
227
+ # determine if the user can add this work to a collection
228
+ # @param collections <Collections> list of collections to which this user can deposit
229
+ # @return true if the user can deposit to at least one collection OR if the user can create a collection; otherwise, false
230
+ def show_deposit_for?(collections:)
231
+ collections.present? || current_ability.can?(:create_any, Collection)
232
+ end
233
+
207
234
  private
208
235
 
209
236
  # list of item ids to display is based on ordered_ids