mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
replaced type input by getRenderType method
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<div class="row" *ngIf="item">
|
||||
<div class="col-10 relationship">
|
||||
<ds-item-type-switcher [object]="item" [viewMode]="viewMode"></ds-item-type-switcher>
|
||||
<ds-listable-object-component-loader [object]="item" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="btn-group relationship-action-buttons">
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<div class="container" *ngVar="(itemRD$ | async) as itemRD">
|
||||
<div class="item-page" *ngIf="itemRD?.hasSucceeded" @fadeInOut>
|
||||
<div *ngIf="itemRD?.payload as item">
|
||||
<ds-item-type-switcher [object]="item" [viewMode]="viewMode"></ds-item-type-switcher>
|
||||
<ds-listable-object-component-loader [object]="item" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
||||
</div>
|
||||
</div>
|
||||
<ds-error *ngIf="itemRD?.hasFailed" message="{{'error.item' | translate}}"></ds-error>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<ds-metadata-field-wrapper *ngIf="representations && representations.length > 0" [label]="label">
|
||||
<ds-item-type-switcher *ngFor="let rep of representations"
|
||||
<ds-listable-object-component-loader *ngFor="let rep of representations"
|
||||
[object]="rep" [viewMode]="viewMode">
|
||||
</ds-item-type-switcher>
|
||||
</ds-listable-object-component-loader>
|
||||
</ds-metadata-field-wrapper>
|
||||
|
@@ -33,7 +33,7 @@ describe('MetadataRepresentationListComponent', () => {
|
||||
}));
|
||||
|
||||
it(`should load ${representations.length} item-type-switcher components`, () => {
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-item-type-switcher'));
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-listable-object-component-loader'));
|
||||
expect(fields.length).toBe(representations.length);
|
||||
});
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<ds-metadata-field-wrapper *ngIf="items && items.length > 0" [label]="label">
|
||||
<ds-item-type-switcher *ngFor="let item of items"
|
||||
<ds-listable-object-component-loader *ngFor="let item of items"
|
||||
[object]="item" [viewMode]="viewMode">
|
||||
</ds-item-type-switcher>
|
||||
</ds-listable-object-component-loader>
|
||||
</ds-metadata-field-wrapper>
|
||||
|
@@ -45,7 +45,7 @@ describe('RelatedItemsComponent', () => {
|
||||
}));
|
||||
|
||||
it(`should load ${mockItems.length} item-type-switcher components`, () => {
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-item-type-switcher'));
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-listable-object-component-loader'));
|
||||
expect(fields.length).toBe(mockItems.length);
|
||||
});
|
||||
|
||||
|
@@ -16,4 +16,7 @@ export class MyDSpaceResult<T extends DSpaceObject> implements ListableObject {
|
||||
*/
|
||||
hitHighlights: MetadataMap;
|
||||
|
||||
getRenderType(): string {
|
||||
return this.indexableObject.getRenderType() + 'MyDSpaceResult';
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,12 @@
|
||||
import { autoserialize, inheritSerialization } from 'cerialize';
|
||||
import { MetadataMap } from '../core/shared/metadata.models';
|
||||
import { ListableObject } from '../shared/object-collection/shared/listable-object.model';
|
||||
import { NormalizedObject } from '../core/cache/models/normalized-object.model';
|
||||
|
||||
/**
|
||||
* Represents a normalized version of a search result object of a certain DSpaceObject
|
||||
*/
|
||||
@inheritSerialization(NormalizedObject)
|
||||
export class NormalizedSearchResult implements ListableObject {
|
||||
export class NormalizedSearchResult {
|
||||
/**
|
||||
* The UUID of the DSpaceObject that was found
|
||||
*/
|
||||
@@ -19,5 +18,4 @@ export class NormalizedSearchResult implements ListableObject {
|
||||
*/
|
||||
@autoserialize
|
||||
hitHighlights: MetadataMap;
|
||||
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ import { SharedModule } from '../shared/shared.module';
|
||||
import { SearchPageRoutingModule } from './search-page-routing.module';
|
||||
import { SearchPageComponent } from './search-page.component';
|
||||
import { SearchResultsComponent } from './search-results/search-results.component';
|
||||
import { ItemSearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/item-search-result/item-search-result-grid-element.component';
|
||||
import { CommunitySearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component'
|
||||
import { CollectionSearchResultGridElementComponent } from '../shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component';
|
||||
import { SearchSidebarComponent } from './search-sidebar/search-sidebar.component';
|
||||
@@ -44,7 +43,6 @@ const components = [
|
||||
SearchResultsComponent,
|
||||
SearchSidebarComponent,
|
||||
SearchSettingsComponent,
|
||||
ItemSearchResultGridElementComponent,
|
||||
CollectionSearchResultGridElementComponent,
|
||||
CommunitySearchResultGridElementComponent,
|
||||
SearchFiltersComponent,
|
||||
@@ -85,7 +83,6 @@ const components = [
|
||||
SearchConfigurationService
|
||||
],
|
||||
entryComponents: [
|
||||
ItemSearchResultGridElementComponent,
|
||||
CollectionSearchResultGridElementComponent,
|
||||
CommunitySearchResultGridElementComponent,
|
||||
SearchFacetFilterComponent,
|
||||
|
@@ -16,4 +16,7 @@ export class SearchResult<T extends DSpaceObject> implements ListableObject {
|
||||
*/
|
||||
hitHighlights: MetadataMap;
|
||||
|
||||
getRenderType(): string {
|
||||
return this.indexableObject.getRenderType() + 'SearchResult';
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ import { Group } from './group.model';
|
||||
|
||||
@mapsTo(EPerson)
|
||||
@inheritSerialization(NormalizedDSpaceObject)
|
||||
export class NormalizedEPerson extends NormalizedDSpaceObject<EPerson> implements CacheableObject, ListableObject {
|
||||
export class NormalizedEPerson extends NormalizedDSpaceObject<EPerson> implements CacheableObject {
|
||||
/**
|
||||
* A string representing the unique handle of this EPerson
|
||||
*/
|
||||
|
@@ -8,7 +8,7 @@ import { Group } from './group.model';
|
||||
|
||||
@mapsTo(Group)
|
||||
@inheritSerialization(NormalizedDSpaceObject)
|
||||
export class NormalizedGroup extends NormalizedDSpaceObject<Group> implements CacheableObject, ListableObject {
|
||||
export class NormalizedGroup extends NormalizedDSpaceObject<Group> implements CacheableObject {
|
||||
|
||||
/**
|
||||
* List of Groups that this Group belong to
|
||||
|
@@ -50,4 +50,8 @@ export class MetadataField implements ListableObject {
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
getRenderType(): string {
|
||||
return this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
@@ -26,4 +26,8 @@ export class MetadataSchema implements ListableObject {
|
||||
* The namespace of this metadata schema
|
||||
*/
|
||||
namespace: string;
|
||||
|
||||
getRenderType(): string {
|
||||
return this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ import { MetadataSchema } from './metadata-schema.model';
|
||||
*/
|
||||
@mapsTo(MetadataField)
|
||||
@inheritSerialization(NormalizedObject)
|
||||
export class NormalizedMetadataField extends NormalizedObject<MetadataField> implements ListableObject {
|
||||
export class NormalizedMetadataField extends NormalizedObject<MetadataField> {
|
||||
|
||||
/**
|
||||
* The identifier of this normalized metadata field
|
||||
|
@@ -9,7 +9,7 @@ import { MetadataSchema } from './metadata-schema.model';
|
||||
*/
|
||||
@mapsTo(MetadataSchema)
|
||||
@inheritSerialization(NormalizedObject)
|
||||
export class NormalizedMetadataSchema extends NormalizedObject<MetadataSchema> implements ListableObject {
|
||||
export class NormalizedMetadataSchema extends NormalizedObject<MetadataSchema> {
|
||||
/**
|
||||
* The unique identifier for this schema
|
||||
*/
|
||||
|
@@ -400,7 +400,7 @@ export class RegistryService {
|
||||
distinctUntilChanged()
|
||||
);
|
||||
|
||||
const serializedSchema = new DSpaceRESTv2Serializer(getMapsToType(MetadataSchema.type)).serialize(schema as NormalizedMetadataSchema);
|
||||
const serializedSchema = new DSpaceRESTv2Serializer(getMapsToType(MetadataSchema.type)).serialize(schema);
|
||||
|
||||
const request$ = endpoint$.pipe(
|
||||
take(1),
|
||||
|
@@ -6,7 +6,7 @@ import { ResourceType } from './resource-type';
|
||||
* Class object representing a browse entry
|
||||
* This class is not normalized because browse entries do not have self links
|
||||
*/
|
||||
export class BrowseEntry implements ListableObject, TypedObject {
|
||||
export class BrowseEntry implements ListableObject {
|
||||
static type = new ResourceType('browseEntry');
|
||||
|
||||
/**
|
||||
@@ -28,4 +28,8 @@ export class BrowseEntry implements ListableObject, TypedObject {
|
||||
* The count of this browse entry
|
||||
*/
|
||||
count: number;
|
||||
|
||||
getRenderType(): string {
|
||||
return (this as any).type.value;
|
||||
}
|
||||
}
|
||||
|
@@ -146,4 +146,7 @@ export class DSpaceObject implements CacheableObject, ListableObject {
|
||||
});
|
||||
}
|
||||
|
||||
getRenderType(): string {
|
||||
return this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
@@ -110,4 +110,11 @@ export class Item extends DSpaceObject {
|
||||
}));
|
||||
}
|
||||
|
||||
getRenderType(): string {
|
||||
const entityType = this.firstMetadataValue('relationship.type');
|
||||
if (isNotEmpty(entityType)) {
|
||||
return entityType;
|
||||
}
|
||||
return 'Publication';
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||
import { JournalIssueSearchResultGridElementComponent } from './journal-issue-grid-element.component';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/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';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||
import { JournalVolumeSearchResultGridElementComponent } from './journal-volume-grid-element.component';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/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';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||
import { JournalSearchResultGridElementComponent } from './journal-grid-element.component';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/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';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -5,7 +5,6 @@ import { JournalIssueListElementComponent } from './journal-issue-list-element.c
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
|
||||
let journalIssueListElementComponent: JournalIssueListElementComponent;
|
||||
@@ -51,7 +50,6 @@ describe('JournalIssueListElementComponent', () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalIssueListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
|
@@ -5,7 +5,6 @@ import { JournalVolumeListElementComponent } from './journal-volume-list-element
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
|
||||
let journalVolumeListElementComponent: JournalVolumeListElementComponent;
|
||||
@@ -51,7 +50,6 @@ describe('JournalVolumeListElementComponent', () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalVolumeListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<ng-container *ngVar="object.indexableObject as item">
|
||||
<ds-item-type-badge [object]="item"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="item.id">
|
||||
<a
|
||||
[routerLink]="['/items/' + item.id]" class="lead"
|
||||
|
@@ -1,17 +1,20 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { JournalIssueSearchResultListElementComponent } from './journal-issue-list-element.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { JournalIssueSearchResultListElementComponent } from './journal-issue-search-result-list-element.component';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
|
||||
let journalIssueListElementComponent: JournalIssueSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<JournalIssueSearchResultListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -33,8 +36,13 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
})
|
||||
});
|
||||
|
||||
const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -44,18 +52,18 @@ const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('JournalIssueListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalIssueSearchResultListElementComponent , TruncatePipe],
|
||||
declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(JournalIssueSearchResultListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<ng-container *ngVar="object.indexableObject as item">
|
||||
<ds-item-type-badge [object]="item"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="item.id">
|
||||
<a
|
||||
[routerLink]="['/items/' + item.id]" class="lead"
|
||||
|
@@ -1,17 +1,20 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { JournalVolumeSearchResultListElementComponent } from './journal-volume-list-element.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { JournalVolumeSearchResultListElementComponent } from './journal-volume-search-result-list-element.component';
|
||||
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
|
||||
let journalVolumeListElementComponent: JournalVolumeSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<JournalVolumeSearchResultListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -33,8 +36,12 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
})
|
||||
});
|
||||
const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -44,18 +51,18 @@ const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('JournalVolumeListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalVolumeSearchResultListElementComponent , TruncatePipe],
|
||||
declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(JournalVolumeSearchResultListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<ng-container *ngVar="object.indexableObject as item">
|
||||
<ds-item-type-badge [object]="item"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="item.id">
|
||||
<a
|
||||
[routerLink]="['/items/' + item.id]" class="lead"
|
||||
|
@@ -1,17 +1,20 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { JournalSearchResultListElementComponent } from './journal-list-element.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { JournalSearchResultListElementComponent } from './journal-search-result-list-element.component';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
|
||||
let journalListElementComponent: JournalSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<JournalSearchResultListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -27,8 +30,13 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
})
|
||||
});
|
||||
|
||||
const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -38,18 +46,19 @@ const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
describe('JournalListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalSearchResultListElementComponent , TruncatePipe],
|
||||
declarations: [JournalSearchResultListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(JournalSearchResultListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||
import { OrgunitSearchResultGridElementComponent } from './orgunit-grid-element.component';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils';
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { OrgunitSearchResultGridElementComponent } from './orgunit-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';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||
import { PersonSearchResultGridElementComponent } from './person-grid-element.component';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/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';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||
import { ProjectSearchResultGridElementComponent } from './project-grid-element.component';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/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 { ProjectSearchResultGridElementComponent } from './project-search-result-grid-element.component';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<ng-container *ngVar="object.indexableObject as item">
|
||||
<ds-item-type-badge [object]="item"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="item.id">
|
||||
<a
|
||||
[routerLink]="['/items/' + item.id]" class="lead"
|
||||
|
@@ -1 +0,0 @@
|
||||
@import '../../../../../styles/variables';
|
||||
|
@@ -1,17 +1,20 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { OrgunitSearchResultListElementComponent } from './orgunit-list-element.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { OrgunitSearchResultListElementComponent } from './orgunit-search-result-list-element.component';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
|
||||
let orgUnitListElementComponent: OrgunitSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<OrgunitSearchResultListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -27,8 +30,12 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
})
|
||||
});
|
||||
const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -38,14 +45,14 @@ const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('OrgUnitListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ OrgunitSearchResultListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<ng-container *ngVar="object.indexableObject as item">
|
||||
<ds-item-type-badge [object]="item"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="item.id">
|
||||
<a
|
||||
[routerLink]="['/items/' + item.id]" class="lead"
|
||||
|
@@ -1 +0,0 @@
|
||||
@import '../../../../../styles/variables';
|
||||
|
@@ -1,16 +1,20 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { PersonSearchResultListElementComponent } from './person-list-element.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { PersonSearchResultListElementComponent } from './person-search-result-list-element.component';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
|
||||
let personListElementComponent: PersonSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<PersonSearchResultListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -26,8 +30,12 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
})
|
||||
});
|
||||
const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -37,17 +45,18 @@ const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('PersonListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PersonSearchResultListElementComponent , TruncatePipe],
|
||||
declarations: [PersonSearchResultListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(PersonSearchResultListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
|
@@ -1,6 +1,8 @@
|
||||
<ds-truncatable [id]="object.id">
|
||||
<ng-container *ngVar="object.indexableObject as item">
|
||||
<ds-truncatable [id]="item.id">
|
||||
<ds-item-type-badge [object]="item"></ds-item-type-badge>
|
||||
<a
|
||||
[routerLink]="['/items/' + object.id]" class="lead"
|
||||
[routerLink]="['/items/' + item.id]" class="lead"
|
||||
[innerHTML]="firstMetadataValue('dc.title')"></a>
|
||||
<!--<span class="text-muted">-->
|
||||
<!--<ds-truncatable-part [id]="item.id" [minLines]="1">-->
|
||||
@@ -12,5 +14,5 @@
|
||||
<!--</span>-->
|
||||
<!--</ds-truncatable-part>-->
|
||||
<!--</span>-->
|
||||
</ds-truncatable>
|
||||
|
||||
</ds-truncatable>
|
||||
</ng-container>
|
@@ -1 +0,0 @@
|
||||
@import '../../../../../styles/variables';
|
||||
|
@@ -1,17 +1,19 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ProjectSearchResultListElementComponent } from './project-list-element.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { ProjectSearchResultListElementComponent } from './project-search-result-list-element.component';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
|
||||
let projectListElementComponent: ProjectSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<ProjectSearchResultListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -27,8 +29,13 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
// }
|
||||
// ]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
})
|
||||
});
|
||||
|
||||
const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
new ItemSearchResult(),
|
||||
{
|
||||
indexableObject: Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -38,18 +45,18 @@ const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('ProjectListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ProjectSearchResultListElementComponent , TruncatePipe],
|
||||
declarations: [ProjectSearchResultListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ProjectSearchResultListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
|
@@ -25,7 +25,7 @@
|
||||
</div>
|
||||
<ul class="list-unstyled">
|
||||
<li *ngFor="let object of objects?.payload?.page" class="mt-4 mb-4">
|
||||
<ds-wrapper-list-element [object]="object"></ds-wrapper-list-element>
|
||||
<ds-listable-object-component-loader [object]="object"></ds-listable-object-component-loader>
|
||||
</li>
|
||||
</ul>
|
||||
<div>
|
||||
|
@@ -15,6 +15,6 @@
|
||||
class="list-group-item list-group-item-action border-0 list-entry"
|
||||
title="{{ listEntry.indexableObject.name }}"
|
||||
(click)="onSelect.emit(listEntry.indexableObject)" #listEntryElement>
|
||||
<ds-wrapper-list-element [object]="listEntry"></ds-wrapper-list-element>
|
||||
<ds-listable-object-component-loader [object]="listEntry" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
||||
</button>
|
||||
</div>
|
||||
|
@@ -19,6 +19,7 @@ import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { SearchResult } from '../../../+search-page/search-result.model';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-dso-selector',
|
||||
@@ -31,7 +32,7 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
* The user can search the list by using the input field
|
||||
*/
|
||||
export class DSOSelectorComponent implements OnInit {
|
||||
|
||||
viewMode = ViewMode.ListElement;
|
||||
/**
|
||||
* The initially selected DSO's uuid
|
||||
*/
|
||||
|
@@ -16,7 +16,7 @@
|
||||
<button class="d-block dropdown-item" (click)="onClickSuggestion(suggestionOption)" #suggestion>
|
||||
<div class="click-blocker">
|
||||
</div>
|
||||
<ds-wrapper-list-element [object]="suggestionOption"></ds-wrapper-list-element>
|
||||
<ds-listable-object-component-loader [object]="suggestionOption" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -2,6 +2,7 @@ import { Component, forwardRef, Input } from '@angular/core';
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { InputSuggestionsComponent } from '../input-suggestions.component';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-dso-input-suggestions',
|
||||
@@ -22,6 +23,7 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
* Component representing a form with a autocomplete functionality for DSpaceObjects
|
||||
*/
|
||||
export class DsoInputSuggestionsComponent extends InputSuggestionsComponent {
|
||||
viewMode = ViewMode.ListElement;
|
||||
/**
|
||||
* The suggestions that should be shown
|
||||
*/
|
||||
|
@@ -8,4 +8,7 @@ import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspa
|
||||
*/
|
||||
@searchResultFor(Item, MyDSpaceConfigurationValueType.Workspace)
|
||||
export class ItemMyDSpaceResult extends SearchResult<Item> {
|
||||
getRenderType(): string {
|
||||
return ItemMyDSpaceResult.name;
|
||||
}
|
||||
}
|
||||
|
@@ -1 +1,5 @@
|
||||
export interface ListableObject {}
|
||||
import { TypedObject } from '../../../core/cache/object-cache.reducer';
|
||||
|
||||
export interface ListableObject extends TypedObject {
|
||||
getRenderType(): string;
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
<ng-container listableObjectComponentLoader></ng-container>
|
||||
<ng-template dsListableObject></ng-template>
|
@@ -5,24 +5,23 @@ import { Context } from '../../../../core/shared/context.model';
|
||||
import { getListableObjectComponent } from './listable-object.decorator';
|
||||
import { GenericConstructor } from '../../../../core/shared/generic-constructor';
|
||||
import { ListableObjectDirective } from './listable-object.directive';
|
||||
import { hasValue, isNotEmpty } from '../../../empty.util';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-listable-object-component-loader',
|
||||
styleUrls: ['./listable-object-component-loader.component.scss'],
|
||||
// styleUrls: ['./listable-object-component-loader.component.scss'],
|
||||
templateUrl: './listable-object-component-loader.component.html'
|
||||
})
|
||||
/**
|
||||
* Component for determining what component to use depending on the item's relationship type (relationship.type)
|
||||
*/
|
||||
export class ListableObjectComponentLoaderComponent implements OnInit {
|
||||
|
||||
@Input() type?: string;
|
||||
/**
|
||||
* The item or metadata to determine the component for
|
||||
*/
|
||||
@Input() object: ListableObject;
|
||||
|
||||
//TODO DO SOMETHING WITH THIS
|
||||
@Input() index: number;
|
||||
/**
|
||||
* The preferred view-mode to display
|
||||
*/
|
||||
@@ -49,9 +48,6 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
|
||||
* @returns {string}
|
||||
*/
|
||||
private getComponent(): GenericConstructor<Component> {
|
||||
if (isNotEmpty(this.type)) {
|
||||
return getListableObjectComponent(this.type, this.viewMode)
|
||||
}
|
||||
return getListableObjectComponent(this.object.constructor as GenericConstructor<ListableObject>, this.viewMode);
|
||||
return getListableObjectComponent(this.object.getRenderType(), this.viewMode)
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ const listElementMap = new Map();
|
||||
* @param type
|
||||
* @param viewMode
|
||||
*/
|
||||
export function listableObjectComponent(objectType: GenericConstructor<ListableObject> | string, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) {
|
||||
export function listableObjectComponent(objectType: string, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT) {
|
||||
return function decorator(component: any) {
|
||||
if (hasNoValue(objectType)) {
|
||||
return;
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { Component, Inject, Input } from '@angular/core';
|
||||
import { ListableObject } from '../listable-object.model';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-abstract-object-element',
|
||||
template: ``,
|
||||
})
|
||||
export class AbstractListableElementComponent <T extends ListableObject> {
|
||||
export class AbstractListableElementComponent<T extends ListableObject> {
|
||||
@Input() object: T;
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/cla
|
||||
import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { Context } from '../../../../core/shared/context.model';
|
||||
|
||||
/**
|
||||
* This component renders claimed task object for the mydspace result in the detail view.
|
||||
@@ -23,8 +24,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: './claimed-my-dspace-result-detail-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(ClaimedTaskMyDSpaceResult, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(ClaimedTask, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(ClaimedTaskMyDSpaceResult.name, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(ClaimedTask.name, ViewMode.DetailedListElement)
|
||||
export class ClaimedMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent<ClaimedTaskMyDSpaceResult, ClaimedTask> {
|
||||
|
||||
/**
|
||||
|
@@ -16,7 +16,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: './item-my-dspace-result-detail-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(ItemMyDSpaceResult, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(ItemMyDSpaceResult.name, ViewMode.DetailedListElement)
|
||||
export class ItemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent<ItemMyDSpaceResult, Item> {
|
||||
|
||||
/**
|
||||
|
@@ -22,8 +22,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: './pool-my-dspace-result-detail-element.component.html',
|
||||
})
|
||||
|
||||
@listableObjectComponent(PoolTaskMyDSpaceResult, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(PoolTask, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(PoolTaskMyDSpaceResult.name, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(PoolTask.name, ViewMode.DetailedListElement)
|
||||
export class PoolMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent<PoolTaskMyDSpaceResult, PoolTask> {
|
||||
|
||||
/**
|
||||
|
@@ -22,8 +22,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: './workflowitem-my-dspace-result-detail-element.component.html',
|
||||
})
|
||||
|
||||
@listableObjectComponent(WorkflowitemMyDSpaceResult, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(WorkflowItem, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(WorkflowitemMyDSpaceResult.name, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(WorkflowItem.name, ViewMode.DetailedListElement)
|
||||
export class WorkflowitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent<WorkflowitemMyDSpaceResult, WorkflowItem> {
|
||||
|
||||
/**
|
||||
|
@@ -10,7 +10,6 @@ import { WorkspaceitemMyDSpaceResult } from '../../../object-collection/shared/w
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { isNotUndefined } from '../../../empty.util';
|
||||
import { ListableObject } from '../../../object-collection/shared/listable-object.model';
|
||||
import { MyDSpaceResultDetailElementComponent } from '../my-dspace-result-detail-element.component';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
@@ -25,8 +24,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: './workspaceitem-my-dspace-result-detail-element.component.html',
|
||||
})
|
||||
|
||||
@listableObjectComponent(WorkspaceitemMyDSpaceResult, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(WorkspaceItem, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(WorkspaceitemMyDSpaceResult.name, ViewMode.DetailedListElement)
|
||||
@listableObjectComponent(WorkspaceItem.name, ViewMode.DetailedListElement)
|
||||
export class WorkspaceitemMyDSpaceResultDetailElementComponent extends MyDSpaceResultDetailElementComponent<WorkspaceitemMyDSpaceResult, WorkspaceItem> {
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
<div class="row mt-2" *ngIf="objects?.hasSucceeded" @fadeIn>
|
||||
<div class="col"
|
||||
*ngFor="let object of objects?.payload?.page">
|
||||
<ds-wrapper-detail-element [object]="object"></ds-wrapper-detail-element>
|
||||
<ds-listable-object-component-loader [object]="object" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
||||
</div>
|
||||
</div>
|
||||
<ds-error *ngIf="objects.hasFailed | async" message="{{'error.objects' | translate}}"></ds-error>
|
||||
|
@@ -15,6 +15,7 @@ import { fadeIn } from '../animations/fade';
|
||||
import { ListableObject } from '../object-collection/shared/listable-object.model';
|
||||
|
||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
|
||||
/**
|
||||
* This component renders a paginated set of results in the detail view.
|
||||
@@ -28,6 +29,7 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o
|
||||
animations: [fadeIn]
|
||||
})
|
||||
export class ObjectDetailComponent {
|
||||
viewMode = ViewMode.DetailedListElement;
|
||||
|
||||
/**
|
||||
* Pagination options object
|
||||
|
@@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
|
||||
templateUrl: './collection-grid-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(Collection, ViewMode.GridElement)
|
||||
@listableObjectComponent(Collection.name, ViewMode.GridElement)
|
||||
export class CollectionGridElementComponent extends AbstractListableElementComponent<Collection> {}
|
||||
|
@@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
|
||||
templateUrl: './community-grid-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(Community, ViewMode.GridElement)
|
||||
@listableObjectComponent(Community.name, ViewMode.GridElement)
|
||||
export class CommunityGridElementComponent extends AbstractListableElementComponent<Community> {}
|
||||
|
@@ -1 +0,0 @@
|
||||
<ds-listable-object-component-loader [type]="object.firstMetadataValue('relationship.type')" [object]="object" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
@@ -1 +0,0 @@
|
||||
|
@@ -1,114 +0,0 @@
|
||||
import { ItemGridElementComponent } from './item-grid-element.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TruncatePipe } from '../../utils/truncate.pipe';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
||||
let itemGridElementComponent: ItemGridElementComponent;
|
||||
let fixture: ComponentFixture<ItemGridElementComponent>;
|
||||
|
||||
const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.contributor.author': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'Smith, Donald'
|
||||
}
|
||||
],
|
||||
'dc.date.issued': [
|
||||
{
|
||||
language: null,
|
||||
value: '2015-06-26'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'dc.type': [
|
||||
{
|
||||
language: null,
|
||||
value: 'Article'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('ItemGridElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ItemGridElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: 'objectElementProvider', useValue: {mockItemWithAuthorAndDate}}
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).overrideComponent(ItemGridElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemGridElementComponent);
|
||||
itemGridElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
describe('When the item has an author', () => {
|
||||
beforeEach(() => {
|
||||
itemGridElementComponent.object = mockItemWithAuthorAndDate;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors'));
|
||||
expect(itemAuthorField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no author', () => {
|
||||
beforeEach(() => {
|
||||
itemGridElementComponent.object = mockItemWithoutAuthorAndDate;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors'));
|
||||
expect(itemAuthorField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has an issuedate', () => {
|
||||
beforeEach(() => {
|
||||
itemGridElementComponent.object = mockItemWithAuthorAndDate;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the issuedate span', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-date'));
|
||||
expect(itemAuthorField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no issuedate', () => {
|
||||
beforeEach(() => {
|
||||
itemGridElementComponent.object = mockItemWithoutAuthorAndDate;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the issuedate span', () => {
|
||||
const dateField = fixture.debugElement.query(By.css('span.item-date'));
|
||||
expect(dateField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
@@ -1,15 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component';
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-grid-element',
|
||||
styleUrls: ['./item-grid-element.component.scss'],
|
||||
templateUrl: './item-grid-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(Item, ViewMode.GridElement)
|
||||
export class ItemGridElementComponent extends AbstractListableElementComponent<Item> {}
|
@@ -13,7 +13,7 @@
|
||||
<div class="card-columns row" *ngIf="objects?.hasSucceeded">
|
||||
<div class="card-column col col-sm-6 col-lg-4" *ngFor="let column of (columns$ | async)" @fadeIn>
|
||||
<div class="card-element" *ngFor="let object of column">
|
||||
<ds-wrapper-grid-element [object]="object"></ds-wrapper-grid-element>
|
||||
<ds-listable-object-component-loader [object]="object" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -20,6 +20,7 @@ import { HostWindowService, WidthCategory } from '../host-window.service';
|
||||
import { ListableObject } from '../object-collection/shared/listable-object.model';
|
||||
|
||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
|
||||
@Component({
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
@@ -31,6 +32,7 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o
|
||||
})
|
||||
|
||||
export class ObjectGridComponent implements OnInit {
|
||||
viewMode = ViewMode.ListElement;
|
||||
|
||||
@Input() config: PaginationComponentOptions;
|
||||
@Input() sortConfig: SortOptions;
|
||||
|
@@ -12,5 +12,5 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: 'collection-search-result-grid-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(CollectionSearchResult, ViewMode.GridElement)
|
||||
@listableObjectComponent(CollectionSearchResult.name, ViewMode.GridElement)
|
||||
export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent<CollectionSearchResult, Collection> {}
|
||||
|
@@ -11,7 +11,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: 'community-search-result-grid-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement)
|
||||
@listableObjectComponent(CommunitySearchResult.name, ViewMode.GridElement)
|
||||
export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent<CommunitySearchResult, Community> {
|
||||
|
||||
}
|
||||
|
@@ -1 +0,0 @@
|
||||
<ds-listable-object-component-loader [type]="object.indexableObject.firstMetadataValue('relationship.type') + 'SearchResult'" [object]="object" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
@@ -1,12 +0,0 @@
|
||||
.card {
|
||||
a > div {
|
||||
position: relative;
|
||||
.thumbnail-overlay {
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
background-color: map-get($theme-colors, primary);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
|
||||
let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
|
||||
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
const type = 'authorOfPublication';
|
||||
|
||||
const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithRelationshipType.hitHighlights = {};
|
||||
mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'relationship.type': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: type
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('ItemSearchResultGridElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [ItemSearchResultGridElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
{ provide: 'objectElementProvider', useValue: (mockItemWithRelationshipType) }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ItemSearchResultGridElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemSearchResultGridElementComponent);
|
||||
itemSearchResultGridElementComponent = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
it('should show send the object to item-type-switcher using viewMode "Card"', () => {
|
||||
const itemTypeSwitcherComp = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance;
|
||||
expect(itemTypeSwitcherComp.object).toBe(mockItemWithRelationshipType);
|
||||
expect(itemTypeSwitcherComp.viewMode).toEqual(ViewMode.GridElement);
|
||||
});
|
||||
});
|
@@ -1,20 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { SearchResultGridElementComponent } from '../search-result-grid-element.component';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||
import { focusShadow } from '../../../animations/focus';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-search-result-grid-element',
|
||||
styleUrls: ['../search-result-grid-element.component.scss', 'item-search-result-grid-element.component.scss'],
|
||||
templateUrl: 'item-search-result-grid-element.component.html',
|
||||
animations: [focusShadow],
|
||||
})
|
||||
|
||||
@listableObjectComponent(ItemSearchResult, ViewMode.GridElement)
|
||||
export class ItemSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
|
||||
viewMode = ViewMode.GridElement;
|
||||
}
|
@@ -4,14 +4,13 @@ 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 { PublicationSearchResultGridElementComponent } from './publication-grid-element.component';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { ITEM } from '../../../../items/switcher/listable-object-component-loader.component';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils';
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { PublicationSearchResultGridElementComponent } from './publication-search-result-grid-element.component';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
@@ -85,7 +84,6 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet
|
||||
declarations: [component, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
{provide: ITEM, useValue: searchResultWithoutMetadata}
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(component, {
|
||||
|
@@ -14,5 +14,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
|
||||
/**
|
||||
* This component is automatically used to create a list view for BrowseEntry objects when used in ObjectCollectionComponent
|
||||
*/
|
||||
@listableObjectComponent(BrowseEntry, ViewMode.ListElement)
|
||||
@listableObjectComponent(BrowseEntry.name, ViewMode.ListElement)
|
||||
export class BrowseEntryListElementComponent extends AbstractListableElementComponent<BrowseEntry> {}
|
||||
|
@@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
|
||||
templateUrl: './collection-list-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(Collection, ViewMode.ListElement)
|
||||
@listableObjectComponent(Collection.name, ViewMode.ListElement)
|
||||
export class CollectionListElementComponent extends AbstractListableElementComponent<Collection> {}
|
||||
|
@@ -11,5 +11,5 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
|
||||
templateUrl: './community-list-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(Community, ViewMode.ListElement)
|
||||
@listableObjectComponent(Community.name, ViewMode.ListElement)
|
||||
export class CommunityListElementComponent extends AbstractListableElementComponent<Community> {}
|
||||
|
@@ -1 +0,0 @@
|
||||
<ds-listable-object-component-loader [type]="object.firstMetadataValue('relationship.type')" [object]="object" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
@@ -1,47 +0,0 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ItemListElementComponent } from './item-list-element.component';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../core/shared/page-info.model';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { createRelationshipsObservable } from '../../../+item-page/simple/item-types/shared/item.component.spec';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../testing/utils';
|
||||
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: [],
|
||||
relationships: createRelationshipsObservable()
|
||||
});
|
||||
|
||||
describe('ItemListElementComponent', () => {
|
||||
let comp: ItemListElementComponent;
|
||||
let fixture: ComponentFixture<ItemListElementComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
declarations: [ItemListElementComponent],
|
||||
providers: [
|
||||
{ provide: 'objectElementProvider', useValue: mockItem }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ItemListElementComponent, {
|
||||
set: {changeDetection: ChangeDetectionStrategy.Default}
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemListElementComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should call an item-type-switcher component and pass the item', () => {
|
||||
const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance;
|
||||
expect(itemTypeSwitcher.object).toBe(mockItem);
|
||||
});
|
||||
|
||||
});
|
@@ -1,21 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component';
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-list-element',
|
||||
styleUrls: ['./item-list-element.component.scss'],
|
||||
templateUrl: './item-list-element.component.html'
|
||||
})
|
||||
|
||||
/**
|
||||
* The component used to list items depending on type
|
||||
* Uses item-type-switcher to determine which components to use for displaying the list
|
||||
*/
|
||||
@listableObjectComponent(Item, ViewMode.ListElement)
|
||||
export class ItemListElementComponent extends AbstractListableElementComponent<Item> {
|
||||
viewMode = ViewMode.ListElement;
|
||||
}
|
@@ -8,5 +8,5 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
templateUrl: './item-type-badge.component.html'
|
||||
})
|
||||
export class ItemTypeBadgeComponent {
|
||||
@Input() object: SearchResult<DSpaceObject>;
|
||||
@Input() object: DSpaceObject;
|
||||
}
|
||||
|
@@ -1,2 +1,2 @@
|
||||
<ds-item-type-switcher [object]="metadataRepresentation" [viewMode]="viewMode">
|
||||
</ds-item-type-switcher>
|
||||
<ds-listable-object-component-loader [object]="metadataRepresentation" [viewMode]="viewMode">
|
||||
</ds-listable-object-component-loader>
|
||||
|
@@ -31,7 +31,7 @@ describe('ItemMetadataListElementComponent', () => {
|
||||
}));
|
||||
|
||||
it('should call an item-type-switcher component and pass the item-metadata-representation', () => {
|
||||
const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-item-type-switcher')).nativeElement;
|
||||
const itemTypeSwitcher = fixture.debugElement.query(By.css('ds-listable-object-component-loader')).nativeElement;
|
||||
expect(itemTypeSwitcher.object).toBe(mockItemMetadataRepresentation);
|
||||
});
|
||||
|
||||
|
@@ -24,8 +24,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }]
|
||||
})
|
||||
|
||||
@listableObjectComponent(ClaimedTaskMyDSpaceResult, ViewMode.ListElement)
|
||||
@listableObjectComponent(ClaimedTask, ViewMode.ListElement)
|
||||
@listableObjectComponent(ClaimedTaskMyDSpaceResult.name, ViewMode.ListElement)
|
||||
@listableObjectComponent(ClaimedTask.name, ViewMode.ListElement)
|
||||
export class ClaimedMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent<ClaimedTaskMyDSpaceResult, ClaimedTask> {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import { ItemMyDSpaceResult } from '../../../object-collection/shared/item-my-ds
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { Context } from '../../../../core/shared/context.model';
|
||||
|
||||
/**
|
||||
* This component renders item object for the mydspace result in the list view.
|
||||
@@ -16,7 +17,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: './item-my-dspace-result-list-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(ItemMyDSpaceResult, ViewMode.ListElement)
|
||||
@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement, Context.Submission)
|
||||
export class ItemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent<ItemMyDSpaceResult, Item> {
|
||||
|
||||
/**
|
||||
|
@@ -13,6 +13,7 @@ import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model';
|
||||
import { PoolTaskMyDSpaceResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { ClaimedTaskMyDSpaceResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model';
|
||||
|
||||
/**
|
||||
* This component renders pool task object for the mydspace result in the list view.
|
||||
@@ -23,8 +24,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: './pool-my-dspace-result-list-element.component.html',
|
||||
})
|
||||
|
||||
@listableObjectComponent(PoolTaskMyDSpaceResult, ViewMode.ListElement)
|
||||
@listableObjectComponent(PoolTask, ViewMode.ListElement)
|
||||
@listableObjectComponent(PoolTaskMyDSpaceResult.name, ViewMode.ListElement)
|
||||
@listableObjectComponent(PoolTask.name, ViewMode.ListElement)
|
||||
export class PoolMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent<PoolTaskMyDSpaceResult, PoolTask> implements OnInit {
|
||||
|
||||
/**
|
||||
|
@@ -22,8 +22,8 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: './workflowitem-my-dspace-result-list-element.component.html',
|
||||
})
|
||||
|
||||
@listableObjectComponent(WorkflowitemMyDSpaceResult, ViewMode.ListElement)
|
||||
@listableObjectComponent(WorkflowItem, ViewMode.ListElement)
|
||||
@listableObjectComponent(WorkflowitemMyDSpaceResult.name, ViewMode.ListElement)
|
||||
@listableObjectComponent(WorkflowItem.name, ViewMode.ListElement)
|
||||
export class WorkflowitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent<WorkflowitemMyDSpaceResult, WorkflowItem> {
|
||||
|
||||
/**
|
||||
|
@@ -22,7 +22,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: './workspaceitem-my-dspace-result-list-element.component.html',
|
||||
})
|
||||
|
||||
@listableObjectComponent(WorkspaceitemMyDSpaceResult, ViewMode.ListElement)
|
||||
@listableObjectComponent(WorkspaceitemMyDSpaceResult.name, ViewMode.ListElement)
|
||||
export class WorkspaceitemMyDSpaceResultListElementComponent extends MyDSpaceResultListElementComponent<WorkspaceitemMyDSpaceResult, WorkspaceItem> {
|
||||
|
||||
/**
|
||||
|
@@ -12,7 +12,7 @@
|
||||
(paginationChange)="onPaginationChange($event)">
|
||||
<ul *ngIf="objects?.hasSucceeded" class="list-unstyled">
|
||||
<li *ngFor="let object of objects?.payload?.page; let i = index; let last = last" class="mt-4 mb-4" [class.border-bottom]="hasBorder && !last">
|
||||
<ds-wrapper-list-element [object]="object" [index]="i"></ds-wrapper-list-element>
|
||||
<ds-listable-object-component-loader [object]="object" [viewMode]="viewMode" [index]="i"></ds-listable-object-component-loader>
|
||||
</li>
|
||||
</ul>
|
||||
</ds-pagination>
|
||||
|
@@ -12,6 +12,7 @@ import { RemoteData } from '../../core/data/remote-data';
|
||||
import { fadeIn } from '../animations/fade';
|
||||
import { ListableObject } from '../object-collection/shared/listable-object.model';
|
||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
|
||||
@Component({
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
@@ -22,7 +23,7 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o
|
||||
animations: [fadeIn]
|
||||
})
|
||||
export class ObjectListComponent {
|
||||
|
||||
viewMode = ViewMode.ListElement;
|
||||
@Input() config: PaginationComponentOptions;
|
||||
@Input() sortConfig: SortOptions;
|
||||
@Input() hasBorder = false;
|
||||
|
@@ -6,6 +6,7 @@ import { Collection } from '../../../../core/shared/collection.model';
|
||||
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { BrowseEntry } from '../../../../core/shared/browse-entry.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-collection-search-result-list-element',
|
||||
@@ -13,5 +14,5 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: 'collection-search-result-list-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(CollectionSearchResult, ViewMode.ListElement)
|
||||
@listableObjectComponent(CollectionSearchResult.name, ViewMode.ListElement)
|
||||
export class CollectionSearchResultListElementComponent extends SearchResultListElementComponent<CollectionSearchResult, Collection> {}
|
||||
|
@@ -6,6 +6,7 @@ import { Community } from '../../../../core/shared/community.model';
|
||||
import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { BrowseEntry } from '../../../../core/shared/browse-entry.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-community-search-result-list-element',
|
||||
@@ -13,7 +14,7 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
templateUrl: 'community-search-result-list-element.component.html'
|
||||
})
|
||||
|
||||
@listableObjectComponent(CommunitySearchResult, ViewMode.ListElement)
|
||||
@listableObjectComponent(CommunitySearchResult.name, ViewMode.ListElement)
|
||||
export class CommunitySearchResultListElementComponent extends SearchResultListElementComponent<CommunitySearchResult, Community> {
|
||||
|
||||
}
|
||||
|
@@ -1,2 +0,0 @@
|
||||
<ds-item-type-badge [object]="object"></ds-item-type-badge>
|
||||
<ds-listable-object-component-loader [type]="object.indexableObject.firstMetadataValue('relationship.type') + 'SearchResult'" [object]="object" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
@@ -1,60 +0,0 @@
|
||||
import { ItemSearchResultListElementComponent } from './item-search-result-list-element.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
let itemSearchResultListElementComponent: ItemSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
const type = 'authorOfPublication';
|
||||
|
||||
const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithRelationshipType.hitHighlights = {};
|
||||
mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'relationship.type': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: type
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('ItemSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule],
|
||||
declarations: [ItemSearchResultListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
{ provide: 'objectElementProvider', useValue: (mockItemWithRelationshipType) }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ItemSearchResultListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemSearchResultListElementComponent);
|
||||
itemSearchResultListElementComponent = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
it('should show a badge on top of the list element', () => {
|
||||
const badge = fixture.debugElement.query(By.css('ds-item-type-badge')).componentInstance;
|
||||
expect(badge.object).toBe(mockItemWithRelationshipType);
|
||||
});
|
||||
});
|
@@ -1,22 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { focusBackground } from '../../../animations/focus';
|
||||
|
||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||
import { SearchResultListElementComponent } from '../search-result-list-element.component';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-search-result-list-element',
|
||||
styleUrls: ['../search-result-list-element.component.scss', 'item-search-result-list-element.component.scss'],
|
||||
templateUrl: 'item-search-result-list-element.component.html',
|
||||
animations: [focusBackground],
|
||||
|
||||
})
|
||||
|
||||
@listableObjectComponent(ItemSearchResult, ViewMode.ListElement)
|
||||
export class ItemSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
|
||||
viewMode = ViewMode.ListElement;
|
||||
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
<ng-container *ngVar="object.indexableObject as item">
|
||||
<ds-truncatable [id]="item.id" *ngIf="object !== undefined && object !== null">
|
||||
<ds-item-type-badge [object]="item"></ds-item-type-badge>
|
||||
|
||||
<ds-truncatable [id]="item.id" *ngIf="object !== undefined && object !== null">
|
||||
<a
|
||||
[routerLink]="['/items/' + item.id]" class="lead"
|
||||
[innerHTML]="firstMetadataValue('dc.title')"></a>
|
||||
@@ -23,5 +25,5 @@
|
||||
[innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
|
||||
</ds-truncatable-part>
|
||||
</div>
|
||||
</ds-truncatable>
|
||||
</ds-truncatable>
|
||||
</ng-container>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user