hyrax 3.0.2 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +22 -0
- data/.dassie/Gemfile +10 -5
- data/.dassie/config/initializers/hyrax.rb +5 -0
- data/.dockerignore +3 -0
- data/.env +0 -1
- data/.rubocop.yml +4 -0
- data/CONTAINERS.md +1 -1
- data/Dockerfile +12 -6
- data/Gemfile +21 -27
- data/app/actors/hyrax/actors/base_actor.rb +1 -1
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
- data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
- data/app/controllers/hyrax/dashboard/collections_controller.rb +12 -10
- data/app/controllers/hyrax/file_sets_controller.rb +49 -13
- data/app/controllers/hyrax/permissions_controller.rb +3 -4
- data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
- data/app/forms/hyrax/forms/collection_form.rb +7 -3
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
- data/app/forms/hyrax/forms/file_set_form.rb +46 -0
- data/app/forms/hyrax/forms/permission.rb +23 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
- data/app/forms/hyrax/forms/resource_form.rb +10 -17
- data/app/forms/hyrax/forms/work_form.rb +5 -2
- data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
- data/app/helpers/hyrax/collections_helper.rb +88 -2
- data/app/helpers/hyrax/dashboard_helper_behavior.rb +3 -7
- data/app/helpers/hyrax/file_set_helper.rb +25 -6
- data/app/helpers/hyrax/work_form_helper.rb +53 -0
- data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
- data/app/indexers/hyrax/valkyrie_indexer.rb +3 -3
- data/app/inputs/controlled_vocabulary_input.rb +2 -5
- data/app/jobs/attach_files_to_work_job.rb +19 -10
- data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
- data/app/jobs/inherit_permissions_job.rb +9 -5
- data/app/models/admin_set.rb +6 -25
- data/app/models/concerns/hyrax/ability.rb +3 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
- data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -52
- data/app/models/concerns/hyrax/suppressible.rb +5 -0
- data/app/models/concerns/hyrax/user.rb +9 -3
- data/app/models/hyrax/file_set.rb +6 -0
- data/app/models/hyrax/pcdm_collection.rb +1 -0
- data/app/models/hyrax/permission_template.rb +98 -12
- data/app/models/hyrax/virus_scanner.rb +27 -18
- data/app/models/sipity/agent.rb +1 -0
- data/app/models/sipity/entity.rb +30 -8
- data/app/models/sipity/workflow.rb +1 -0
- data/app/models/sipity.rb +42 -0
- data/app/presenters/hyrax/admin_set_options_presenter.rb +2 -10
- data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
- data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
- data/app/presenters/hyrax/collection_presenter.rb +31 -6
- data/app/presenters/hyrax/file_set_presenter.rb +6 -1
- data/app/presenters/hyrax/file_usage.rb +3 -2
- data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
- data/app/presenters/hyrax/trophy_presenter.rb +33 -4
- data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
- data/app/presenters/hyrax/version_list_presenter.rb +19 -0
- data/app/presenters/hyrax/version_presenter.rb +3 -2
- data/app/presenters/hyrax/work_show_presenter.rb +25 -4
- data/app/presenters/hyrax/work_usage.rb +5 -3
- data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
- data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
- data/app/search_builders/hyrax/my/collections_search_builder.rb +1 -1
- data/app/services/hyrax/admin_set_create_service.rb +3 -1
- data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
- data/app/services/hyrax/collections/collection_member_service.rb +112 -27
- data/app/services/hyrax/collections/migration_service.rb +4 -2
- data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
- data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
- data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
- data/app/services/hyrax/contextual_path.rb +23 -0
- data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
- data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
- data/app/services/hyrax/edit_permissions_service.rb +27 -20
- data/app/services/hyrax/find_objects_via_solr_service.rb +11 -7
- data/app/services/hyrax/multiple_membership_checker.rb +51 -31
- data/app/services/hyrax/resource_status.rb +7 -0
- data/app/services/hyrax/search_service.rb +4 -2
- data/app/services/hyrax/solr_query_builder_service.rb +29 -6
- data/app/services/hyrax/solr_query_service.rb +224 -0
- data/app/services/hyrax/solr_service.rb +8 -1
- data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
- data/app/services/hyrax/work_uploads_handler.rb +17 -2
- data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
- data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
- data/app/services/hyrax/workflow/status_list_service.rb +43 -13
- data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
- data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
- data/app/views/hyrax/base/_form_representative.html.erb +1 -1
- data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
- data/app/views/hyrax/base/_guts4form.html.erb +2 -2
- data/app/views/hyrax/base/_representative_media.html.erb +1 -1
- data/app/views/hyrax/base/_show_actions.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
- data/app/views/hyrax/file_sets/edit.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
- data/app/views/hyrax/file_sets/show.html.erb +1 -1
- data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
- data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
- data/bin/solrcloud-assign-configset.sh +8 -5
- data/bin/solrcloud-upload-configset.sh +4 -2
- data/chart/hyrax/Chart.yaml +3 -3
- data/chart/hyrax/README.md +47 -1
- data/chart/hyrax/templates/_helpers.tpl +1 -1
- data/chart/hyrax/templates/configmap-env.yaml +1 -3
- data/chart/hyrax/templates/deployment-worker.yaml +6 -3
- data/chart/hyrax/templates/deployment.yaml +8 -3
- data/chart/hyrax/values.yaml +12 -0
- data/config/brakeman.ignore +2 -2
- data/config/locales/hyrax.de.yml +1 -1
- data/config/locales/hyrax.en.yml +1 -1
- data/config/locales/hyrax.es.yml +1 -1
- data/config/locales/hyrax.fr.yml +1 -1
- data/config/locales/hyrax.it.yml +1 -1
- data/config/locales/hyrax.pt-BR.yml +1 -1
- data/config/locales/hyrax.zh.yml +1 -1
- data/docker-compose.yml +1 -0
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
- data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
- data/lib/hyrax/configuration.rb +8 -0
- data/lib/hyrax/engine.rb +1 -0
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/specs/capybara.rb +3 -1
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
- data/lib/hyrax/transactions/container.rb +21 -0
- data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
- data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
- data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
- data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
- data/lib/hyrax/transactions/work_create.rb +2 -1
- data/lib/hyrax/valkyrie_can_can_adapter.rb +1 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/hyrax.rb +9 -0
- data/lib/tasks/collection_type_global_id.rake +1 -1
- data/lib/tasks/regenerate_derivatives.rake +12 -0
- data/lib/wings/orm_converter.rb +18 -2
- data/lib/wings/setup.rb +1 -0
- data/lib/wings/valkyrie/storage.rb +56 -1
- data/template.rb +1 -1
- metadata +17 -2
@@ -28,6 +28,7 @@ module Hyrax
|
|
28
28
|
:to_s, to: :solr_document
|
29
29
|
|
30
30
|
delegate(*Hyrax::CollectionType.settings_attributes, to: :collection_type, prefix: :collection_type_is)
|
31
|
+
alias nestable? collection_type_is_nestable?
|
31
32
|
|
32
33
|
def collection_type
|
33
34
|
@collection_type ||= Hyrax::CollectionType.find_by_gid!(collection_type_gid)
|
@@ -77,19 +78,36 @@ module Hyrax
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def total_items
|
80
|
-
|
81
|
+
field_pairs = { "member_of_collection_ids_ssim" => id.to_s }
|
82
|
+
SolrQueryService.new
|
83
|
+
.with_field_pairs(field_pairs: field_pairs)
|
84
|
+
.count
|
81
85
|
end
|
82
86
|
|
83
87
|
def total_viewable_items
|
84
|
-
|
88
|
+
field_pairs = { "member_of_collection_ids_ssim" => id.to_s }
|
89
|
+
SolrQueryService.new
|
90
|
+
.with_field_pairs(field_pairs: field_pairs)
|
91
|
+
.accessible_by(ability: current_ability)
|
92
|
+
.count
|
85
93
|
end
|
86
94
|
|
87
95
|
def total_viewable_works
|
88
|
-
|
96
|
+
field_pairs = { "member_of_collection_ids_ssim" => id.to_s }
|
97
|
+
SolrQueryService.new
|
98
|
+
.with_field_pairs(field_pairs: field_pairs)
|
99
|
+
.with_generic_type(generic_type: "Work")
|
100
|
+
.accessible_by(ability: current_ability)
|
101
|
+
.count
|
89
102
|
end
|
90
103
|
|
91
104
|
def total_viewable_collections
|
92
|
-
|
105
|
+
field_pairs = { "member_of_collection_ids_ssim" => id.to_s }
|
106
|
+
SolrQueryService.new
|
107
|
+
.with_field_pairs(field_pairs: field_pairs)
|
108
|
+
.with_generic_type(generic_type: "Collection")
|
109
|
+
.accessible_by(ability: current_ability)
|
110
|
+
.count
|
93
111
|
end
|
94
112
|
|
95
113
|
def collection_type_badge
|
@@ -154,14 +172,21 @@ module Hyrax
|
|
154
172
|
create_work_presenter.first_model
|
155
173
|
end
|
156
174
|
|
175
|
+
##
|
176
|
+
# @deprecated this implementation requires an extra db round trip, had a
|
177
|
+
# buggy cacheing mechanism, and was largely duplicative of other code.
|
178
|
+
# all versions of this code are replaced by
|
179
|
+
# {CollectionsHelper#available_parent_collections_data}.
|
157
180
|
def available_parent_collections(scope:)
|
181
|
+
Deprecation.warn("#{self.class}#available_parent_collections is " \
|
182
|
+
"deprecated. Use available_parent_collections_data " \
|
183
|
+
"helper instead.")
|
158
184
|
return @available_parents if @available_parents.present?
|
159
185
|
collection = ::Collection.find(id)
|
160
186
|
colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
|
161
187
|
@available_parents = colls.map do |col|
|
162
188
|
{ "id" => col.id, "title_first" => col.title.first }
|
163
|
-
end
|
164
|
-
@available_parents.to_json
|
189
|
+
end.to_json
|
165
190
|
end
|
166
191
|
|
167
192
|
def subcollection_count=(total)
|
@@ -57,8 +57,13 @@ module Hyrax
|
|
57
57
|
current_ability.can?(:read, id) ? first_title : 'File'
|
58
58
|
end
|
59
59
|
|
60
|
+
##
|
61
|
+
# @deprecated use `::Ability.can?(:edit, presenter)`. Hyrax views calling
|
62
|
+
# presenter {#editor} methods will continue to call them until Hyrax
|
63
|
+
# 4.0.0. The deprecation time horizon for the presenter methods themselves
|
64
|
+
# is 5.0.0.
|
60
65
|
def editor?
|
61
|
-
current_ability.can?(:edit,
|
66
|
+
current_ability.can?(:edit, self)
|
62
67
|
end
|
63
68
|
|
64
69
|
def tweeter
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# Called by the stats controller, it finds cached file pageview data,
|
3
|
-
# and prepares it for visualization in /app/views/stats/file.html.erb
|
4
2
|
module Hyrax
|
3
|
+
##
|
4
|
+
# Called by the stats controller, it finds cached file pageview data,
|
5
|
+
# and prepares it for visualization in /app/views/stats/file.html.erb
|
5
6
|
class FileUsage < StatsUsagePresenter
|
6
7
|
def initialize(id)
|
7
8
|
self.model = ::FileSet.find(id)
|
@@ -1,27 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Hyrax
|
4
|
+
##
|
5
|
+
# @api public
|
6
|
+
#
|
7
|
+
# Presents works in context as "trophied" for a given user.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# my_user = User.find(user_id)
|
11
|
+
#
|
12
|
+
# trophies = Hyrax::TrophyPresenter.find_by_user(my_user)
|
13
|
+
# trophies.each do |trophy|
|
14
|
+
# puts "Object name/title: #{trophy}"
|
15
|
+
# puts "Thumbnail path: #{trophy.thumbnail_path}"
|
16
|
+
# end
|
3
17
|
class TrophyPresenter
|
4
18
|
include ModelProxy
|
19
|
+
|
20
|
+
##
|
21
|
+
# @param solr_document [::SolrDocument]
|
5
22
|
def initialize(solr_document)
|
6
23
|
@solr_document = solr_document
|
7
24
|
end
|
8
25
|
|
26
|
+
##
|
27
|
+
# @!attribute [r] SolrDocument
|
28
|
+
# @return [::SolrDocument]
|
9
29
|
attr_reader :solr_document
|
10
30
|
|
11
31
|
delegate :to_s, :thumbnail_path, to: :solr_document
|
12
32
|
|
33
|
+
##
|
13
34
|
# @param user [User] the user to find the TrophyPresentes for.
|
35
|
+
#
|
14
36
|
# @return [Array<TrophyPresenter>] a list of all the trophy presenters for the user
|
15
37
|
def self.find_by_user(user)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
38
|
+
ids = user.trophies.pluck(:work_id)
|
39
|
+
return ids if ids.empty?
|
40
|
+
|
41
|
+
documents = Hyrax::SolrQueryService.new.with_ids(ids: ids).solr_documents
|
42
|
+
|
43
|
+
documents.map { |doc| new(doc) }
|
20
44
|
rescue RSolr::Error::ConnectionRefused
|
21
45
|
[]
|
22
46
|
end
|
23
47
|
|
48
|
+
##
|
49
|
+
# @api private
|
50
|
+
# @deprecated use CatalogController.blacklight_config.document_model instead
|
24
51
|
def self.document_model
|
52
|
+
Deprecation
|
53
|
+
.warn("Use CatalogController.blacklight_config.document_model instead.")
|
25
54
|
CatalogController.blacklight_config.document_model
|
26
55
|
end
|
27
56
|
private_class_method :document_model
|
@@ -1,16 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
3
|
class UserProfilePresenter
|
4
|
+
##
|
5
|
+
# @param user [::User]
|
6
|
+
# @param ability [::Ability]
|
4
7
|
def initialize(user, ability)
|
5
8
|
@user = user
|
6
9
|
@ability = ability
|
7
10
|
end
|
8
11
|
|
12
|
+
##
|
13
|
+
# @!attribute [r] ability
|
14
|
+
# @return [::Ability]
|
15
|
+
# @!attribute [r] user
|
16
|
+
# @return [::User]
|
9
17
|
attr_reader :user, :ability
|
10
18
|
|
11
19
|
delegate :name, to: :user
|
12
20
|
|
13
|
-
|
21
|
+
##
|
22
|
+
# @return [Boolean] true if the presenter is for the logged in user
|
14
23
|
def current_user?
|
15
24
|
user == ability.current_user
|
16
25
|
end
|
@@ -23,6 +32,7 @@ module Hyrax
|
|
23
32
|
end
|
24
33
|
end
|
25
34
|
|
35
|
+
##
|
26
36
|
# @return [Array<TrophyPresenter>] list of TrophyPresenters for this profile.
|
27
37
|
def trophies
|
28
38
|
@trophies ||= Hyrax::TrophyPresenter.find_by_user(user)
|
@@ -1,10 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
|
+
##
|
4
|
+
# @api public
|
3
5
|
class VersionListPresenter
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
##
|
9
|
+
# @param version_list [Array<#created>]
|
4
10
|
def initialize(version_list)
|
5
11
|
@raw_list = version_list
|
6
12
|
end
|
7
13
|
|
14
|
+
##
|
15
|
+
# @param [Object] an object representing the File Set
|
16
|
+
#
|
17
|
+
# @return [Enumerable<Hyrax::VersionPresenter>] an enumerable of presenters
|
18
|
+
# for the relevant file versions.
|
19
|
+
#
|
20
|
+
# @raise [ArgumentError] if we can't build an enu
|
21
|
+
def self.for(file_set:)
|
22
|
+
new(file_set.original_file&.versions&.all.to_a)
|
23
|
+
rescue NoMethodError
|
24
|
+
raise ArgumentError
|
25
|
+
end
|
26
|
+
|
8
27
|
delegate :each, to: :wrapped_list
|
9
28
|
|
10
29
|
private
|
@@ -20,8 +20,9 @@ module Hyrax
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def committer
|
23
|
-
|
24
|
-
|
23
|
+
Hyrax::VersionCommitter
|
24
|
+
.find_by(version_id: @version.uri)
|
25
|
+
&.committer_login
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
@@ -132,8 +132,13 @@ module Hyrax
|
|
132
132
|
graph.dump(:ttl)
|
133
133
|
end
|
134
134
|
|
135
|
+
##
|
136
|
+
# @deprecated use `::Ability.can?(:edit, presenter)`. Hyrax views calling
|
137
|
+
# presenter {#editor} methods will continue to call them until Hyrax
|
138
|
+
# 4.0.0. The deprecation time horizon for the presenter methods themselves
|
139
|
+
# is 5.0.0.
|
135
140
|
def editor?
|
136
|
-
current_ability.can?(:edit,
|
141
|
+
current_ability.can?(:edit, self)
|
137
142
|
end
|
138
143
|
|
139
144
|
def tweeter
|
@@ -223,9 +228,25 @@ module Hyrax
|
|
223
228
|
end
|
224
229
|
end
|
225
230
|
|
226
|
-
|
227
|
-
# @
|
228
|
-
|
231
|
+
##
|
232
|
+
# @return [Integer]
|
233
|
+
def member_count
|
234
|
+
@member_count ||= member_presenters.count
|
235
|
+
end
|
236
|
+
|
237
|
+
##
|
238
|
+
# Given a set of collections, which the caller asserts the current ability
|
239
|
+
# can deposit to, decide whether to display actions to add this work to a
|
240
|
+
# collection.
|
241
|
+
#
|
242
|
+
# By default, this returns `true` if any collections are passed in OR the
|
243
|
+
# current ability can create a collection.
|
244
|
+
#
|
245
|
+
# @param collections [Enumerable<::Collection>, nil] list of collections to
|
246
|
+
# which the current ability can deposit
|
247
|
+
#
|
248
|
+
# @return [Boolean] a flag indicating whether to display collection deposit
|
249
|
+
# options.
|
229
250
|
def show_deposit_for?(collections:)
|
230
251
|
collections.present? || current_ability.can?(:create_any, ::Collection)
|
231
252
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Called by the stats controller, it finds cached work pageview data,
|
4
|
-
# and prepares it for visualization in /app/views/stats/work.html.erb
|
2
|
+
|
5
3
|
module Hyrax
|
4
|
+
# Follows the model established by {FileUsage}.
|
5
|
+
#
|
6
|
+
# Called by the stats controller, it finds cached work pageview data,
|
7
|
+
# and prepares it for visualization in /app/views/stats/work.html.erb
|
6
8
|
class WorkUsage < StatsUsagePresenter
|
7
9
|
def initialize(id)
|
8
10
|
self.model = Hyrax::WorkRelation.new.find(id)
|
@@ -11,12 +11,14 @@ module Hyrax
|
|
11
11
|
|
12
12
|
attr_reader :field, :values, :options
|
13
13
|
|
14
|
+
##
|
14
15
|
# @param [Symbol] field
|
15
16
|
# @param [Array] values
|
16
17
|
# @param [Hash] options
|
17
18
|
# @option options [String] :label The field label to render
|
18
19
|
# @option options [String] :include_empty Do we render if if the values are empty?
|
19
20
|
# @option options [String] :work_type Used for some I18n logic
|
21
|
+
# @option options [Boolean] :sort sort the values with +Array#sort+ if truthy
|
20
22
|
def initialize(field, values, options = {})
|
21
23
|
@field = field
|
22
24
|
@values = values
|
@@ -31,7 +33,10 @@ module Hyrax
|
|
31
33
|
|
32
34
|
attributes = microdata_object_attributes(field).merge(class: "attribute attribute-#{field}")
|
33
35
|
|
34
|
-
|
36
|
+
values_array = Array(values)
|
37
|
+
values_array = values_array.sort if options[:sort]
|
38
|
+
|
39
|
+
markup += values_array.map do |value|
|
35
40
|
"<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
|
36
41
|
end.join
|
37
42
|
|
@@ -48,7 +53,10 @@ module Hyrax
|
|
48
53
|
|
49
54
|
attributes = microdata_object_attributes(field).merge(class: "attribute attribute-#{field}")
|
50
55
|
|
51
|
-
|
56
|
+
values_array = Array(values)
|
57
|
+
values_array.sort! if options[:sort]
|
58
|
+
|
59
|
+
markup += values_array.map do |value|
|
52
60
|
"<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
|
53
61
|
end.join
|
54
62
|
markup += %(</ul></dd>)
|
@@ -21,6 +21,6 @@ class Hyrax::My::CollectionsSearchBuilder < ::Hyrax::CollectionSearchBuilder
|
|
21
21
|
# This overrides the models in FilterByType
|
22
22
|
# @return [Array<Class>] a list of classes to include
|
23
23
|
def models
|
24
|
-
[::AdminSet, ::Collection]
|
24
|
+
[::AdminSet, ::Collection, Hyrax::AdministrativeSet]
|
25
25
|
end
|
26
26
|
end
|
@@ -81,9 +81,11 @@ module Hyrax
|
|
81
81
|
::Ability.admin_group_name
|
82
82
|
end
|
83
83
|
|
84
|
+
##
|
85
|
+
# @return [PermissionTemplate]
|
84
86
|
def create_permission_template
|
85
87
|
permission_template = PermissionTemplate.create!(source_id: admin_set.id, access_grants_attributes: access_grants_attributes)
|
86
|
-
admin_set
|
88
|
+
permission_template.reset_access_controls_for(collection: admin_set)
|
87
89
|
permission_template
|
88
90
|
end
|
89
91
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Collections
|
4
|
+
##
|
5
|
+
# Retrieves collection members
|
6
|
+
class CollectionMemberSearchService < Hyrax::SearchService
|
7
|
+
##
|
8
|
+
# @param scope [#repository] Typically a controller object which responds to :repository
|
9
|
+
# @param [::Collection] collection
|
10
|
+
# @param [ActionController::Parameters] params the query params
|
11
|
+
# @param [ActionController::Parameters] user_params
|
12
|
+
# @param [::Ability] current_ability
|
13
|
+
# @param [Class] search_builder_class a {::SearchBuilder}
|
14
|
+
def initialize(scope:, collection:, params:, user_params: nil, current_ability: nil, search_builder_class: Hyrax::CollectionMemberSearchBuilder) # rubocop:disable Metrics/ParameterLists
|
15
|
+
super(
|
16
|
+
config: scope.blacklight_config,
|
17
|
+
user_params: user_params || params,
|
18
|
+
collection: collection,
|
19
|
+
scope: scope,
|
20
|
+
current_ability: current_ability || scope.current_ability,
|
21
|
+
search_builder_class: search_builder_class
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# @api public
|
27
|
+
#
|
28
|
+
# Collections which are members of the given collection
|
29
|
+
#
|
30
|
+
# @return [Blacklight::Solr::Response] (up to 50 solr documents)
|
31
|
+
def available_member_subcollections
|
32
|
+
response, _docs = search_results do |builder|
|
33
|
+
# To differentiate current page for works vs subcollections, we have to use a sub_collection_page
|
34
|
+
# param. Map this to the page param before querying for subcollections, if it's present
|
35
|
+
builder.page(user_params[:sub_collection_page])
|
36
|
+
builder.search_includes_models = :collections
|
37
|
+
builder
|
38
|
+
end
|
39
|
+
response
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# @api public
|
44
|
+
#
|
45
|
+
# Works which are members of the given collection
|
46
|
+
#
|
47
|
+
# @return [Blacklight::Solr::Response]
|
48
|
+
def available_member_works
|
49
|
+
response, _docs = search_results do |builder|
|
50
|
+
builder.search_includes_models = :works
|
51
|
+
builder
|
52
|
+
end
|
53
|
+
response
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# @api public
|
58
|
+
#
|
59
|
+
# Work ids of the works which are members of the given collection
|
60
|
+
#
|
61
|
+
# @return [Blacklight::Solr::Response]
|
62
|
+
def available_member_work_ids
|
63
|
+
response, _docs = search_results do |builder|
|
64
|
+
builder.search_includes_models = :works
|
65
|
+
builder.merge(fl: 'id')
|
66
|
+
builder
|
67
|
+
end
|
68
|
+
response
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|