diff --git a/app/controllers/concerns/hyrax/collections_controller_behavior.rb b/app/controllers/concerns/hyrax/collections_controller_behavior.rb
index 21501b96b8..d0b4f42247 100644
--- a/app/controllers/concerns/hyrax/collections_controller_behavior.rb
+++ b/app/controllers/concerns/hyrax/collections_controller_behavior.rb
@@ -65,6 +65,7 @@ def _prefixes
def query_collection_members
member_works
member_subcollections if collection.collection_type.nestable?
+ parent_collections if collection.collection_type.nestable?
end
# Instantiate the membership query service
@@ -78,6 +79,13 @@ def member_works
@members_count = @response.total
end
+ def parent_collections
+ col = @collection
+ col = Collection.find(collection.id) if col.blank?
+ @parent_collections = col.member_of_collections
+ @parent_collection_count = @parent_collections.size
+ end
+
def member_subcollections
results = collection_member_service.available_member_subcollections
@subcollection_docs = results.documents
diff --git a/app/controllers/hyrax/dashboard/collections_controller.rb b/app/controllers/hyrax/dashboard/collections_controller.rb
index 96a344b24e..52e54d84ef 100644
--- a/app/controllers/hyrax/dashboard/collections_controller.rb
+++ b/app/controllers/hyrax/dashboard/collections_controller.rb
@@ -428,6 +428,7 @@ def set_default_permissions
def query_collection_members
member_works
member_subcollections if collection.collection_type.nestable?
+ parent_collections if collection.collection_type.nestable?
end
# Instantiate the membership query service
@@ -447,6 +448,13 @@ def member_subcollections
@subcollection_count = results.total
end
+ def parent_collections
+ col = @collection
+ col = Collection.find(collection.id) if col.blank?
+ @parent_collections = col.member_of_collections
+ @parent_collection_count = @parent_collections.size
+ end
+
# You can override this method if you need to provide additional
# inputs to the search builder. For example:
# search_field: 'all_fields'
diff --git a/app/views/hyrax/collections/_show_parent_collections.html.erb b/app/views/hyrax/collections/_show_parent_collections.html.erb
new file mode 100644
index 0000000000..8c3776f77d
--- /dev/null
+++ b/app/views/hyrax/collections/_show_parent_collections.html.erb
@@ -0,0 +1,15 @@
+<% if @parent_collections.nil? || @parent_collections.empty? %>
+
<%= render 'collection_description', presenter: @presenter %>
+
+ <% if @presenter.collection_type_is_nestable? && @parent_collection_count > 0 %>
+
+
+
+ <%= t('.parent_collection_header') %> (<%= @parent_collection_count %>)
+
+
+
+
+
+ <%= render 'show_parent_collections', collection: @parent_collections %>
+
+
+ <% end %>
+
-
+
+ <% if @presenter.collection_type_is_nestable? %>
+
<%= t('.parent_collection_header') %> (<%= @parent_collection_count %>)
+
+ <%= render 'hyrax/dashboard/collections/show_parent_collections', presenter: @presenter %>
+
+ <% end %>
+
+
<%= render 'hyrax/collections/collection_description', presenter: @presenter %>
diff --git a/config/locales/hyrax.en.yml b/config/locales/hyrax.en.yml
index 7cb46785d8..a106f94b09 100644
--- a/config/locales/hyrax.en.yml
+++ b/config/locales/hyrax.en.yml
@@ -487,9 +487,11 @@ en:
label: "Search Collection %{title}"
placeholder: "Search subcollections and works in this collection"
show:
- works_in_collection: "Works"
- subcollection_count: "Subcollections"
+ no_visible_parent_collections: "There are no visible parent collections."
no_visible_subcollections: "There are no visible subcollections."
+ parent_collection_header: "Parent Collections"
+ subcollection_count: "Subcollections"
+ works_in_collection: "Works"
collection_type:
default_title: "User Collection"
admin_set_title: "Admin Set"
@@ -626,6 +628,7 @@ en:
show:
header: "Collection"
item_count: "Works"
+ parent_collection_header: "Parent Collections"
public_view_label: "Public view of Collection"
search_results: "Search Results within this Collection"
subcollection_count: "Subcollections"
@@ -1109,7 +1112,7 @@ en:
labels:
collection:
size: "Size"
- total_items: "Total works"
+ total_items: "Total items"
collection_type:
allow_multiple_membership: "MULTIPLE MEMBERSHIP"
assigns_workflow: "WORKFLOW"
diff --git a/spec/views/hyrax/collections/_show_descriptions.html.erb_spec.rb b/spec/views/hyrax/collections/_show_descriptions.html.erb_spec.rb
index 3067c0872b..da07f45476 100644
--- a/spec/views/hyrax/collections/_show_descriptions.html.erb_spec.rb
+++ b/spec/views/hyrax/collections/_show_descriptions.html.erb_spec.rb
@@ -23,7 +23,7 @@
render
expect(rendered).to have_content 'Date Created'
expect(rendered).to include('itemprop="dateCreated"')
- expect(rendered).to have_content 'Total works'
+ expect(rendered).to have_content 'Total items'
expect(rendered).to have_content '2'
expect(rendered).to have_content 'Size'
expect(rendered).to have_content '118 MB'
diff --git a/spec/views/hyrax/collections/_show_parent_collections.html.erb_spec.rb b/spec/views/hyrax/collections/_show_parent_collections.html.erb_spec.rb
new file mode 100644
index 0000000000..497c3040e5
--- /dev/null
+++ b/spec/views/hyrax/collections/_show_parent_collections.html.erb_spec.rb
@@ -0,0 +1,36 @@
+RSpec.describe 'hyrax/collections/_show_parent_collections.html.erb', type: :view do
+ let(:collection) { build(:named_collection, id: '123') }
+
+ context 'when parent collection list is empty' do
+ let(:parentcollection) { nil }
+
+ before do
+ assign(:parent_collections, parentcollection)
+ end
+
+ it "posts a warning message" do
+ render('show_parent_collections.html.erb', collection: parentcollection)
+ expect(rendered).to have_text("There are no visible parent collections.")
+ end
+ end
+
+ context 'when parent collection list is not empty' do
+ let(:parentcollection) { [collection] }
+
+ before do
+ assign(:parent_collections, parentcollection)
+ assign(:document, collection)
+ allow(collection).to receive(:title_or_label).and_return(collection.title)
+ allow(collection).to receive(:persisted?).and_return true
+ render('show_parent_collections.html.erb', collection: parentcollection)
+ end
+
+ it "posts the collection's title with a link to the collection" do
+ expect(rendered).to have_link(collection.title.first)
+ end
+
+ xit 'includes a count of the parent collections' do
+ # TODO: add test when actual count is added to page
+ end
+ end
+end
diff --git a/spec/views/hyrax/collections/show.html.erb_spec.rb b/spec/views/hyrax/collections/show.html.erb_spec.rb
index dcd24dbb2c..b874d213cf 100644
--- a/spec/views/hyrax/collections/show.html.erb_spec.rb
+++ b/spec/views/hyrax/collections/show.html.erb_spec.rb
@@ -15,6 +15,7 @@
allow(presenter).to receive(:collection_type_is_nestable?).and_return(true)
allow(presenter).to receive(:total_items).and_return(0)
assign(:subcollection_count, 0)
+ assign(:parent_collection_count, 0)
assign(:members_count, 0)
allow(presenter).to receive(:banner_file).and_return("banner.gif")
allow(presenter).to receive(:logo_record).and_return([{ linkurl: "logo link url", alttext: "logo alt text", file_location: "logo.gif" }])
diff --git a/spec/views/hyrax/dashboard/collections/_show_descriptions.html.erb_spec.rb b/spec/views/hyrax/dashboard/collections/_show_descriptions.html.erb_spec.rb
index 1793133ed8..b8bcc25681 100644
--- a/spec/views/hyrax/dashboard/collections/_show_descriptions.html.erb_spec.rb
+++ b/spec/views/hyrax/dashboard/collections/_show_descriptions.html.erb_spec.rb
@@ -23,7 +23,7 @@
render
expect(rendered).to have_content 'Date Created'
expect(rendered).to include('itemprop="dateCreated"')
- expect(rendered).to have_content 'Total works'
+ expect(rendered).to have_content 'Total items'
expect(rendered).to have_content '2'
expect(rendered).to have_content 'Size'
expect(rendered).to have_content '118 MB'
diff --git a/spec/views/hyrax/dashboard/collections/_show_parent_collections.html.erb_spec.rb b/spec/views/hyrax/dashboard/collections/_show_parent_collections.html.erb_spec.rb
new file mode 100644
index 0000000000..92fcecddcf
--- /dev/null
+++ b/spec/views/hyrax/dashboard/collections/_show_parent_collections.html.erb_spec.rb
@@ -0,0 +1,36 @@
+RSpec.describe 'hyrax/dashboard/collections/_show_parent_collections.html.erb', type: :view do
+ let(:collection) { build(:named_collection, id: '123') }
+
+ context 'when parent collection list is empty' do
+ let(:parentcollection) { nil }
+
+ before do
+ assign(:parent_collections, parentcollection)
+ end
+
+ it "posts a warning message" do
+ render('show_parent_collections.html.erb', collection: parentcollection)
+ expect(rendered).to have_text("There are no visible parent collections.")
+ end
+ end
+
+ context 'when parent collection list is not empty' do
+ let(:parentcollection) { [collection] }
+
+ before do
+ assign(:parent_collections, parentcollection)
+ assign(:document, collection)
+ allow(collection).to receive(:title_or_label).and_return(collection.title)
+ allow(collection).to receive(:persisted?).and_return true
+ render('show_parent_collections.html.erb', collection: parentcollection)
+ end
+
+ it "posts the collection's title with a link to the collection" do
+ expect(rendered).to have_link(collection.title.first)
+ end
+
+ xit 'includes a count of the parent collections' do
+ # TODO: add test when actual count is added to page
+ end
+ end
+end
diff --git a/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb b/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb
index 264318892b..bb0a1e0d91 100644
--- a/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb
+++ b/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb
@@ -37,6 +37,7 @@
stub_template '_show_actions.html.erb' => '
THE COLLECTION ACTIONS
'
stub_template '_show_subcollection_actions.html.erb' => '
THE SUBCOLLECTION ACTIONS
'
stub_template '_show_add_items_actions.html.erb' => '
THE ADD ITEMS ACTIONS
'
+ stub_template '_show_parent_collections.html.erb' => '
THE PARENT COLLECTIONS LIST
'
stub_template 'hyrax/collections/_paginate.html.erb' => 'paginate'
stub_template 'hyrax/collections/_media_display.html.erb' => '
'
stub_template 'hyrax/my/collections/_modal_add_to_collection.html.erb' => 'modal add as subcollection'