mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
fix issue where ItemMetadataRepresentations didn't get their entity type from the item
This commit is contained in:
@@ -41,7 +41,7 @@ export const relationsToRepresentations = (thisId: string, itemType: string, met
|
||||
}
|
||||
return ids.findById(queryId).pipe(
|
||||
getSucceededRemoteData(),
|
||||
map((d: RemoteData<Item>) => Object.assign(new ItemMetadataRepresentation(itemType), d.payload))
|
||||
map((d: RemoteData<Item>) => Object.assign(new ItemMetadataRepresentation(), d.payload))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
@@ -7,7 +7,7 @@ import { ItemMetadataRepresentation } from '../../../core/shared/metadata-repres
|
||||
|
||||
const itemType = 'type';
|
||||
const metadataRepresentation1 = new MetadatumRepresentation(itemType);
|
||||
const metadataRepresentation2 = new ItemMetadataRepresentation(itemType);
|
||||
const metadataRepresentation2 = new ItemMetadataRepresentation();
|
||||
const representations = [metadataRepresentation1, metadataRepresentation2];
|
||||
|
||||
describe('MetadataRepresentationListComponent', () => {
|
||||
|
@@ -16,9 +16,15 @@ describe('ItemMetadataRepresentation', () => {
|
||||
item.metadata = metadataMap;
|
||||
|
||||
for (const itemType of Object.keys(ItemTypeToValue)) {
|
||||
describe(`when creating an ItemMetadataRepresentation with item-type "${itemType}"`, () => {
|
||||
describe(`when creating an ItemMetadataRepresentation`, () => {
|
||||
beforeEach(() => {
|
||||
itemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(itemType), item);
|
||||
item.metadata['relationship.type'] = [
|
||||
Object.assign(new MetadataValue(), {
|
||||
value: itemType
|
||||
})
|
||||
];
|
||||
|
||||
itemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), item);
|
||||
});
|
||||
|
||||
it('should have a representation type of item', () => {
|
||||
@@ -30,7 +36,7 @@ describe('ItemMetadataRepresentation', () => {
|
||||
});
|
||||
|
||||
it('should return the correct item type', () => {
|
||||
expect(itemMetadataRepresentation.itemType).toEqual(itemType);
|
||||
expect(itemMetadataRepresentation.itemType).toEqual(item.firstMetadataValue('relationship.type'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -7,7 +7,8 @@ import { hasValue } from '../../../../shared/empty.util';
|
||||
*/
|
||||
export const ItemTypeToValue = {
|
||||
Default: 'dc.title',
|
||||
Person: 'dc.contributor.author'
|
||||
Person: 'dc.contributor.author',
|
||||
OrgUnit: 'dc.title'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -18,11 +19,8 @@ export class ItemMetadataRepresentation extends Item implements MetadataRepresen
|
||||
/**
|
||||
* The type of item this item can be represented as
|
||||
*/
|
||||
itemType: string;
|
||||
|
||||
constructor(itemType: string) {
|
||||
super();
|
||||
this.itemType = itemType;
|
||||
get itemType(): string {
|
||||
return this.firstMetadataValue('relationship.type');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -29,7 +29,7 @@ const mockItem: Item = Object.assign(new Item(), {
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(relationType), mockItem);
|
||||
const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem);
|
||||
let viewMode = ItemViewMode.Full;
|
||||
|
||||
describe('ItemTypeSwitcherComponent', () => {
|
||||
|
@@ -0,0 +1,13 @@
|
||||
<ng-template #descTemplate>
|
||||
<span class="text-muted">
|
||||
<span *ngIf="item.allMetadata(['orgunit.identifier.description']).length > 0"
|
||||
class="item-list-job-title">
|
||||
<span [innerHTML]="firstMetadataValue(['orgunit.identifier.description'])"></span>
|
||||
</span>
|
||||
</span>
|
||||
</ng-template>
|
||||
<ds-truncatable [id]="item.id">
|
||||
<a [routerLink]="['/items/' + item.id]"
|
||||
[innerHTML]="firstMetadataValue('orgunit.identifier.name')"
|
||||
[tooltip]="descTemplate"></a>
|
||||
</ds-truncatable>
|
@@ -0,0 +1,15 @@
|
||||
import { ItemViewMode, rendersItemType } from '../../../../items/item-type-decorator';
|
||||
import { Component } from '@angular/core';
|
||||
import { TypedItemSearchResultListElementComponent } from '../typed-item-search-result-list-element.component';
|
||||
import { MetadataRepresentationType } from '../../../../../core/shared/metadata-representation/metadata-representation.model';
|
||||
|
||||
@rendersItemType('OrgUnit', ItemViewMode.Element, MetadataRepresentationType.Item)
|
||||
@Component({
|
||||
selector: 'ds-orgunit-metadata-list-element',
|
||||
templateUrl: './orgunit-metadata-list-element.component.html'
|
||||
})
|
||||
/**
|
||||
* The component for displaying a list element for an item of the type OrgUnit
|
||||
*/
|
||||
export class OrgUnitMetadataListElementComponent extends TypedItemSearchResultListElementComponent {
|
||||
}
|
@@ -5,7 +5,7 @@ import { ItemMetadataListElementComponent } from './item-metadata-list-element.c
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||
|
||||
const mockItemMetadataRepresentation = new ItemMetadataRepresentation('type');
|
||||
const mockItemMetadataRepresentation = new ItemMetadataRepresentation();
|
||||
|
||||
describe('ItemMetadataListElementComponent', () => {
|
||||
let comp: ItemMetadataListElementComponent;
|
||||
|
@@ -10,6 +10,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { NgxPaginationModule } from 'ngx-pagination';
|
||||
import { ItemTypeSwitcherComponent } from './items/switcher/item-type-switcher.component';
|
||||
import { OrgUnitMetadataListElementComponent } from './object-list/item-list-element/item-types/orgunit/orgunit-metadata-list-element.component';
|
||||
import { TypedItemSearchResultListElementComponent } from './object-list/item-list-element/item-types/typed-item-search-result-list-element.component';
|
||||
import { PublicationListElementComponent } from './object-list/item-list-element/item-types/publication/publication-list-element.component';
|
||||
import { OrgUnitListElementComponent } from './object-list/item-list-element/item-types/orgunit/orgunit-list-element.component';
|
||||
@@ -247,6 +248,7 @@ const ENTRY_COMPONENTS = [
|
||||
PublicationListElementComponent,
|
||||
PersonListElementComponent,
|
||||
PersonMetadataListElementComponent,
|
||||
OrgUnitMetadataListElementComponent,
|
||||
OrgUnitListElementComponent,
|
||||
ProjectListElementComponent,
|
||||
JournalListElementComponent,
|
||||
|
Reference in New Issue
Block a user