Skip to content
Snippets Groups Projects
Unverified Commit 8c124f22 authored by Tim Donohue's avatar Tim Donohue Committed by GitHub
Browse files

Merge pull request #303 from atmire/hide-metadata-labels-without-value

Hide metadata labels without value
parents 1a20cec4 7ac26843
No related branches found
No related tags found
No related merge requests found
<div class="simple-view-element">
<span *ngIf="content.children.length != 0">
<h5 class="simple-view-element-header" *ngIf="label">{{ label }}</h5>
<div class="simple-view-element-body">
<ng-content></ng-content>
</div>
</span>
<div #content class="simple-view-element-body">
<ng-content></ng-content>
</div>
</div>
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Component, DebugElement } from '@angular/core';
import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.component';
@Component({
selector: 'ds-component-with-content',
template: '<ds-metadata-field-wrapper [label]="\'test label\'">\n' +
' <div class="my content">\n' +
' </div>\n' +
'</ds-metadata-field-wrapper>'
})
class ContentComponent {}
describe('MetadataFieldWrapperComponent', () => {
let component: MetadataFieldWrapperComponent;
let fixture: ComponentFixture<MetadataFieldWrapperComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [MetadataFieldWrapperComponent, ContentComponent]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MetadataFieldWrapperComponent);
component = fixture.componentInstance;
});
const wrapperSelector = '.simple-view-element';
const labelSelector = '.simple-view-element-header';
it('should create', () => {
expect(component).toBeDefined();
});
it('should not show a label when there is no content', () => {
component.label = 'test label';
fixture.detectChanges();
const debugLabel = fixture.debugElement.query(By.css(labelSelector));
expect(debugLabel).toBeNull();
});
it('should show a label when there is content', () => {
const parentFixture = TestBed.createComponent(ContentComponent);
parentFixture.detectChanges();
const parentComponent = parentFixture.componentInstance;
const parentNative = parentFixture.nativeElement;
const nativeLabel = parentNative.querySelector(labelSelector);
expect(nativeLabel.textContent).toContain('test label');
});
});
import { Component, Input } from '@angular/core';
import { Metadatum } from '../../../core/shared/metadatum.model';
/**
* This component renders the configured 'values' into the ds-metadata-field-wrapper component.
......@@ -11,7 +12,7 @@ import { Component, Input } from '@angular/core';
})
export class MetadataValuesComponent {
@Input() values: any;
@Input() values: Metadatum[];
@Input() separator: string;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment