mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
74572: Separate components for untyped items
This commit is contained in:
@@ -12,7 +12,7 @@ import { WorkflowItem } from '../../../../../core/submission/models/workflowitem
|
||||
import { LinkService } from '../../../../../core/cache/builders/link.service';
|
||||
import { followLink } from '../../../../../shared/utils/follow-link-config.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { PublicationGridElementComponent } from '../../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component';
|
||||
import { ItemGridElementComponent } from '../../../../../shared/object-grid/item-grid-element/item-types/item/item-grid-element.component';
|
||||
import { ListableObjectDirective } from '../../../../../shared/object-collection/shared/listable-object/listable-object.directive';
|
||||
import { WorkflowItemSearchResult } from '../../../../../shared/object-collection/shared/workflow-item-search-result.model';
|
||||
import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service';
|
||||
@@ -43,7 +43,7 @@ describe('WorkflowItemAdminWorkflowGridElementComponent', () => {
|
||||
init();
|
||||
TestBed.configureTestingModule(
|
||||
{
|
||||
declarations: [WorkflowItemSearchResultAdminWorkflowGridElementComponent, PublicationGridElementComponent, ListableObjectDirective],
|
||||
declarations: [WorkflowItemSearchResultAdminWorkflowGridElementComponent, ItemGridElementComponent, ListableObjectDirective],
|
||||
imports: [
|
||||
NoopAnimationsModule,
|
||||
TranslateModule.forRoot(),
|
||||
@@ -60,7 +60,7 @@ describe('WorkflowItemAdminWorkflowGridElementComponent', () => {
|
||||
})
|
||||
.overrideComponent(WorkflowItemSearchResultAdminWorkflowGridElementComponent, {
|
||||
set: {
|
||||
entryComponents: [PublicationGridElementComponent]
|
||||
entryComponents: [ItemGridElementComponent]
|
||||
}
|
||||
})
|
||||
.compileComponents();
|
||||
|
@@ -30,6 +30,7 @@ import { UploadBitstreamComponent } from './bitstreams/upload/upload-bitstream.c
|
||||
import { TabbedRelatedEntitiesSearchComponent } from './simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component';
|
||||
import { StatisticsModule } from '../statistics/statistics.module';
|
||||
import { AbstractIncrementalListComponent } from './simple/abstract-incremental-list/abstract-incremental-list.component';
|
||||
import { UntypedItemComponent } from './simple/item-types/untyped-item/untyped-item.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -54,6 +55,7 @@ import { AbstractIncrementalListComponent } from './simple/abstract-incremental-
|
||||
CollectionsComponent,
|
||||
FullFileSectionComponent,
|
||||
PublicationComponent,
|
||||
UntypedItemComponent,
|
||||
RelatedItemsComponent,
|
||||
ItemComponent,
|
||||
GenericItemPageFieldComponent,
|
||||
@@ -75,7 +77,8 @@ import { AbstractIncrementalListComponent } from './simple/abstract-incremental-
|
||||
TabbedRelatedEntitiesSearchComponent
|
||||
],
|
||||
entryComponents: [
|
||||
PublicationComponent
|
||||
PublicationComponent,
|
||||
UntypedItemComponent
|
||||
]
|
||||
})
|
||||
export class ItemPageModule {
|
||||
|
@@ -36,7 +36,7 @@ const mockItem: Item = Object.assign(new Item(), {
|
||||
relationships: createRelationshipsObservable()
|
||||
});
|
||||
|
||||
describe('PublicationComponent', () => {
|
||||
describe('UntypedItemComponent', () => {
|
||||
let comp: PublicationComponent;
|
||||
let fixture: ComponentFixture<PublicationComponent>;
|
||||
|
||||
|
@@ -9,7 +9,6 @@ import { listableObjectComponent } from '../../../../shared/object-collection/sh
|
||||
*/
|
||||
|
||||
@listableObjectComponent('Publication', ViewMode.StandalonePage)
|
||||
@listableObjectComponent(Item, ViewMode.StandalonePage)
|
||||
@Component({
|
||||
selector: 'ds-publication',
|
||||
styleUrls: ['./publication.component.scss'],
|
||||
|
@@ -0,0 +1,67 @@
|
||||
<div class="d-flex flex-row">
|
||||
<h2 class="item-page-title-field mr-auto">
|
||||
{{'item.page.titleprefix' | translate}}<ds-metadata-values [mdValues]="object?.allMetadata(['dc.title'])"></ds-metadata-values>
|
||||
</h2>
|
||||
<div class="pl-2">
|
||||
<ds-dso-page-edit-button [pageRoutePrefix]="'items'" [dso]="object" [tooltipMsg]="'item.page.edit'"></ds-dso-page-edit-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<ds-metadata-field-wrapper>
|
||||
<ds-thumbnail [thumbnail]="getThumbnail() | async"></ds-thumbnail>
|
||||
</ds-metadata-field-wrapper>
|
||||
<ds-item-page-file-section [item]="object"></ds-item-page-file-section>
|
||||
<ds-item-page-date-field [item]="object"></ds-item-page-date-field>
|
||||
<ds-item-page-author-field [item]="object"></ds-item-page-author-field>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['journal.title']"
|
||||
[label]="'item.page.journal-title'">
|
||||
</ds-generic-item-page-field>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['journal.identifier.issn']"
|
||||
[label]="'item.page.journal-issn'">
|
||||
</ds-generic-item-page-field>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['journalvolume.identifier.name']"
|
||||
[label]="'item.page.volume-title'">
|
||||
</ds-generic-item-page-field>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['dc.publisher']"
|
||||
[label]="'item.page.publisher'">
|
||||
</ds-generic-item-page-field>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<ds-metadata-representation-list
|
||||
[parentItem]="object"
|
||||
[itemType]="'Person'"
|
||||
[metadataField]="'dc.contributor.author'"
|
||||
[label]="'relationships.isAuthorOf' | translate">
|
||||
</ds-metadata-representation-list>
|
||||
<ds-item-page-abstract-field [item]="object"></ds-item-page-abstract-field>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['dc.description']"
|
||||
[label]="'item.page.description'">
|
||||
</ds-generic-item-page-field>
|
||||
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['dc.subject']"
|
||||
[separator]="','"
|
||||
[label]="'item.page.subject'">
|
||||
</ds-generic-item-page-field>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['dc.identifier.citation']"
|
||||
[label]="'item.page.citation'">
|
||||
</ds-generic-item-page-field>
|
||||
<ds-item-page-uri-field [item]="object"
|
||||
[fields]="['dc.identifier.uri']"
|
||||
[label]="'item.page.uri'">
|
||||
</ds-item-page-uri-field>
|
||||
<ds-item-page-collections [item]="object"></ds-item-page-collections>
|
||||
<div>
|
||||
<a class="btn btn-outline-primary" [routerLink]="['/items/' + object.id + '/full']">
|
||||
{{"item.page.link.full" | translate}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1 @@
|
||||
@import '../../../../../styles/variables.scss';
|
@@ -0,0 +1,112 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||
import { DefaultChangeAnalyzer } from '../../../../core/data/default-change-analyzer.service';
|
||||
import { DSOChangeAnalyzer } from '../../../../core/data/dso-change-analyzer.service';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { RelationshipService } from '../../../../core/data/relationship.service';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
||||
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { MetadataMap } from '../../../../core/shared/metadata.models';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { UUIDService } from '../../../../core/shared/uuid.service';
|
||||
import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.mock';
|
||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
|
||||
import { createRelationshipsObservable } from '../shared/item.component.spec';
|
||||
import { UntypedItemComponent } from './untyped-item.component';
|
||||
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bundles: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: new MetadataMap(),
|
||||
relationships: createRelationshipsObservable()
|
||||
});
|
||||
|
||||
describe('UntypedItemComponent', () => {
|
||||
let comp: UntypedItemComponent;
|
||||
let fixture: ComponentFixture<UntypedItemComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
const mockBitstreamDataService = {
|
||||
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
||||
return createSuccessfulRemoteDataObject$(new Bitstream());
|
||||
}
|
||||
};
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
})],
|
||||
declarations: [UntypedItemComponent, GenericItemPageFieldComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ItemDataService, useValue: {} },
|
||||
{ provide: TruncatableService, useValue: {} },
|
||||
{ provide: RelationshipService, useValue: {} },
|
||||
{ provide: ObjectCacheService, useValue: {} },
|
||||
{ provide: UUIDService, useValue: {} },
|
||||
{ provide: Store, useValue: {} },
|
||||
{ provide: RemoteDataBuildService, useValue: {} },
|
||||
{ provide: CommunityDataService, useValue: {} },
|
||||
{ provide: HALEndpointService, useValue: {} },
|
||||
{ provide: NotificationsService, useValue: {} },
|
||||
{ provide: HttpClient, useValue: {} },
|
||||
{ provide: DSOChangeAnalyzer, useValue: {} },
|
||||
{ provide: DefaultChangeAnalyzer, useValue: {} },
|
||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||
],
|
||||
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(UntypedItemComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(UntypedItemComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should contain a component to display the date', () => {
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-date-field'));
|
||||
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should contain a component to display the author', () => {
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-author-field'));
|
||||
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should contain a component to display the abstract', () => {
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-abstract-field'));
|
||||
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should contain a component to display the uri', () => {
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-uri-field'));
|
||||
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should contain a component to display the collections', () => {
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-collections'));
|
||||
expect(fields.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
});
|
@@ -0,0 +1,20 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { ItemComponent } from '../shared/item.component';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
|
||||
|
||||
/**
|
||||
* Component that represents a publication Item page
|
||||
*/
|
||||
|
||||
@listableObjectComponent(Item, ViewMode.StandalonePage)
|
||||
@Component({
|
||||
selector: 'ds-untyped-item',
|
||||
styleUrls: ['./untyped-item.component.scss'],
|
||||
templateUrl: './untyped-item.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class UntypedItemComponent extends ItemComponent {
|
||||
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
import { autoserialize, autoserializeAs, deserialize, inheritSerialization } from 'cerialize';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { isEmpty } from '../../shared/empty.util';
|
||||
import { DEFAULT_ENTITY_TYPE } from '../../shared/metadata-representation/metadata-representation.decorator';
|
||||
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
|
||||
import { link, typedObject } from '../cache/builders/build-decorators';
|
||||
import { PaginatedList } from '../data/paginated-list';
|
||||
@@ -105,9 +104,9 @@ export class Item extends DSpaceObject implements ChildHALResource {
|
||||
* Method that returns as which type of object this object should be rendered
|
||||
*/
|
||||
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
|
||||
let entityType = this.firstMetadataValue('relationship.type');
|
||||
const entityType = this.firstMetadataValue('relationship.type');
|
||||
if (isEmpty(entityType)) {
|
||||
entityType = DEFAULT_ENTITY_TYPE;
|
||||
return super.getRenderTypes();
|
||||
}
|
||||
return [entityType, ...super.getRenderTypes()];
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
|
@@ -3,8 +3,8 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils';
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec';
|
||||
import { JournalIssueSearchResultGridElementComponent } from './journal-issue-search-result-grid-element.component';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
|
@@ -3,8 +3,8 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils';
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec';
|
||||
import { JournalVolumeSearchResultGridElementComponent } from './journal-volume-search-result-grid-element.component';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
|
@@ -3,8 +3,8 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils';
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec';
|
||||
import { JournalSearchResultGridElementComponent } from './journal-search-result-grid-element.component';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
|
||||
[routerLink]="['/items/' + dso.id]" class="lead"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
|
||||
[routerLink]="['/items/' + dso.id]" class="lead"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
|
||||
[routerLink]="['/items/' + dso.id]" class="lead"
|
||||
|
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('organization.legalName')"></h4>
|
||||
</ds-truncatable-part>
|
||||
|
@@ -4,7 +4,7 @@ import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { OrgUnitSearchResultGridElementComponent } from './org-unit-search-result-grid-element.component';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title"
|
||||
[innerHTML]="firstMetadataValue('person.familyName') + ', ' + firstMetadataValue('person.givenName')"></h4>
|
||||
|
@@ -3,8 +3,8 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils';
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec';
|
||||
import { PersonSearchResultGridElementComponent } from './person-search-result-grid-element.component';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
|
@@ -4,7 +4,7 @@ import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { ProjectSearchResultGridElementComponent } from './project-search-result-grid-element.component';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec';
|
||||
import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
|
||||
[routerLink]="['/items/' + dso.id]" class="lead"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
|
||||
[routerLink]="['/items/' + dso.id]" class="lead"
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
|
||||
[routerLink]="['/items/' + dso.id]" class="lead"
|
||||
[innerHTML]="firstMetadataValue('dc.title')"></a>
|
||||
|
@@ -6,7 +6,7 @@ import { GenericConstructor } from '../../../../core/shared/generic-constructor'
|
||||
import { Context } from '../../../../core/shared/context.model';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import * as listableObjectDecorators from './listable-object.decorator';
|
||||
import { PublicationListElementComponent } from '../../../object-list/item-list-element/item-types/publication/publication-list-element.component';
|
||||
import { ItemListElementComponent } from '../../../object-list/item-list-element/item-types/item/item-list-element.component';
|
||||
import { ListableObjectDirective } from './listable-object.directive';
|
||||
import { spyOnExported } from '../../../testing/utils.test';
|
||||
|
||||
@@ -27,13 +27,13 @@ describe('ListableObjectComponentLoaderComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
declarations: [ListableObjectComponentLoaderComponent, PublicationListElementComponent, ListableObjectDirective],
|
||||
declarations: [ListableObjectComponentLoaderComponent, ItemListElementComponent, ListableObjectDirective],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
providers: [ComponentFactoryResolver]
|
||||
}).overrideComponent(ListableObjectComponentLoaderComponent, {
|
||||
set: {
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
entryComponents: [PublicationListElementComponent]
|
||||
entryComponents: [ItemListElementComponent]
|
||||
}
|
||||
}).compileComponents();
|
||||
}));
|
||||
@@ -45,7 +45,7 @@ describe('ListableObjectComponentLoaderComponent', () => {
|
||||
comp.object = new TestType();
|
||||
comp.viewMode = testViewMode;
|
||||
comp.context = testContext;
|
||||
spyOnExported(listableObjectDecorators, 'getListableObjectComponent').and.returnValue(PublicationListElementComponent);
|
||||
spyOnExported(listableObjectDecorators, 'getListableObjectComponent').and.returnValue(ItemListElementComponent);
|
||||
fixture.detectChanges();
|
||||
|
||||
}));
|
||||
|
@@ -0,0 +1,4 @@
|
||||
<ds-item-search-result-grid-element [showLabel]="showLabel" [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType">
|
||||
<ng-content></ng-content>
|
||||
<ng-content></ng-content>
|
||||
</ds-item-search-result-grid-element>
|
@@ -4,7 +4,7 @@ import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { PublicationGridElementComponent } from './publication-grid-element.component';
|
||||
import { ItemGridElementComponent } from './item-grid-element.component';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils';
|
||||
@@ -41,7 +41,7 @@ const mockItem = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('PublicationGridElementComponent', () => {
|
||||
describe('ItemGridElementComponent', () => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
@@ -52,18 +52,18 @@ describe('PublicationGridElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [PublicationGridElementComponent, TruncatePipe],
|
||||
declarations: [ItemGridElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(PublicationGridElementComponent, {
|
||||
}).overrideComponent(ItemGridElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(PublicationGridElementComponent);
|
||||
fixture = TestBed.createComponent(ItemGridElementComponent);
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
@@ -74,7 +74,7 @@ describe('PublicationGridElementComponent', () => {
|
||||
});
|
||||
|
||||
it(`should contain a PublicationGridElementComponent`, () => {
|
||||
const publicationGridElement = fixture.debugElement.query(By.css(`ds-publication-search-result-grid-element`));
|
||||
const publicationGridElement = fixture.debugElement.query(By.css(`ds-item-search-result-grid-element`));
|
||||
expect(publicationGridElement).not.toBeNull();
|
||||
});
|
||||
});
|
@@ -8,13 +8,13 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
@listableObjectComponent('Publication', ViewMode.GridElement)
|
||||
@listableObjectComponent(Item, ViewMode.GridElement)
|
||||
@Component({
|
||||
selector: 'ds-publication-grid-element',
|
||||
styleUrls: ['./publication-grid-element.component.scss'],
|
||||
templateUrl: './publication-grid-element.component.html',
|
||||
selector: 'ds-item-grid-element',
|
||||
styleUrls: ['./item-grid-element.component.scss'],
|
||||
templateUrl: './item-grid-element.component.html',
|
||||
animations: [focusShadow]
|
||||
})
|
||||
/**
|
||||
* The component for displaying a grid element for an item of the type Publication
|
||||
*/
|
||||
export class PublicationGridElementComponent extends AbstractListableElementComponent<Item> {
|
||||
export class ItemGridElementComponent extends AbstractListableElementComponent<Item> {
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
<ds-publication-search-result-grid-element [showLabel]="showLabel" [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType">
|
||||
<ng-content></ng-content>
|
||||
<ng-content></ng-content>
|
||||
</ds-publication-search-result-grid-element>
|
@@ -8,6 +8,7 @@
|
||||
</ds-grid-thumbnail>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<h4 class="card-title">{{dso.name}}</h4>
|
||||
<p *ngIf="dso.shortDescription" class="card-text">{{dso.shortDescription}}</p>
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
|
@@ -8,6 +8,7 @@
|
||||
</ds-grid-thumbnail>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<h4 class="card-title">{{dso.name}}</h4>
|
||||
<p *ngIf="dso.shortDescription" class="card-text">{{dso.shortDescription}}</p>
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
|
@@ -15,7 +15,7 @@
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
@@ -24,7 +24,7 @@ import { ItemSearchResult } from '../../../../object-collection/shared/item-sear
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { PublicationSearchResultGridElementComponent } from './publication-search-result-grid-element.component';
|
||||
import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
@@ -72,7 +72,7 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('PublicationGridElementComponent', getEntityGridElementTestComponent(PublicationSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract']));
|
||||
describe('ItemGridElementComponent', getEntityGridElementTestComponent(ItemSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract']));
|
||||
|
||||
/**
|
||||
* Create test cases for a grid component of an entity.
|
@@ -9,13 +9,13 @@ import { ItemSearchResult } from '../../../../object-collection/shared/item-sear
|
||||
@listableObjectComponent('PublicationSearchResult', ViewMode.GridElement)
|
||||
@listableObjectComponent(ItemSearchResult, ViewMode.GridElement)
|
||||
@Component({
|
||||
selector: 'ds-publication-search-result-grid-element',
|
||||
styleUrls: ['./publication-search-result-grid-element.component.scss'],
|
||||
templateUrl: './publication-search-result-grid-element.component.html',
|
||||
selector: 'ds-item-search-result-grid-element',
|
||||
styleUrls: ['./item-search-result-grid-element.component.scss'],
|
||||
templateUrl: './item-search-result-grid-element.component.html',
|
||||
animations: [focusShadow]
|
||||
})
|
||||
/**
|
||||
* The component for displaying a grid element for an item search result of the type Publication
|
||||
*/
|
||||
export class PublicationSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
|
||||
export class ItemSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<ds-item-search-result-list-element [showLabel]="showLabel" [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-item-search-result-list-element>
|
@@ -1,7 +1,7 @@
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { PublicationListElementComponent } from './publication-list-element.component';
|
||||
import { ItemListElementComponent } from './item-list-element.component';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
@@ -43,7 +43,7 @@ const mockItem: Item = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('PublicationListElementComponent', () => {
|
||||
describe('ItemListElementComponent', () => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
@@ -53,18 +53,18 @@ describe('PublicationListElementComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PublicationListElementComponent, TruncatePipe],
|
||||
declarations: [ItemListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(PublicationListElementComponent, {
|
||||
}).overrideComponent(ItemListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(PublicationListElementComponent);
|
||||
fixture = TestBed.createComponent(ItemListElementComponent);
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
@@ -75,7 +75,7 @@ describe('PublicationListElementComponent', () => {
|
||||
});
|
||||
|
||||
it(`should contain a PublicationListElementComponent`, () => {
|
||||
const publicationListElement = fixture.debugElement.query(By.css(`ds-publication-search-result-list-element`));
|
||||
const publicationListElement = fixture.debugElement.query(By.css(`ds-item-search-result-list-element`));
|
||||
expect(publicationListElement).not.toBeNull();
|
||||
});
|
||||
});
|
@@ -7,12 +7,12 @@ import { Item } from '../../../../../core/shared/item.model';
|
||||
@listableObjectComponent('Publication', ViewMode.ListElement)
|
||||
@listableObjectComponent(Item, ViewMode.ListElement)
|
||||
@Component({
|
||||
selector: 'ds-publication-list-element',
|
||||
styleUrls: ['./publication-list-element.component.scss'],
|
||||
templateUrl: './publication-list-element.component.html'
|
||||
selector: 'ds-item-list-element',
|
||||
styleUrls: ['./item-list-element.component.scss'],
|
||||
templateUrl: './item-list-element.component.html'
|
||||
})
|
||||
/**
|
||||
* The component for displaying a list element for an item of the type Publication
|
||||
*/
|
||||
export class PublicationListElementComponent extends AbstractListableElementComponent<Item> {
|
||||
export class ItemListElementComponent extends AbstractListableElementComponent<Item> {
|
||||
}
|
@@ -1 +0,0 @@
|
||||
<ds-publication-search-result-list-element [showLabel]="showLabel" [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-publication-search-result-list-element>
|
@@ -1,3 +0,0 @@
|
||||
<div *ngIf="object && object.firstMetadataValue('relationship.type') as type">
|
||||
<span class="badge badge-light">{{ type.toLowerCase() + '.listelement.badge' | translate }}</span>
|
||||
</div>
|
@@ -1,16 +0,0 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-type-badge',
|
||||
templateUrl: './item-type-badge.component.html'
|
||||
})
|
||||
/**
|
||||
* Component rendering the type of an item as a badge
|
||||
*/
|
||||
export class ItemTypeBadgeComponent {
|
||||
/**
|
||||
* The component used to retrieve the type from
|
||||
*/
|
||||
@Input() object: DSpaceObject;
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
<ng-container *ngIf="status">
|
||||
<ds-mydspace-item-status [status]="status"></ds-mydspace-item-status>
|
||||
</ng-container>
|
||||
<ds-item-type-badge [object]="item"></ds-item-type-badge>
|
||||
<ds-type-badge [object]="item"></ds-type-badge>
|
||||
<ds-truncatable [id]="item.id">
|
||||
<h3 [innerHTML]="item.firstMetadataValue('dc.title') || ('mydspace.results.no-title' | translate)" [ngClass]="{'lead': true,'text-muted': !item.firstMetadataValue('dc.title')}"></h3>
|
||||
<div>
|
||||
|
@@ -153,7 +153,7 @@ describe('ItemListPreviewComponent', () => {
|
||||
});
|
||||
|
||||
it('should show the entity type span', () => {
|
||||
const entityField = fixture.debugElement.query(By.css('ds-item-type-badge'));
|
||||
const entityField = fixture.debugElement.query(By.css('ds-type-badge'));
|
||||
expect(entityField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
@@ -1,3 +1,4 @@
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/collections/' + dso.id]" class="lead" [innerHTML]="firstMetadataValue('dc.title')"></a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="lead" [innerHTML]="firstMetadataValue('dc.title')"></span>
|
||||
<div *ngIf="dso.shortDescription" class="text-muted abstract-text" [innerHTML]="firstMetadataValue('dc.description.abstract')"></div>
|
||||
|
@@ -1,3 +1,4 @@
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/communities/' + dso.id]" class="lead" [innerHTML]="firstMetadataValue('dc.title')"></a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="lead" [innerHTML]="firstMetadataValue('dc.title')"></span>
|
||||
<div *ngIf="dso.shortDescription" class="text-muted abstract-text" [innerHTML]="firstMetadataValue('dc.description.abstract')"></div>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<ds-item-type-badge *ngIf="showLabel" [object]="dso"></ds-item-type-badge>
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
|
||||
<ds-truncatable [id]="dso.id" *ngIf="object !== undefined && object !== null">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
|
@@ -2,14 +2,14 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PublicationSearchResultListElementComponent } from './publication-search-result-list-element.component';
|
||||
import { ItemSearchResultListElementComponent } from './item-search-result-list-element.component';
|
||||
import { Item } from '../../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../../truncatable/truncatable.service';
|
||||
import { ItemSearchResult } from '../../../../../object-collection/shared/item-search-result.model';
|
||||
|
||||
let publicationListElementComponent: PublicationSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<PublicationSearchResultListElementComponent>;
|
||||
let publicationListElementComponent: ItemSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
||||
indexableObject:
|
||||
@@ -64,22 +64,22 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign(new ItemSearchRe
|
||||
})
|
||||
});
|
||||
|
||||
describe('PublicationListElementComponent', () => {
|
||||
describe('ItemListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PublicationSearchResultListElementComponent, TruncatePipe],
|
||||
declarations: [ItemSearchResultListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(PublicationSearchResultListElementComponent, {
|
||||
}).overrideComponent(ItemSearchResultListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(PublicationSearchResultListElementComponent);
|
||||
fixture = TestBed.createComponent(ItemSearchResultListElementComponent);
|
||||
publicationListElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
@@ -8,12 +8,12 @@ import { Item } from '../../../../../../core/shared/item.model';
|
||||
@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement)
|
||||
@listableObjectComponent(ItemSearchResult, ViewMode.ListElement)
|
||||
@Component({
|
||||
selector: 'ds-publication-search-result-list-element',
|
||||
styleUrls: ['./publication-search-result-list-element.component.scss'],
|
||||
templateUrl: './publication-search-result-list-element.component.html'
|
||||
selector: 'ds-item-search-result-list-element',
|
||||
styleUrls: ['./item-search-result-list-element.component.scss'],
|
||||
templateUrl: './item-search-result-list-element.component.html'
|
||||
})
|
||||
/**
|
||||
* The component for displaying a list element for an item search result of the type Publication
|
||||
*/
|
||||
export class PublicationSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
|
||||
export class ItemSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
<div *ngIf="typeMessage">
|
||||
<span class="badge badge-light">{{ typeMessage | translate }}</span>
|
||||
</div>
|
@@ -5,11 +5,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { TruncatePipe } from '../../utils/truncate.pipe';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ItemTypeBadgeComponent } from './item-type-badge.component';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TypeBadgeComponent } from './type-badge.component';
|
||||
|
||||
let comp: ItemTypeBadgeComponent;
|
||||
let fixture: ComponentFixture<ItemTypeBadgeComponent>;
|
||||
let comp: TypeBadgeComponent;
|
||||
let fixture: ComponentFixture<TypeBadgeComponent>;
|
||||
|
||||
const type = 'authorOfPublication';
|
||||
|
||||
@@ -41,15 +41,15 @@ describe('ItemTypeBadgeComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot()],
|
||||
declarations: [ItemTypeBadgeComponent, TruncatePipe],
|
||||
declarations: [TypeBadgeComponent, TruncatePipe],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ItemTypeBadgeComponent, {
|
||||
}).overrideComponent(TypeBadgeComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemTypeBadgeComponent);
|
||||
fixture = TestBed.createComponent(TypeBadgeComponent);
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
@@ -71,9 +71,9 @@ describe('ItemTypeBadgeComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show a badge', () => {
|
||||
it('should show an item badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('span.badge'));
|
||||
expect(badge).toBeNull();
|
||||
expect(badge.nativeElement.textContent).toContain('item');
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,41 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { isEmpty } from '../../empty.util';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-type-badge',
|
||||
templateUrl: './type-badge.component.html'
|
||||
})
|
||||
/**
|
||||
* Component rendering the type of an item as a badge
|
||||
*/
|
||||
export class TypeBadgeComponent {
|
||||
|
||||
private _object: DSpaceObject;
|
||||
private _typeMessage: string;
|
||||
|
||||
/**
|
||||
* The component used to retrieve the type from
|
||||
*/
|
||||
@Input() set object(object: DSpaceObject) {
|
||||
this._object = object;
|
||||
|
||||
const renderTypes = this._object.getRenderTypes();
|
||||
if (!isEmpty(renderTypes.length)) {
|
||||
const renderType = renderTypes[0];
|
||||
if (renderType instanceof Function) {
|
||||
this._typeMessage = `${(renderType as any).name.toLowerCase()}.listelement.badge`;
|
||||
} else {
|
||||
this._typeMessage = `${renderType.toLowerCase()}.listelement.badge`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get object(): DSpaceObject {
|
||||
return this._object;
|
||||
}
|
||||
|
||||
get typeMessage(): string {
|
||||
return this._typeMessage;
|
||||
}
|
||||
}
|
@@ -21,7 +21,7 @@ import { ComcolRoleComponent } from './comcol-forms/edit-comcol-page/comcol-role
|
||||
import { ConfirmationModalComponent } from './confirmation-modal/confirmation-modal.component';
|
||||
import { ExportMetadataSelectorComponent } from './dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component';
|
||||
import { FileDropzoneNoUploaderComponent } from './file-dropzone-no-uploader/file-dropzone-no-uploader.component';
|
||||
import { PublicationListElementComponent } from './object-list/item-list-element/item-types/publication/publication-list-element.component';
|
||||
import { ItemListElementComponent } from './object-list/item-list-element/item-types/item/item-list-element.component';
|
||||
import { EnumKeysPipe } from './utils/enum-keys-pipe';
|
||||
import { FileSizePipe } from './utils/file-size-pipe';
|
||||
import { MetadataFieldValidator } from './utils/metadatafield-validator.directive';
|
||||
@@ -160,13 +160,12 @@ import { ItemSelectComponent } from './object-select/item-select/item-select.com
|
||||
import { CollectionSelectComponent } from './object-select/collection-select/collection-select.component';
|
||||
import { FilterInputSuggestionsComponent } from './input-suggestions/filter-suggestions/filter-input-suggestions.component';
|
||||
import { DsoInputSuggestionsComponent } from './input-suggestions/dso-input-suggestions/dso-input-suggestions.component';
|
||||
import { PublicationGridElementComponent } from './object-grid/item-grid-element/item-types/publication/publication-grid-element.component';
|
||||
import { ItemTypeBadgeComponent } from './object-list/item-type-badge/item-type-badge.component';
|
||||
import { ItemGridElementComponent } from './object-grid/item-grid-element/item-types/item/item-grid-element.component';
|
||||
import { TypeBadgeComponent } from './object-list/type-badge/type-badge.component';
|
||||
import { MetadataRepresentationLoaderComponent } from './metadata-representation/metadata-representation-loader.component';
|
||||
import { MetadataRepresentationDirective } from './metadata-representation/metadata-representation.directive';
|
||||
import { ListableObjectComponentLoaderComponent } from './object-collection/shared/listable-object/listable-object-component-loader.component';
|
||||
import { PublicationSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-types/publication/publication-search-result-list-element.component';
|
||||
import { PublicationSearchResultGridElementComponent } from './object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component';
|
||||
import { ItemSearchResultListElementComponent } from './object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component';
|
||||
import { ListableObjectDirective } from './object-collection/shared/listable-object/listable-object.directive';
|
||||
import { SearchLabelComponent } from './search/search-labels/search-label/search-label.component';
|
||||
import { ItemMetadataRepresentationListElementComponent } from './object-list/metadata-representation-list-element/item/item-metadata-representation-list-element.component';
|
||||
@@ -217,6 +216,7 @@ import { CommunitySidebarSearchListElementComponent } from './object-list/sideba
|
||||
import { AuthorizedCollectionSelectorComponent } from './dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component';
|
||||
import { DsoPageEditButtonComponent } from './dso-page/dso-page-edit-button/dso-page-edit-button.component';
|
||||
import { HoverClassDirective } from './hover-class.directive';
|
||||
import { ItemSearchResultGridElementComponent } from './object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component';
|
||||
|
||||
const MODULES = [
|
||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||
@@ -381,7 +381,7 @@ const COMPONENTS = [
|
||||
BrowseByComponent,
|
||||
AbstractTrackableComponent,
|
||||
ComcolMetadataComponent,
|
||||
ItemTypeBadgeComponent,
|
||||
TypeBadgeComponent,
|
||||
BrowseByComponent,
|
||||
AbstractTrackableComponent,
|
||||
CustomSwitchComponent,
|
||||
@@ -397,7 +397,7 @@ const COMPONENTS = [
|
||||
LogInPasswordComponent,
|
||||
LogInContainerComponent,
|
||||
ItemVersionsComponent,
|
||||
PublicationSearchResultListElementComponent,
|
||||
ItemSearchResultListElementComponent,
|
||||
ItemVersionsNoticeComponent,
|
||||
ModifyItemOverviewComponent,
|
||||
ImpersonateNavbarComponent,
|
||||
@@ -426,10 +426,10 @@ const ENTRY_COMPONENTS = [
|
||||
CommunitySearchResultGridElementComponent,
|
||||
CollectionSearchResultGridElementComponent,
|
||||
SearchResultGridElementComponent,
|
||||
PublicationListElementComponent,
|
||||
PublicationGridElementComponent,
|
||||
PublicationSearchResultListElementComponent,
|
||||
PublicationSearchResultGridElementComponent,
|
||||
ItemListElementComponent,
|
||||
ItemGridElementComponent,
|
||||
ItemSearchResultListElementComponent,
|
||||
ItemSearchResultGridElementComponent,
|
||||
BrowseEntryListElementComponent,
|
||||
SearchResultDetailElementComponent,
|
||||
SearchResultGridElementComponent,
|
||||
|
@@ -760,6 +760,10 @@
|
||||
|
||||
|
||||
|
||||
"collection.listelement.badge": "Collection",
|
||||
|
||||
|
||||
|
||||
"collection.page.browse.recent.head": "Recent Submissions",
|
||||
|
||||
"collection.page.browse.recent.empty": "No items to show",
|
||||
@@ -863,6 +867,10 @@
|
||||
|
||||
|
||||
|
||||
"community.listelement.badge": "Community",
|
||||
|
||||
|
||||
|
||||
"comcol-role.edit.no-group": "None",
|
||||
|
||||
"comcol-role.edit.create": "Create",
|
||||
@@ -1676,6 +1684,28 @@
|
||||
|
||||
|
||||
|
||||
"item.listelement.badge": "Item",
|
||||
|
||||
"item.page.description": "Description",
|
||||
|
||||
"item.page.edit": "Edit this item",
|
||||
|
||||
"item.page.journal-issn": "Journal ISSN",
|
||||
|
||||
"item.page.journal-title": "Journal Title",
|
||||
|
||||
"item.page.publisher": "Publisher",
|
||||
|
||||
"item.page.titleprefix": "Item: ",
|
||||
|
||||
"item.page.volume-title": "Volume Title",
|
||||
|
||||
"item.search.results.head": "Item Search Results",
|
||||
|
||||
"item.search.title": "DSpace Angular :: Item Search",
|
||||
|
||||
|
||||
|
||||
"item.page.abstract": "Abstract",
|
||||
|
||||
"item.page.author": "Authors",
|
||||
|
Reference in New Issue
Block a user