diff --git a/src/app/+item-page/simple/related-items/related-items-component.ts b/src/app/+item-page/simple/related-items/related-items-component.ts index 838508524c..5b4376bab0 100644 --- a/src/app/+item-page/simple/related-items/related-items-component.ts +++ b/src/app/+item-page/simple/related-items/related-items-component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; import { ItemViewMode } from '../../../shared/items/item-type-decorator'; import { Observable } from 'rxjs/internal/Observable'; @@ -6,6 +6,9 @@ import { RemoteData } from '../../../core/data/remote-data'; import { PaginatedList } from '../../../core/data/paginated-list'; import { RelationshipService } from '../../../core/data/relationship.service'; import { FindAllOptions } from '../../../core/data/request.models'; +import { getRemoteDataPayload, getSucceededRemoteData } from '../../../core/shared/operators'; +import { hasNoValue, hasValueOperator } from '../../../shared/empty.util'; +import { Subscription } from 'rxjs/internal/Subscription'; @Component({ selector: 'ds-related-items', @@ -16,7 +19,7 @@ import { FindAllOptions } from '../../../core/data/request.models'; * This component is used for displaying relations between items * It expects a parent item and relationship type, as well as a label to display on top */ -export class RelatedItemsComponent implements OnInit { +export class RelatedItemsComponent implements OnInit, OnDestroy { /** * The parent of the list of related items to display */ @@ -39,6 +42,11 @@ export class RelatedItemsComponent implements OnInit { */ @Input() label: string; + /** + * Completely hide the component until there's at least one item visible + */ + @HostBinding('class.d-none') hidden = true; + /** * The list of related items */ @@ -60,11 +68,19 @@ export class RelatedItemsComponent implements OnInit { */ showingAll = false; + /** + * Subscription on items used to update the "hidden" property of this component + */ + itemSub: Subscription; + constructor(public relationshipService: RelationshipService) { } ngOnInit(): void { this.items$ = this.relationshipService.getRelatedItemsByLabel(this.parentItem, this.relationType, this.options); + this.itemSub = this.items$.subscribe((itemsRD: RemoteData>) => { + this.hidden = !(itemsRD.hasSucceeded && itemsRD.payload && itemsRD.payload.page.length > 0); + }); } /** @@ -82,4 +98,13 @@ export class RelatedItemsComponent implements OnInit { this.items$ = this.relationshipService.getRelatedItemsByLabel(this.parentItem, this.relationType, this.options); this.showingAll = false; } + + /** + * Unsubscribe from the item subscription + */ + ngOnDestroy(): void { + if (this.itemSub) { + this.itemSub.unsubscribe(); + } + } } diff --git a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html index a6886cf1ac..de74a75d2b 100644 --- a/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html +++ b/themes/mantis/app/+item-page/simple/item-types/publication/publication.component.html @@ -61,27 +61,24 @@
-
- - -
-
- - -
-
- - -
+ + + + + +
diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index a25a474eb0..b34be8aec2 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -26,25 +26,29 @@ [label]="'journalissue.page.journal-title'"> + +
@@ -53,21 +57,21 @@ -
+
-
- - -
-
- - -
+ + + +
diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html index c20e9a775a..99651377cb 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.html @@ -23,17 +23,17 @@
@@ -42,21 +42,21 @@
-
+
-
- - -
-
- - -
+ + + +
diff --git a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html index ef827af590..ecc36c53bc 100644 --- a/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html +++ b/themes/mantis/app/entity-groups/journal-entities/item-pages/journal/journal.component.html @@ -22,21 +22,21 @@
@@ -45,15 +45,15 @@
-
+
-
- - -
+ +
diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html b/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html index 6bb925c93f..d5db61b7a1 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.html @@ -23,25 +23,25 @@
@@ -50,27 +50,27 @@
-
+
-
- - -
-
- - -
-
- - -
+ + + + + +
diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html b/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html index 54d7962b97..851a24e961 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/person/person.component.html @@ -17,38 +17,30 @@

{{'person.page.titleprefix' | translate}} + [mdValues]="[item?.firstMetadata('person.familyName'), item?.firstMetadata('person.givenName')]" [separator]="', '">

- - - -
@@ -57,21 +49,21 @@
-
+
-
- - -
-
- - -
+ + + +
diff --git a/themes/mantis/app/entity-groups/research-entities/item-pages/project/project.component.html b/themes/mantis/app/entity-groups/research-entities/item-pages/project/project.component.html index aa4a107247..9b8f1532ae 100644 --- a/themes/mantis/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/themes/mantis/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -22,9 +22,10 @@
- +
@@ -58,27 +59,27 @@
-
+
-
- - -
-
- - -
-
- - -
+ + + + + +