mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-19 07:53:02 +00:00
new project metadata representation component
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
<ng-template #descTemplate>
|
||||||
|
<span class="text-muted">
|
||||||
|
<span class="item-list-job-title">
|
||||||
|
<span [innerHTML]="metadataRepresentation.firstMetadataValue(['dc.title'])"></span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</ng-template>
|
||||||
|
<ds-truncatable [id]="metadataRepresentation.id">
|
||||||
|
<a [routerLink]="[itemPageRoute]"
|
||||||
|
[innerHTML]="metadataRepresentation.getValue()"
|
||||||
|
[ngbTooltip]="metadataRepresentation.allMetadata(['dc.title']).length > 0 ? descTemplate : null"></a>
|
||||||
|
</ds-truncatable>
|
@@ -0,0 +1,46 @@
|
|||||||
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
|
import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { ProjectItemMetadataListElementComponent } from './project-item-metadata-list-element.component';
|
||||||
|
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
||||||
|
|
||||||
|
const projectTitle = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.';
|
||||||
|
const mockItem = Object.assign(new Item(), { metadata: { 'dc.title': [{ value: projectTitle }] } });
|
||||||
|
const virtMD = Object.assign(new MetadataValue(), { value: projectTitle });
|
||||||
|
|
||||||
|
const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(virtMD), mockItem);
|
||||||
|
|
||||||
|
describe('ProjectItemMetadataListElementComponent', () => {
|
||||||
|
let comp: ProjectItemMetadataListElementComponent;
|
||||||
|
let fixture: ComponentFixture<ProjectItemMetadataListElementComponent>;
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports:[
|
||||||
|
NgbModule
|
||||||
|
],
|
||||||
|
declarations: [ProjectItemMetadataListElementComponent],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).overrideComponent(ProjectItemMetadataListElementComponent, {
|
||||||
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ProjectItemMetadataListElementComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
comp.metadataRepresentation = mockItemMetadataRepresentation;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show the project\'s name as a link', () => {
|
||||||
|
const linkText = fixture.debugElement.query(By.css('a')).nativeElement.textContent;
|
||||||
|
expect(linkText).toBe(projectTitle);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@@ -0,0 +1,15 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator';
|
||||||
|
import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model';
|
||||||
|
import { ItemMetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component';
|
||||||
|
|
||||||
|
@metadataRepresentationComponent('Project', MetadataRepresentationType.Item)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-project-item-metadata-list-element',
|
||||||
|
templateUrl: './project-item-metadata-list-element.component.html'
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying an item of the type Project as a metadata field
|
||||||
|
*/
|
||||||
|
export class ProjectItemMetadataListElementComponent extends ItemMetadataRepresentationListElementComponent {
|
||||||
|
}
|
Reference in New Issue
Block a user