mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
add support for multiple metadata fields to the MetadataRepresentationListComponent
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<ds-metadata-representation-list class="ds-item-page-mixed-author-field"
|
||||
[parentItem]="object"
|
||||
[itemType]="'Person'"
|
||||
[metadataField]="'dc.contributor.author'"
|
||||
[metadataFields]="['dc.contributor.author', 'dc.creator']"
|
||||
[label]="'relationships.isAuthorOf' | translate">
|
||||
</ds-metadata-representation-list>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
|
@@ -21,7 +21,7 @@
|
||||
<ds-metadata-representation-list class="ds-item-page-mixed-author-field"
|
||||
[parentItem]="object"
|
||||
[itemType]="'Person'"
|
||||
[metadataField]="'dc.contributor.author'"
|
||||
[metadataFields]="['dc.contributor.author', 'dc.creator']"
|
||||
[label]="'relationships.isAuthorOf' | translate">
|
||||
</ds-metadata-representation-list>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
|
@@ -11,7 +11,7 @@ import { VarDirective } from '../../../shared/utils/var.directive';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
||||
const itemType = 'Person';
|
||||
const metadataField = 'dc.contributor.author';
|
||||
const metadataFields = ['dc.contributor.author', 'dc.creator'];
|
||||
const parentItem: Item = Object.assign(new Item(), {
|
||||
id: 'parent-item',
|
||||
metadata: {
|
||||
@@ -28,6 +28,14 @@ const parentItem: Item = Object.assign(new Item(), {
|
||||
place: 1
|
||||
}
|
||||
],
|
||||
'dc.creator': [
|
||||
{
|
||||
language: null,
|
||||
value: 'Related Creator with authority',
|
||||
authority: 'virtual::related-creator',
|
||||
place: 3,
|
||||
},
|
||||
],
|
||||
'dc.title': [
|
||||
{
|
||||
language: null,
|
||||
@@ -81,13 +89,13 @@ describe('MetadataRepresentationListComponent', () => {
|
||||
comp = fixture.componentInstance;
|
||||
comp.parentItem = parentItem;
|
||||
comp.itemType = itemType;
|
||||
comp.metadataField = metadataField;
|
||||
comp.metadataFields = metadataFields;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should load 2 ds-metadata-representation-loader components', () => {
|
||||
it('should load 3 ds-metadata-representation-loader components', () => {
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-metadata-representation-loader'));
|
||||
expect(fields.length).toBe(2);
|
||||
expect(fields.length).toBe(3);
|
||||
});
|
||||
|
||||
it('should contain one page of items', () => {
|
||||
|
@@ -42,7 +42,7 @@ export class MetadataRepresentationListComponent extends AbstractIncrementalList
|
||||
/**
|
||||
* The metadata field to use for fetching metadata from the item
|
||||
*/
|
||||
@Input() metadataField: string;
|
||||
@Input() metadataFields: string[];
|
||||
|
||||
/**
|
||||
* An i18n label to use as a title for the list
|
||||
@@ -70,7 +70,7 @@ export class MetadataRepresentationListComponent extends AbstractIncrementalList
|
||||
* @param page The page to fetch
|
||||
*/
|
||||
getPage(page: number): Observable<MetadataRepresentation[]> {
|
||||
const metadata = this.parentItem.findMetadataSortedByPlace(this.metadataField);
|
||||
const metadata = this.parentItem.findMetadataSortedByPlace(this.metadataFields);
|
||||
this.total = metadata.length;
|
||||
return this.resolveMetadataRepresentations(metadata, page);
|
||||
}
|
||||
|
@@ -163,8 +163,8 @@ export class DSpaceObject extends ListableObject implements CacheableObject {
|
||||
* Find metadata on a specific field and order all of them using their "place" property.
|
||||
* @param key
|
||||
*/
|
||||
findMetadataSortedByPlace(key: string): MetadataValue[] {
|
||||
return this.allMetadata([key]).sort((a: MetadataValue, b: MetadataValue) => {
|
||||
findMetadataSortedByPlace(keyOrKeys: string | string[]): MetadataValue[] {
|
||||
return this.allMetadata(keyOrKeys).sort((a: MetadataValue, b: MetadataValue) => {
|
||||
if (hasNoValue(a.place) && hasNoValue(b.place)) {
|
||||
return 0;
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<ds-metadata-representation-list
|
||||
[parentItem]="object"
|
||||
[itemType]="'OrgUnit'"
|
||||
[metadataField]="'project.contributor.other'"
|
||||
[metadataFields]="['project.contributor.other']"
|
||||
[label]="'project.page.contributor' | translate">
|
||||
</ds-metadata-representation-list>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
|
Reference in New Issue
Block a user