diff --git a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts
index 9c62b80cad7..e17e5397b7e 100644
--- a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts
+++ b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts
@@ -1,4 +1,4 @@
-import { Component } from '@angular/core';
+import { Component, Input } from '@angular/core';
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.component';
@@ -6,35 +6,34 @@ import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.componen
/* tslint:disable:max-classes-per-file */
@Component({
selector: 'ds-component-without-content',
- template: '
\n' +
+ template: '\n' +
''
})
-class NoContentComponent {}
+class NoContentComponent {
+ public hideIfNoTextContent = true;
+}
@Component({
selector: 'ds-component-with-empty-spans',
- template: '\n' +
+ template: '\n' +
' \n' +
' \n' +
''
})
-class SpanContentComponent {}
+class SpanContentComponent {
+ @Input() hideIfNoTextContent = true;
+}
@Component({
selector: 'ds-component-with-text',
- template: '\n' +
+ template: '\n' +
' The quick brown fox jumps over the lazy dog\n' +
''
})
-class TextContentComponent {}
+class TextContentComponent {
+ @Input() hideIfNoTextContent = true;
+}
-@Component({
- selector: 'ds-component-with-image',
- template: '\n' +
- ' \n' +
- ''
-})
-class ImgContentComponent {}
/* tslint:enable:max-classes-per-file */
describe('MetadataFieldWrapperComponent', () => {
@@ -43,7 +42,7 @@ describe('MetadataFieldWrapperComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
- declarations: [MetadataFieldWrapperComponent, NoContentComponent, SpanContentComponent, TextContentComponent, ImgContentComponent]
+ declarations: [MetadataFieldWrapperComponent, NoContentComponent, SpanContentComponent, TextContentComponent]
}).compileComponents();
}));
@@ -58,38 +57,60 @@ describe('MetadataFieldWrapperComponent', () => {
expect(component).toBeDefined();
});
- it('should not show the component when there is no content', () => {
- const parentFixture = TestBed.createComponent(NoContentComponent);
- parentFixture.detectChanges();
- const parentNative = parentFixture.nativeElement;
- const nativeWrapper = parentNative.querySelector(wrapperSelector);
- expect(nativeWrapper.classList.contains('d-none')).toBe(true);
- });
+ describe('with hideIfNoTextContent=true', () => {
+ it('should not show the component when there is no content', () => {
+ const parentFixture = TestBed.createComponent(NoContentComponent);
+ parentFixture.detectChanges();
+ const parentNative = parentFixture.nativeElement;
+ const nativeWrapper = parentNative.querySelector(wrapperSelector);
+ expect(nativeWrapper.classList.contains('d-none')).toBe(true);
+ });
- it('should not show the component when there is DOM content but not text or an image', () => {
- const parentFixture = TestBed.createComponent(SpanContentComponent);
- parentFixture.detectChanges();
- const parentNative = parentFixture.nativeElement;
- const nativeWrapper = parentNative.querySelector(wrapperSelector);
- expect(nativeWrapper.classList.contains('d-none')).toBe(true);
- });
+ it('should not show the component when there is no text content', () => {
+ const parentFixture = TestBed.createComponent(SpanContentComponent);
+ parentFixture.detectChanges();
+ const parentNative = parentFixture.nativeElement;
+ const nativeWrapper = parentNative.querySelector(wrapperSelector);
+ expect(nativeWrapper.classList.contains('d-none')).toBe(true);
+ });
- it('should show the component when there is text content', () => {
- const parentFixture = TestBed.createComponent(TextContentComponent);
- parentFixture.detectChanges();
- const parentNative = parentFixture.nativeElement;
- const nativeWrapper = parentNative.querySelector(wrapperSelector);
- parentFixture.detectChanges();
- expect(nativeWrapper.classList.contains('d-none')).toBe(false);
+ it('should show the component when there is text content', () => {
+ const parentFixture = TestBed.createComponent(TextContentComponent);
+ parentFixture.detectChanges();
+ const parentNative = parentFixture.nativeElement;
+ const nativeWrapper = parentNative.querySelector(wrapperSelector);
+ parentFixture.detectChanges();
+ expect(nativeWrapper.classList.contains('d-none')).toBe(false);
+ });
});
- it('should show the component when there is img content', () => {
- const parentFixture = TestBed.createComponent(ImgContentComponent);
- parentFixture.detectChanges();
- const parentNative = parentFixture.nativeElement;
- const nativeWrapper = parentNative.querySelector(wrapperSelector);
- parentFixture.detectChanges();
- expect(nativeWrapper.classList.contains('d-none')).toBe(false);
- });
+ describe('with hideIfNoTextContent=false', () => {
+ it('should show the component when there is no content', () => {
+ const parentFixture = TestBed.createComponent(NoContentComponent);
+ parentFixture.componentInstance.hideIfNoTextContent = false;
+ parentFixture.detectChanges();
+ const parentNative = parentFixture.nativeElement;
+ const nativeWrapper = parentNative.querySelector(wrapperSelector);
+ expect(nativeWrapper.classList.contains('d-none')).toBe(false);
+ });
+ it('should show the component when there is no text content', () => {
+ const parentFixture = TestBed.createComponent(SpanContentComponent);
+ parentFixture.componentInstance.hideIfNoTextContent = false;
+ parentFixture.detectChanges();
+ const parentNative = parentFixture.nativeElement;
+ const nativeWrapper = parentNative.querySelector(wrapperSelector);
+ expect(nativeWrapper.classList.contains('d-none')).toBe(false);
+ });
+
+ it('should show the component when there is text content', () => {
+ const parentFixture = TestBed.createComponent(TextContentComponent);
+ parentFixture.componentInstance.hideIfNoTextContent = false;
+ parentFixture.detectChanges();
+ const parentNative = parentFixture.nativeElement;
+ const nativeWrapper = parentNative.querySelector(wrapperSelector);
+ parentFixture.detectChanges();
+ expect(nativeWrapper.classList.contains('d-none')).toBe(false);
+ });
+ });
});
diff --git a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts
index 8af108cceb8..5c6b99248f7 100644
--- a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts
+++ b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts
@@ -1,5 +1,4 @@
import { Component, Input } from '@angular/core';
-import { hasNoValue } from '../../../shared/empty.util';
/**
* This component renders any content inside this wrapper.
@@ -17,10 +16,5 @@ export class MetadataFieldWrapperComponent {
*/
@Input() label: string;
- /**
- * Make hasNoValue() available in the template
- */
- hasNoValue(o: any): boolean {
- return hasNoValue(o);
- }
+ @Input() hideIfNoTextContent = true;
}
diff --git a/src/app/+item-page/full/field-components/file-section/full-file-section.component.html b/src/app/+item-page/full/field-components/file-section/full-file-section.component.html
index bc1c63cc322..c5393055dfc 100644
--- a/src/app/+item-page/full/field-components/file-section/full-file-section.component.html
+++ b/src/app/+item-page/full/field-components/file-section/full-file-section.component.html
@@ -11,7 +11,7 @@