mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
fixed existing tests and added linkType
This commit is contained in:
@@ -216,9 +216,9 @@ describe('ItemMetadataComponent', () => {
|
||||
});
|
||||
|
||||
it('it should call reinstateFieldUpdates on the objectUpdatesService with the correct url and metadata', () => {
|
||||
expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.object.metadataAsList);
|
||||
expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.object, { metadata: Metadata.toMetadataMap(comp.object.metadataAsList) }));
|
||||
expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.object.metadataAsList);
|
||||
expect(objectUpdatesService.getUpdatedFields).toHaveBeenCalledWith(url, comp.item.metadataAsList);
|
||||
expect(itemService.update).toHaveBeenCalledWith(Object.assign(comp.item, { metadata: Metadata.toMetadataMap(comp.item.metadataAsList) }));
|
||||
expect(objectUpdatesService.getFieldUpdates).toHaveBeenCalledWith(url, comp.item.metadataAsList);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -5,7 +5,6 @@ import { ObjectUpdatesService } from '../../../../core/data/object-updates/objec
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { EditRelationshipComponent } from './edit-relationship.component';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { ResourceType } from '../../../../core/shared/resource-type';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
@@ -113,7 +112,7 @@ describe('EditRelationshipComponent', () => {
|
||||
|
||||
comp.url = url;
|
||||
comp.fieldUpdate = fieldUpdate1;
|
||||
comp.object = item;
|
||||
comp.item = item;
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
@@ -32,7 +32,7 @@ describe('ModifyItemOverviewComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ModifyItemOverviewComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItem;
|
||||
comp.item = mockItem;
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
@@ -31,7 +31,7 @@ describe('ItemPageAbstractFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageAbstractFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -32,7 +32,7 @@ describe('ItemPageAuthorFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageAuthorFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItemWithMetadataFieldAndValue(field, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(field, mockValue);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -31,7 +31,7 @@ describe('ItemPageDateFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageDateFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -33,7 +33,7 @@ describe('GenericItemPageFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(GenericItemPageFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.fields = mockFields;
|
||||
comp.label = mockLabel;
|
||||
fixture.detectChanges();
|
||||
|
@@ -4,12 +4,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { ItemPageFieldComponent } from './item-page-field.component';
|
||||
import { MetadataValuesComponent } from '../../../field-components/metadata-values/metadata-values.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { MetadataMap, MetadataValue } from '../../../../core/shared/metadata.models';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
|
||||
@@ -40,7 +37,7 @@ describe('ItemPageFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.fields = mockFields;
|
||||
comp.label = mockLabel;
|
||||
fixture.detectChanges();
|
||||
|
@@ -31,7 +31,7 @@ describe('ItemPageTitleFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageTitleFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -31,7 +31,7 @@ describe('ItemPageUriFieldComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemPageUriFieldComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
comp.item = mockItemWithMetadataFieldAndValue(mockField, mockValue);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -3,19 +3,16 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader';
|
||||
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
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 '../shared/item.component.spec';
|
||||
import { PublicationComponent } from './publication.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { MetadataMap } from '../../../../core/shared/metadata.models';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
|
||||
@@ -45,7 +42,6 @@ describe('PublicationComponent', () => {
|
||||
})],
|
||||
declarations: [PublicationComponent, GenericItemPageFieldComponent, TruncatePipe],
|
||||
providers: [
|
||||
{provide: ITEM, useValue: mockItem},
|
||||
{provide: ItemDataService, useValue: {}},
|
||||
{provide: SearchFixedFilterService, useValue: searchFixedFilterServiceStub},
|
||||
{provide: TruncatableService, useValue: {}}
|
||||
@@ -60,6 +56,7 @@ describe('PublicationComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(PublicationComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -7,17 +7,14 @@ import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader';
|
||||
import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { ItemComponent } from './item.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { VarDirective } from '../../../../shared/utils/var.directive';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
@@ -56,7 +53,6 @@ export function getItemPageFieldsTest(mockItem: Item, component) {
|
||||
})],
|
||||
declarations: [component, GenericItemPageFieldComponent, TruncatePipe],
|
||||
providers: [
|
||||
{provide: ITEM, useValue: mockItem},
|
||||
{provide: ItemDataService, useValue: {}},
|
||||
{provide: SearchFixedFilterService, useValue: searchFixedFilterServiceStub},
|
||||
{provide: TruncatableService, useValue: {}}
|
||||
@@ -71,6 +67,7 @@ export function getItemPageFieldsTest(mockItem: Item, component) {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(component);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
@@ -386,10 +383,6 @@ describe('ItemComponent', () => {
|
||||
}
|
||||
}), BrowserAnimationsModule],
|
||||
declarations: [ItemComponent, VarDirective],
|
||||
providers: [
|
||||
{provide: ITEM, useValue: mockItem}
|
||||
],
|
||||
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ItemComponent, {
|
||||
set: {changeDetection: ChangeDetectionStrategy.Default}
|
||||
@@ -399,6 +392,7 @@ describe('ItemComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
representations = comp.buildRepresentations('bogus', metadataField);
|
||||
}));
|
||||
|
@@ -33,7 +33,7 @@ describe('MetadataRepresentationListComponent', () => {
|
||||
}));
|
||||
|
||||
it(`should load ${representations.length} item-type-switcher components`, () => {
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-listable-object-component-loader'));
|
||||
const fields = fixture.debugElement.queryAll(By.css('ds-metadata-representation-loader'));
|
||||
expect(fields.length).toBe(representations.length);
|
||||
});
|
||||
|
||||
|
@@ -38,7 +38,7 @@ describe('RelatedEntitiesSearchComponent', () => {
|
||||
comp = fixture.componentInstance;
|
||||
fixedFilterService = (comp as any).fixedFilterService;
|
||||
comp.relationType = mockRelationType;
|
||||
comp.object = mockItem;
|
||||
comp.item = mockItem;
|
||||
comp.relationEntityType = mockRelationEntityType;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
@@ -12,7 +12,7 @@ import { ClaimedSearchResultListElementComponent } from '../shared/object-list/m
|
||||
import { PoolSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/pool-search-result/pool-search-result-list-element.component';
|
||||
import { MyDSpaceNewSubmissionComponent } from './my-dspace-new-submission/my-dspace-new-submission.component';
|
||||
import { ItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/item-search-result/item-search-result-detail-element.component';
|
||||
import { WorkspaceItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workspace-item-my-dspace-result/workspace-item-search-result-detail-element.component';
|
||||
import { WorkspaceItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workspace-item-search-result/workspace-item-search-result-detail-element.component';
|
||||
import { WorkflowItemSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/workflow-item-search-result/workflow-item-search-result-detail-element.component';
|
||||
import { ClaimedTaskSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/claimed-task-search-result/claimed-task-search-result-detail-element.component';
|
||||
import { MyDSpaceGuard } from './my-dspace.guard';
|
||||
@@ -20,7 +20,7 @@ import { MyDSpaceConfigurationService } from './my-dspace-configuration.service'
|
||||
import { SearchResultListElementComponent } from '../shared/object-list/search-result-list-element/search-result-list-element.component';
|
||||
import { ItemSearchResultListElementSubmissionComponent } from '../shared/object-list/my-dspace-result-list-element/item-search-result/item-search-result-list-element-submission.component';
|
||||
import { WorkflowItemSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/workflow-item-search-result/workflow-item-search-result-list-element.component';
|
||||
import { PoolSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-my-dspace-result/pool-search-result-detail-element.component';
|
||||
import { PoolSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@@ -4,6 +4,7 @@
|
||||
[config]="searchConfig.pagination"
|
||||
[sortConfig]="searchConfig.sort"
|
||||
[objects]="searchResults"
|
||||
[linkType]="linkType"
|
||||
[hideGear]="true">
|
||||
</ds-viewable-collection></div>
|
||||
<ds-loading *ngIf="hasNoValue(searchResults) || hasNoValue(searchResults.payload) || searchResults.isLoading" message="{{'loading.search-results' | translate}}"></ds-loading>
|
||||
|
@@ -8,6 +8,7 @@ import { PaginatedList } from '../../core/data/paginated-list';
|
||||
import { hasNoValue, isNotEmpty } from '../../shared/empty.util';
|
||||
import { SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
import { CollectionElementLinkType } from '../../shared/object-collection/collection-element-link.type';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-search-results',
|
||||
@@ -24,6 +25,8 @@ import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
export class SearchResultsComponent {
|
||||
hasNoValue = hasNoValue;
|
||||
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
|
||||
/**
|
||||
* The actual search result objects
|
||||
*/
|
||||
|
@@ -1 +1 @@
|
||||
<ds-journal-issue-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-journal-issue-search-result-grid-element>
|
||||
<ds-journal-issue-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-journal-issue-search-result-grid-element>
|
@@ -1,15 +1,19 @@
|
||||
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 { JournalIssueGridElementComponent } 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 { of as observableOf } from 'rxjs';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
const mockItem = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -33,18 +37,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutMetadata.hitHighlights = {};
|
||||
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
describe('JournalIssueGridElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
describe('JournalIssueGridElementComponent', getEntityGridElementTestComponent(JournalIssueGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title']));
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [JournalIssueGridElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(JournalIssueGridElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalIssueGridElementComponent);
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe(`when the journal issue is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it(`should contain a JournalIssueSearchResultGridElementComponent`, () => {
|
||||
const journalIssueGridElement = fixture.debugElement.query(By.css(`ds-journal-issue-search-result-grid-element`));
|
||||
expect(journalIssueGridElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -1 +1 @@
|
||||
<ds-journal-volume-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-journal-volume-search-result-grid-element>
|
||||
<ds-journal-volume-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-journal-volume-search-result-grid-element>
|
@@ -1,15 +1,19 @@
|
||||
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 { JournalVolumeGridElementComponent } 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 { of as observableOf } from 'rxjs';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { JournalIssueGridElementComponent } from '../journal-issue/journal-issue-grid-element.component';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
const mockItem = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -33,18 +37,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutMetadata.hitHighlights = {};
|
||||
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
describe('JournalVolumeGridElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
describe('JournalVolumeGridElementComponent', getEntityGridElementTestComponent(JournalVolumeGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description']));
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [JournalVolumeGridElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(JournalVolumeGridElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalVolumeGridElementComponent);
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe(`when the journal volume is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it(`should contain a JournalVolumeSearchResultGridElementComponent`, () => {
|
||||
const journalVolumeGridElement = fixture.debugElement.query(By.css(`ds-journal-volume-search-result-grid-element`));
|
||||
expect(journalVolumeGridElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -1 +1 @@
|
||||
<ds-journal-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-journal-search-result-grid-element>
|
||||
<ds-journal-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-journal-search-result-grid-element>
|
@@ -1,15 +1,18 @@
|
||||
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 { JournalGridElementComponent } 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 { async, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
const mockItem = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -39,18 +42,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutMetadata.hitHighlights = {};
|
||||
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
describe('JournalGridElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
describe('JournalGridElementComponent', getEntityGridElementTestComponent(JournalGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description']));
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [JournalGridElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(JournalGridElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalGridElementComponent);
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe(`when the journal is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it(`should contain a JournalGridElementComponent`, () => {
|
||||
const journalGridElement = fixture.debugElement.query(By.css(`ds-journal-search-result-grid-element`));
|
||||
expect(journalGridElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -1,15 +1,21 @@
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<div class="card" [@focusShadow]="(isCollapsed$ | async)?'blur':'focus'">
|
||||
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
<p *ngIf="dso.hasMetadata('creativework.datePublished')" class="item-date card-text text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
@@ -21,8 +27,8 @@
|
||||
<span [innerHTML]="firstMetadataValue('journal.title')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<div class="text-center">
|
||||
<a [routerLink]="['/items/' + dso.id]"
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
<a [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="lead btn btn-primary viewButton">View</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -46,4 +46,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('JournalIssueGridElementComponent', getEntityGridElementTestComponent(JournalIssueSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title']));
|
||||
describe('JournalIssueSearchResultGridElementComponent', getEntityGridElementTestComponent(JournalIssueSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title']));
|
||||
|
@@ -1,11 +1,17 @@
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<div class="card" [@focusShadow]="(isCollapsed$ | async)?'blur':'focus'">
|
||||
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="this.dso.getThumbnail() | async">
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
@@ -21,8 +27,8 @@
|
||||
<span [innerHTML]="firstMetadataValue('dc.description')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<div class="text-center">
|
||||
<a [routerLink]="['/items/' + dso.id]"
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
<a [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="lead btn btn-primary viewButton">View</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -46,4 +46,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('JournalVolumeGridElementComponent', getEntityGridElementTestComponent(JournalVolumeSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description']));
|
||||
describe('JournalVolumeSearchResultGridElementComponent', getEntityGridElementTestComponent(JournalVolumeSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description']));
|
||||
|
@@ -1,23 +1,29 @@
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<div class="card" [@focusShadow]="(isCollapsed$ | async)?'blur':'focus'">
|
||||
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="this.dso.getThumbnail() | async">
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
<p *ngIf="dso.hasMetadata('creativework.editor')"
|
||||
class="item-publisher card-text text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<span class="item-editor">{{dso.firstMetadataValue('creativework.editor')}}</span>
|
||||
<span class="item-editor">{{firstMetadataValue('creativework.editor')}}</span>
|
||||
<span *ngIf="dso.hasMetadata('creativework.publisher')" class="item-publisher">
|
||||
<span>, </span>
|
||||
{{dso.firstMetadataValue('creativework.publisher')}}
|
||||
{{firstMetadataValue('creativework.publisher')}}
|
||||
</span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
@@ -26,8 +32,8 @@
|
||||
<span [innerHTML]="firstMetadataValue('dc.description')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<div class="text-center">
|
||||
<a [routerLink]="['/items/' + dso.id]"
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
<a [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="lead btn btn-primary viewButton">View</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -52,4 +52,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('JournalGridElementComponent', getEntityGridElementTestComponent(JournalSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description']));
|
||||
describe('JournalSearchResultGridElementComponent', getEntityGridElementTestComponent(JournalSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description']));
|
||||
|
@@ -1 +1 @@
|
||||
<ds-journal-issue-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-journal-issue-search-result-list-element>
|
||||
<ds-journal-issue-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-journal-issue-search-result-list-element>
|
@@ -1,4 +1,4 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { JournalIssueListElementComponent } from './journal-issue-list-element.component';
|
||||
@@ -7,10 +7,7 @@ import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
|
||||
let journalIssueListElementComponent: JournalIssueListElementComponent;
|
||||
let fixture: ComponentFixture<JournalIssueListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -33,27 +30,23 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('JournalIssueListElementComponent', () => {
|
||||
describe('JournalIssueListElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalIssueListElementComponent , TruncatePipe],
|
||||
declarations: [JournalIssueListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(JournalIssueListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
@@ -61,55 +54,19 @@ describe('JournalIssueListElementComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalIssueListElementComponent);
|
||||
journalIssueListElementComponent = fixture.componentInstance;
|
||||
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe('When the item has a journal identifier', () => {
|
||||
describe(`when the journal issue is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
journalIssueListElementComponent.object = mockItemWithMetadata;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journal issues span', () => {
|
||||
const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues'));
|
||||
expect(journalIdentifierField).not.toBeNull();
|
||||
it(`should contain a JournalIssueListElementComponent`, () => {
|
||||
const journalIssueListElement = fixture.debugElement.query(By.css(`ds-journal-issue-search-result-list-element`));
|
||||
expect(journalIssueListElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no journal identifier', () => {
|
||||
beforeEach(() => {
|
||||
journalIssueListElementComponent.object = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journal issues span', () => {
|
||||
const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues'));
|
||||
expect(journalIdentifierField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has a journal number', () => {
|
||||
beforeEach(() => {
|
||||
journalIssueListElementComponent.object = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journal issue numbers span', () => {
|
||||
const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers'));
|
||||
expect(journalNumberField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no journal number', () => {
|
||||
beforeEach(() => {
|
||||
journalIssueListElementComponent.object = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journal issue numbers span', () => {
|
||||
const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers'));
|
||||
expect(journalNumberField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1 +1 @@
|
||||
<ds-journal-volume-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-journal-volume-search-result-list-element>
|
||||
<ds-journal-volume-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-journal-volume-search-result-list-element>
|
@@ -1,4 +1,4 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { JournalVolumeListElementComponent } from './journal-volume-list-element.component';
|
||||
@@ -7,10 +7,7 @@ import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
|
||||
let journalVolumeListElementComponent: JournalVolumeListElementComponent;
|
||||
let fixture: ComponentFixture<JournalVolumeListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -33,27 +30,22 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
describe('JournalVolumeListElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
describe('JournalVolumeListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalVolumeListElementComponent , TruncatePipe],
|
||||
declarations: [JournalVolumeListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(JournalVolumeListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
@@ -61,55 +53,19 @@ describe('JournalVolumeListElementComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalVolumeListElementComponent);
|
||||
journalVolumeListElementComponent = fixture.componentInstance;
|
||||
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe('When the item has a journal title', () => {
|
||||
describe(`when the journal volume is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
journalVolumeListElementComponent.object = mockItemWithMetadata;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journal title span', () => {
|
||||
const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes'));
|
||||
expect(journalTitleField).not.toBeNull();
|
||||
it(`should contain a JournalVolumeListElementComponent`, () => {
|
||||
const journalVolumeListElement = fixture.debugElement.query(By.css(`ds-journal-volume-search-result-list-element`));
|
||||
expect(journalVolumeListElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no journal title', () => {
|
||||
beforeEach(() => {
|
||||
journalVolumeListElementComponent.object = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journal title span', () => {
|
||||
const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes'));
|
||||
expect(journalTitleField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has a journal identifier', () => {
|
||||
beforeEach(() => {
|
||||
journalVolumeListElementComponent.object = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journal identifiers span', () => {
|
||||
const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers'));
|
||||
expect(journalIdentifierField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no journal identifier', () => {
|
||||
beforeEach(() => {
|
||||
journalVolumeListElementComponent.object = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journal identifiers span', () => {
|
||||
const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers'));
|
||||
expect(journalIdentifierField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1 +1 @@
|
||||
<ds-journal-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-journal-search-result-list-element>
|
||||
<ds-journal-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-journal-search-result-list-element>
|
@@ -1,17 +1,13 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { JournalListElementComponent } 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';
|
||||
|
||||
let journalListElementComponent: JournalListElementComponent;
|
||||
let fixture: ComponentFixture<JournalListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -28,28 +24,24 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('JournalListElementComponent', () => {
|
||||
|
||||
describe('JournalListElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalListElementComponent , TruncatePipe],
|
||||
declarations: [JournalListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(JournalListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
@@ -57,31 +49,19 @@ describe('JournalListElementComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalListElementComponent);
|
||||
journalListElementComponent = fixture.componentInstance;
|
||||
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe('When the item has an issn', () => {
|
||||
describe(`when the journal is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
journalListElementComponent.object = mockItemWithMetadata;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journals span', () => {
|
||||
const issnField = fixture.debugElement.query(By.css('span.item-list-journals'));
|
||||
expect(issnField).not.toBeNull();
|
||||
it(`should contain a JournalListElementComponent`, () => {
|
||||
const journalListElement = fixture.debugElement.query(By.css(`ds-journal-search-result-list-element`));
|
||||
expect(journalListElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no issn', () => {
|
||||
beforeEach(() => {
|
||||
journalListElementComponent.object = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journals span', () => {
|
||||
const issnField = fixture.debugElement.query(By.css('span.item-list-journals'));
|
||||
expect(issnField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,8 +1,11 @@
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a
|
||||
<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>
|
||||
<span *ngIf="linkType == linkTypes.None"
|
||||
class="lead"
|
||||
[innerHTML]="firstMetadataValue('dc.title')"></span>
|
||||
<span class="text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<span *ngIf="dso.allMetadata(['publicationvolume.volumeNumber']).length > 0"
|
||||
|
@@ -55,7 +55,7 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
})
|
||||
});
|
||||
|
||||
describe('JournalIssueListElementComponent', () => {
|
||||
describe('JournalIssueSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe],
|
||||
|
@@ -1,8 +1,11 @@
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a
|
||||
<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>
|
||||
<span *ngIf="linkType == linkTypes.None"
|
||||
class="lead"
|
||||
[innerHTML]="firstMetadataValue('dc.title')"></span>
|
||||
<span class="text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<span *ngIf="dso.allMetadata(['journal.title']).length > 0"
|
||||
|
@@ -54,7 +54,7 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
})
|
||||
});
|
||||
|
||||
describe('JournalVolumeListElementComponent', () => {
|
||||
describe('JournalVolumeSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe],
|
||||
|
@@ -1,8 +1,11 @@
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a
|
||||
<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>
|
||||
<span *ngIf="linkType == linkTypes.None"
|
||||
class="lead"
|
||||
[innerHTML]="firstMetadataValue('dc.title')"></span>
|
||||
<span class="text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<span *ngIf="dso.allMetadata(['creativeworkseries.issn']).length > 0"
|
||||
|
@@ -50,7 +50,7 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
}
|
||||
);
|
||||
|
||||
describe('JournalListElementComponent', () => {
|
||||
describe('JournalSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [JournalSearchResultListElementComponent, TruncatePipe],
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<ds-metadata-field-wrapper>
|
||||
<ds-thumbnail [thumbnail]="this.object.getThumbnail() | async"></ds-thumbnail>
|
||||
<ds-thumbnail [thumbnail]="object.getThumbnail() | async"></ds-thumbnail>
|
||||
</ds-metadata-field-wrapper>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['publicationvolume.volumeNumber']"
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<ds-metadata-field-wrapper>
|
||||
<ds-thumbnail [thumbnail]="this.object.getThumbnail() | async"></ds-thumbnail>
|
||||
<ds-thumbnail [thumbnail]="object.getThumbnail() | async"></ds-thumbnail>
|
||||
</ds-metadata-field-wrapper>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['publicationvolume.volumeNumber']"
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<ds-metadata-field-wrapper>
|
||||
<ds-thumbnail [thumbnail]="this.object.getThumbnail() | async"></ds-thumbnail>
|
||||
<ds-thumbnail [thumbnail]="object.getThumbnail() | async"></ds-thumbnail>
|
||||
</ds-metadata-field-wrapper>
|
||||
<ds-generic-item-page-field class="item-page-fields" [item]="object"
|
||||
[fields]="['creativeworkseries.issn']"
|
||||
|
@@ -1,19 +1,16 @@
|
||||
import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ITEM } from '../../../../shared/items/switcher/listable-object-component-loader.component';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { JournalComponent } from './journal.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { GenericItemPageFieldComponent } from '../../../../+item-page/simple/field-components/specific-field/generic/generic-item-page-field.component';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
|
||||
@@ -55,7 +52,6 @@ describe('JournalComponent', () => {
|
||||
})],
|
||||
declarations: [JournalComponent, GenericItemPageFieldComponent, TruncatePipe],
|
||||
providers: [
|
||||
{provide: ITEM, useValue: mockItem},
|
||||
{provide: ItemDataService, useValue: {}},
|
||||
{provide: TruncatableService, useValue: {}}
|
||||
],
|
||||
@@ -69,6 +65,7 @@ describe('JournalComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
<ds-orgunit-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-orgunit-search-result-grid-element>
|
||||
<ds-orgunit-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-orgunit-search-result-grid-element>
|
@@ -1,15 +1,17 @@
|
||||
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 { OrgunitGridElementComponent } 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 { async, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
const mockItem = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -39,18 +41,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutMetadata.hitHighlights = {};
|
||||
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
describe('OrgunitGridElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
describe('OrgunitGridElementComponent', getEntityGridElementTestComponent(OrgunitGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city']));
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [OrgunitGridElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(OrgunitGridElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(OrgunitGridElementComponent);
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe(`when the org unit is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it(`should contain a OrgunitGridElementComponent`, () => {
|
||||
const orgunitGridElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-grid-element`));
|
||||
expect(orgunitGridElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -1 +1 @@
|
||||
<ds-person-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-person-search-result-grid-element>
|
||||
<ds-person-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-person-search-result-grid-element>
|
@@ -1,15 +1,17 @@
|
||||
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 { PersonGridElementComponent } 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 { async, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
const mockItem = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -33,18 +35,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutMetadata.hitHighlights = {};
|
||||
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
describe('PersonGridElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
describe('PersonGridElementComponent', getEntityGridElementTestComponent(PersonGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle']));
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [PersonGridElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(PersonGridElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(PersonGridElementComponent);
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe(`when the person is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it(`should contain a PersonGridElementComponent`, () => {
|
||||
const personGridElement = fixture.debugElement.query(By.css(`ds-person-search-result-grid-element`));
|
||||
expect(personGridElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -1 +1 @@
|
||||
<ds-project-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-project-search-result-grid-element>
|
||||
<ds-project-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-project-search-result-grid-element>
|
@@ -6,10 +6,15 @@ import { ProjectGridElementComponent } 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 { async, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { PersonGridElementComponent } from '../person/person-grid-element.component';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithMetadata.hitHighlights = {};
|
||||
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
const mockItem = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -27,18 +32,43 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutMetadata.hitHighlights = {};
|
||||
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
describe('ProjectGridElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
describe('ProjectGridElementComponent', getEntityGridElementTestComponent(ProjectGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['description']));
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [ProjectGridElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ProjectGridElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ProjectGridElementComponent);
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe(`when the project is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it(`should contain a ProjectGridElementComponent`, () => {
|
||||
const projectGridElement = fixture.debugElement.query(By.css(`ds-project-search-result-grid-element`));
|
||||
expect(projectGridElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -1,33 +1,39 @@
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<div class="card" [@focusShadow]="(isCollapsed$ | async)?'blur':'focus'">
|
||||
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('organization.legalName')"></h4>
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('organization.legalName')"></h4>
|
||||
</ds-truncatable-part>
|
||||
<p *ngIf="dso.hasMetadata('organization.foundingDate')" class="dso-date card-text text-muted">
|
||||
<p *ngIf="dso.hasMetadata('organization.foundingDate')" class="item-date card-text text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<span [innerHTML]="firstMetadataValue('organization.foundingDate')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<p *ngIf="dso.hasMetadata('organization.address.addressCountry')"
|
||||
class="dso-location card-text">
|
||||
class="item-location card-text">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||
<span class="dso-country">{{dso.firstMetadataValue('organization.address.addressCountry')}}</span>
|
||||
<span *ngIf="dso.hasMetadata('organization.address.addressLocality')" class="dso-city">
|
||||
<span class="item-country">{{firstMetadataValue('organization.address.addressCountry')}}</span>
|
||||
<span *ngIf="dso.hasMetadata('organization.address.addressLocality')" class="item-city">
|
||||
<span>, </span>
|
||||
{{dso.firstMetadataValue('organization.address.addressLocality')}}
|
||||
{{firstMetadataValue('organization.address.addressLocality')}}
|
||||
</span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<div class="text-center">
|
||||
<a [routerLink]="['/items/' + dso.id]"
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
<a [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="lead btn btn-primary viewButton">View</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -52,4 +52,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('OrgunitGridElementComponent', getEntityGridElementTestComponent(OrgunitSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city']));
|
||||
describe('OrgunitSearchResultGridElementComponent', getEntityGridElementTestComponent(OrgunitSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city']));
|
||||
|
@@ -1,28 +1,35 @@
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<div class="card" [@focusShadow]="(isCollapsed$ | async)?'blur':'focus'">
|
||||
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="this.dso.getThumbnail() | async">
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('person.familyName') + ', ' + dso.firstMetadataValue('person.givenName')"></h4>
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('person.familyName') + ', ' + firstMetadataValue('person.givenName')"></h4>
|
||||
</ds-truncatable-part>
|
||||
<p *ngIf="dso.hasMetadata('person.email')" class="dso-email card-text text-muted">
|
||||
<p *ngIf="dso.hasMetadata('person.email')" class="item-email card-text text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<span [innerHTML]="firstMetadataValue('person.email')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<p *ngIf="dso.hasMetadata('person.jobTitle')" class="dso-jobtitle card-text">
|
||||
<p *ngIf="dso.hasMetadata('person.jobTitle')" class="item-jobtitle card-text">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||
<span [innerHTML]="firstMetadataValue('person.jobTitle')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<div class="text-center">
|
||||
<a [routerLink]="['/items/' + dso.id]"
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
<a [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="lead btn btn-primary viewButton">View</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -46,4 +46,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('PersonGridElementComponent', getEntityGridElementTestComponent(PersonSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle']));
|
||||
describe('PersonSearchResultGridElementComponent', getEntityGridElementTestComponent(PersonSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle']));
|
||||
|
@@ -1,23 +1,29 @@
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<div class="card" [@focusShadow]="(isCollapsed$ | async)?'blur':'focus'">
|
||||
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="card-img-top full-width">
|
||||
<div>
|
||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail() | async">
|
||||
</ds-grid-thumbnail>
|
||||
</div>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||
<h4 class="card-title" [innerHTML]="firstMetadataValue('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
<p *ngIf="dso.hasMetadata('dc.description')" class="dso-description card-text text-muted">
|
||||
<p *ngIf="dso.hasMetadata('dc.description')" class="item-description card-text text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||
<span [innerHTML]="firstMetadataValue('dc.description')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<div class="text-center">
|
||||
<a [routerLink]="['/items/' + dso.id]"
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
<a [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/items/' + dso.id]"
|
||||
class="lead btn btn-primary viewButton">View</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -40,4 +40,4 @@ mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('ProjectGridElementComponent', getEntityGridElementTestComponent(ProjectSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['description']));
|
||||
describe('ProjectSearchResultGridElementComponent', getEntityGridElementTestComponent(ProjectSearchResultGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['description']));
|
||||
|
@@ -1,13 +1,13 @@
|
||||
<ng-template #descTemplate>
|
||||
<span class="text-muted">
|
||||
<span *ngIf="object.allMetadata(['dc.description']).length > 0"
|
||||
<span *ngIf="metadataRepresentation.allMetadata(['dc.description']).length > 0"
|
||||
class="item-list-job-title">
|
||||
<span [innerHTML]="firstMetadataValue(['dc.description'])"></span>
|
||||
<span [innerHTML]="metadataRepresentation.firstMetadataValue(['dc.description'])"></span>
|
||||
</span>
|
||||
</span>
|
||||
</ng-template>
|
||||
<ds-truncatable [id]="object.id">
|
||||
<a [routerLink]="['/items/' + object.id]"
|
||||
[innerHTML]="firstMetadataValue('organization.legalName')"
|
||||
<ds-truncatable [id]="metadataRepresentation.id">
|
||||
<a [routerLink]="['/items/' + metadataRepresentation.id]"
|
||||
[innerHTML]="metadataRepresentation.firstMetadataValue('organization.legalName')"
|
||||
[tooltip]="descTemplate"></a>
|
||||
</ds-truncatable>
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { AbstractListableElementComponent } from '../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator';
|
||||
import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model';
|
||||
import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||
|
||||
@metadataRepresentationComponent('OrgUnit', MetadataRepresentationType.Item)
|
||||
@Component({
|
||||
@@ -12,5 +11,6 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-rep
|
||||
/**
|
||||
* The component for displaying a list element for an item of the type OrgUnit
|
||||
*/
|
||||
export class OrgunitItemPageListElementComponent extends AbstractListableElementComponent<Item> {
|
||||
export class OrgunitItemPageListElementComponent {
|
||||
metadataRepresentation: ItemMetadataRepresentation;
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
<ds-orgunit-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-orgunit-search-result-list-element>
|
||||
<ds-orgunit-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-orgunit-search-result-list-element>
|
@@ -1,17 +1,13 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { OrgUnitListElementComponent } 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';
|
||||
|
||||
let orgUnitListElementComponent: OrgUnitListElementComponent;
|
||||
let fixture: ComponentFixture<OrgUnitListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -28,28 +24,23 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('OrgUnitListElementComponent', () => {
|
||||
describe('OrgunitListElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ OrgUnitListElementComponent , TruncatePipe],
|
||||
declarations: [OrgUnitListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(OrgUnitListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
@@ -57,31 +48,19 @@ describe('OrgUnitListElementComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(OrgUnitListElementComponent);
|
||||
orgUnitListElementComponent = fixture.componentInstance;
|
||||
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe('When the item has an orgunit description', () => {
|
||||
describe(`when the orgunit is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
orgUnitListElementComponent.object = mockItemWithMetadata;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the description span', () => {
|
||||
const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description'));
|
||||
expect(orgunitDescriptionField).not.toBeNull();
|
||||
it(`should contain a OrgUnitListElementComponent`, () => {
|
||||
const orgunitListElement = fixture.debugElement.query(By.css(`ds-orgunit-search-result-list-element`));
|
||||
expect(orgunitListElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no orgunit description', () => {
|
||||
beforeEach(() => {
|
||||
orgUnitListElementComponent.object = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the description span', () => {
|
||||
const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description'));
|
||||
expect(orgunitDescriptionField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,15 +1,15 @@
|
||||
<ng-template #descTemplate>
|
||||
<span class="text-muted">
|
||||
<span *ngIf="object.allMetadata(['person.jobTitle']).length > 0"
|
||||
<span *ngIf="metadataRepresentation.allMetadata(['person.jobTitle']).length > 0"
|
||||
class="item-list-job-title">
|
||||
<span *ngFor="let value of allMetadataValues(['person.jobTitle']); let last=last;">
|
||||
<span *ngFor="let value of metadataRepresentation.allMetadataValues(['person.jobTitle']); let last=last;">
|
||||
<span [innerHTML]="value"><span [innerHTML]="value"></span></span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</ng-template>
|
||||
<ds-truncatable [id]="object.id">
|
||||
<a [routerLink]="['/items/' + object.id]"
|
||||
[innerHTML]="firstMetadataValue('person.familyName') + ', ' + firstMetadataValue('person.givenName')"
|
||||
<ds-truncatable [id]="metadataRepresentation.id">
|
||||
<a [routerLink]="['/items/' + metadataRepresentation.id]"
|
||||
[innerHTML]="metadataRepresentation.firstMetadataValue('person.familyName') + ', ' + metadataRepresentation.firstMetadataValue('person.givenName')"
|
||||
[tooltip]="descTemplate"></a>
|
||||
</ds-truncatable>
|
||||
|
@@ -3,6 +3,8 @@ import { AbstractListableElementComponent } from '../../../../shared/object-coll
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { metadataRepresentationComponent } from '../../../../shared/metadata-representation/metadata-representation.decorator';
|
||||
import { MetadataRepresentationType } from '../../../../core/shared/metadata-representation/metadata-representation.model';
|
||||
import { MetadataRepresentationListElementComponent } from '../../../../shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component';
|
||||
import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||
|
||||
@metadataRepresentationComponent('Person', MetadataRepresentationType.Item)
|
||||
@Component({
|
||||
@@ -12,5 +14,6 @@ import { MetadataRepresentationType } from '../../../../core/shared/metadata-rep
|
||||
/**
|
||||
* The component for displaying a list element for an item of the type Person
|
||||
*/
|
||||
export class PersonItemPageListElementComponent extends AbstractListableElementComponent<Item> {
|
||||
export class PersonItemPageListElementComponent {
|
||||
metadataRepresentation: ItemMetadataRepresentation;
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
<ds-person-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-person-search-result-list-element>
|
||||
<ds-person-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-person-search-result-list-element>
|
@@ -6,11 +6,9 @@ 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 { OrgUnitListElementComponent } from '../orgunit/orgunit-list-element.component';
|
||||
|
||||
let personListElementComponent: PersonListElementComponent;
|
||||
let fixture: ComponentFixture<PersonListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -27,27 +25,23 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('PersonListElementComponent', () => {
|
||||
describe('PersonListElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PersonListElementComponent , TruncatePipe],
|
||||
declarations: [PersonListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(PersonListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
@@ -55,31 +49,19 @@ describe('PersonListElementComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(PersonListElementComponent);
|
||||
personListElementComponent = fixture.componentInstance;
|
||||
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe('When the item has a job title', () => {
|
||||
describe(`when the person is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
personListElementComponent.object = mockItemWithMetadata;
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the job title span', () => {
|
||||
const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title'));
|
||||
expect(jobTitleField).not.toBeNull();
|
||||
it(`should contain a PersonListElementComponent`, () => {
|
||||
const personListElement = fixture.debugElement.query(By.css(`ds-person-search-result-list-element`));
|
||||
expect(personListElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no job title', () => {
|
||||
beforeEach(() => {
|
||||
personListElementComponent.object = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the job title span', () => {
|
||||
const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title'));
|
||||
expect(jobTitleField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1 +1 @@
|
||||
<ds-project-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }"></ds-project-search-result-list-element>
|
||||
<ds-project-search-result-list-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-project-search-result-list-element>
|
@@ -1,17 +1,14 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ProjectListElementComponent } 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 { PersonListElementComponent } from '../person/person-list-element.component';
|
||||
import { ProjectListElementComponent } from './project-list-element.component';
|
||||
|
||||
let projectListElementComponent: ProjectListElementComponent;
|
||||
let fixture: ComponentFixture<ProjectListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
@@ -28,28 +25,22 @@ const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
// ]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
describe('ProjectListElementComponent',
|
||||
() => {
|
||||
let comp;
|
||||
let fixture;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
describe('ProjectListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ProjectListElementComponent , TruncatePipe],
|
||||
declarations: [ProjectListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ProjectListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
@@ -57,31 +48,19 @@ describe('ProjectListElementComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ProjectListElementComponent);
|
||||
projectListElementComponent = fixture.componentInstance;
|
||||
|
||||
comp = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
// describe('When the item has a status', () => {
|
||||
// beforeEach(() => {
|
||||
// projectListElementComponent.item = mockItemWithMetadata;
|
||||
// fixture.detectChanges();
|
||||
// });
|
||||
//
|
||||
// it('should show the status span', () => {
|
||||
// const statusField = fixture.debugElement.query(By.css('span.item-list-status'));
|
||||
// expect(statusField).not.toBeNull();
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// describe('When the item has no status', () => {
|
||||
// beforeEach(() => {
|
||||
// projectListElementComponent.item = mockItemWithoutMetadata;
|
||||
// fixture.detectChanges();
|
||||
// });
|
||||
//
|
||||
// it('should not show the status span', () => {
|
||||
// const statusField = fixture.debugElement.query(By.css('span.item-list-status'));
|
||||
// expect(statusField).toBeNull();
|
||||
// });
|
||||
// });
|
||||
});
|
||||
describe(`when the project is rendered`, () => {
|
||||
beforeEach(() => {
|
||||
comp.object = mockItem;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it(`should contain a ProjectListElementComponent`, () => {
|
||||
const projectListElement = fixture.debugElement.query(By.css(`ds-project-search-result-list-element`));
|
||||
expect(projectListElement).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -1,8 +1,11 @@
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
|
||||
[routerLink]="['/items/' + dso.id]" class="lead"
|
||||
[innerHTML]="firstMetadataValue('organization.legalName')"></a>
|
||||
<span *ngIf="linkType == linkTypes.None"
|
||||
class="lead"
|
||||
[innerHTML]="firstMetadataValue('organization.legalName')"></span>
|
||||
<span class="text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||
<span *ngIf="dso.allMetadata(['dc.description']).length > 0"
|
||||
|
@@ -48,7 +48,7 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
})
|
||||
});
|
||||
|
||||
describe('OrgUnitListElementComponent', () => {
|
||||
describe('OrgUnitSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ OrgunitSearchResultListElementComponent , TruncatePipe],
|
||||
|
@@ -1,8 +1,11 @@
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<a
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
|
||||
[routerLink]="['/items/' + dso.id]" class="lead"
|
||||
[innerHTML]="firstMetadataValue('person.familyName') + ', ' + firstMetadataValue('person.givenName')"></a>
|
||||
<span *ngIf="linkType == linkTypes.None"
|
||||
class="lead"
|
||||
[innerHTML]="firstMetadataValue('person.familyName') + ', ' + firstMetadataValue('person.givenName')"></span>
|
||||
<span class="text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<span *ngIf="dso.allMetadata(['person.jobTitle']).length > 0"
|
||||
|
@@ -48,7 +48,7 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
})
|
||||
});
|
||||
|
||||
describe('PersonListElementComponent', () => {
|
||||
describe('PersonSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PersonSearchResultListElementComponent, TruncatePipe],
|
||||
|
@@ -1,8 +1,11 @@
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<ds-truncatable [id]="dso.id">
|
||||
<ds-item-type-badge [object]="dso"></ds-item-type-badge>
|
||||
<a
|
||||
<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>
|
||||
<span *ngIf="linkType == linkTypes.None"
|
||||
class="lead"
|
||||
[innerHTML]="firstMetadataValue('dc.title')"></span>
|
||||
<!--<span class="text-muted">-->
|
||||
<!--<ds-truncatable-part [id]="dso.id" [minLines]="1">-->
|
||||
<!--<span *ngIf="dso.allMetadata(['project.identifier.status']).length > 0"-->
|
||||
@@ -13,4 +16,4 @@
|
||||
<!--</span>-->
|
||||
<!--</ds-truncatable-part>-->
|
||||
<!--</span>-->
|
||||
</ds-truncatable>
|
||||
</ds-truncatable>
|
||||
|
@@ -48,7 +48,7 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign(
|
||||
})
|
||||
});
|
||||
|
||||
describe('ProjectListElementComponent', () => {
|
||||
describe('ProjectSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ProjectSearchResultListElementComponent, TruncatePipe],
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<ds-metadata-field-wrapper>
|
||||
<ds-thumbnail [thumbnail]="this.object.getThumbnail() | async" [defaultImage]="'assets/images/orgunit-placeholder.svg'"></ds-thumbnail>
|
||||
<ds-thumbnail [thumbnail]="object.getThumbnail() | async" [defaultImage]="'assets/images/orgunit-placeholder.svg'"></ds-thumbnail>
|
||||
</ds-metadata-field-wrapper>
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['organization.foundingDate']"
|
||||
|
@@ -1,12 +1,12 @@
|
||||
<h2 class="item-page-title-field">
|
||||
{{'person.page.titleprefix' | translate}}<ds-metadata-values [mdValues]="[item?.firstMetadata('person.familyName'), item?.firstMetadata('person.givenName')]" [separator]="', '"></ds-metadata-values>
|
||||
{{'person.page.titleprefix' | translate}}<ds-metadata-values [mdValues]="[object?.firstMetadata('person.familyName'), object?.firstMetadata('person.givenName')]" [separator]="', '"></ds-metadata-values>
|
||||
</h2>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<ds-metadata-field-wrapper>
|
||||
<ds-thumbnail [thumbnail]="this.item.getThumbnail() | async" [defaultImage]="'assets/images/person-placeholder.svg'"></ds-thumbnail>
|
||||
<ds-thumbnail [thumbnail]="this.object.getThumbnail() | async" [defaultImage]="'assets/images/person-placeholder.svg'"></ds-thumbnail>
|
||||
</ds-metadata-field-wrapper>
|
||||
<ds-generic-item-page-field [item]="item"
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['person.email']"
|
||||
[label]="'person.page.email'">
|
||||
</ds-generic-item-page-field>
|
||||
@@ -14,7 +14,7 @@
|
||||
<!--[fields]="['person.identifier.orcid']"-->
|
||||
<!--[label]="'person.page.orcid'">-->
|
||||
<!--</ds-generic-item-page-field>-->
|
||||
<ds-generic-item-page-field [item]="item"
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['person.birthDate']"
|
||||
[label]="'person.page.birthdate'">
|
||||
</ds-generic-item-page-field>
|
||||
@@ -32,26 +32,26 @@
|
||||
[items]="orgUnits$ | async"
|
||||
[label]="'relationships.isOrgUnitOf' | translate">
|
||||
</ds-related-items>
|
||||
<ds-generic-item-page-field [item]="item"
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['person.jobTitle']"
|
||||
[label]="'person.page.jobtitle'">
|
||||
</ds-generic-item-page-field>
|
||||
<ds-generic-item-page-field [item]="item"
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['person.familyName']"
|
||||
[label]="'person.page.lastname'">
|
||||
</ds-generic-item-page-field>
|
||||
<ds-generic-item-page-field [item]="item"
|
||||
<ds-generic-item-page-field [item]="object"
|
||||
[fields]="['person.givenName']"
|
||||
[label]="'person.page.firstname'">
|
||||
</ds-generic-item-page-field>
|
||||
<div>
|
||||
<a class="btn btn-outline-primary" [routerLink]="['/items/' + item.id + '/full']">
|
||||
<a class="btn btn-outline-primary" [routerLink]="['/items/' + object.id + '/full']">
|
||||
{{"item.page.link.full" | translate}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5 w-100">
|
||||
<ds-related-entities-search [item]="item"
|
||||
<ds-related-entities-search [item]="object"
|
||||
[relationType]="'isAuthorOfPublication'">
|
||||
</ds-related-entities-search>
|
||||
</div>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<ds-metadata-field-wrapper>
|
||||
<ds-thumbnail [thumbnail]="this.object.getThumbnail() | async" [defaultImage]="'assets/images/project-placeholder.svg'"></ds-thumbnail>
|
||||
<ds-thumbnail [thumbnail]="object.getThumbnail() | async" [defaultImage]="'assets/images/project-placeholder.svg'"></ds-thumbnail>
|
||||
</ds-metadata-field-wrapper>
|
||||
<!--<ds-generic-item-page-field [item]="item"-->
|
||||
<!--[fields]="['project.identifier.status']"-->
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<form #form="ngForm" (ngSubmit)="onSubmit(currentObject)"
|
||||
[action]="action" (keydown)="onKeydown($event)"
|
||||
[action]="action"
|
||||
(keydown.arrowdown)="shiftFocusDown($event)"
|
||||
(keydown.arrowup)="shiftFocusUp($event)" (keydown.esc)="close()"
|
||||
(dsClickOutside)="close();">
|
||||
@@ -14,9 +14,7 @@
|
||||
<div class="dropdown-list">
|
||||
<div *ngFor="let suggestionOption of suggestions">
|
||||
<button class="d-block dropdown-item" (click)="onClickSuggestion(suggestionOption)" #suggestion>
|
||||
<div class="click-blocker">
|
||||
</div>
|
||||
<ds-listable-object-component-loader [object]="suggestionOption" [viewMode]="viewMode"></ds-listable-object-component-loader>
|
||||
<ds-listable-object-component-loader [object]="suggestionOption" [viewMode]="viewMode" [linkType]="linkTypes.None"></ds-listable-object-component-loader>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -3,6 +3,7 @@ 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';
|
||||
import { CollectionElementLinkType } from '../../object-collection/collection-element-link.type';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-dso-input-suggestions',
|
||||
@@ -24,6 +25,7 @@ import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
*/
|
||||
export class DsoInputSuggestionsComponent extends InputSuggestionsComponent {
|
||||
viewMode = ViewMode.ListElement;
|
||||
linkTypes = CollectionElementLinkType;
|
||||
/**
|
||||
* The suggestions that should be shown
|
||||
*/
|
||||
|
@@ -5,19 +5,9 @@
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
padding: $input-padding-y $input-padding-x;
|
||||
position: relative;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.click-blocker {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,3 @@
|
||||
export enum CollectionElementLinkType {
|
||||
None, Link, ExternalLink
|
||||
}
|
@@ -3,6 +3,7 @@
|
||||
[objects]="objects"
|
||||
[hasBorder]="hasBorder"
|
||||
[hideGear]="hideGear"
|
||||
[linkType]="linkType"
|
||||
[context]="context"
|
||||
(paginationChange)="onPaginationChange($event)"
|
||||
(pageChange)="onPageChange($event)"
|
||||
@@ -16,6 +17,7 @@
|
||||
[sortConfig]="sortConfig"
|
||||
[objects]="objects"
|
||||
[hideGear]="hideGear"
|
||||
[linkType]="linkType"
|
||||
[context]="context"
|
||||
(paginationChange)="onPaginationChange($event)"
|
||||
(pageChange)="onPageChange($event)"
|
||||
@@ -29,6 +31,7 @@
|
||||
[sortConfig]="sortConfig"
|
||||
[objects]="objects"
|
||||
[hideGear]="hideGear"
|
||||
[linkType]="linkType"
|
||||
[context]="context"
|
||||
*ngIf="(currentMode$ | async) === viewModeEnum.DetailedListElement">
|
||||
</ds-object-detail>
|
||||
|
@@ -11,6 +11,9 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options
|
||||
import { ListableObject } from './shared/listable-object.model';
|
||||
import { isNotEmpty } from '../empty.util';
|
||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
import { CollectionElementLinkType } from './collection-element-link.type';
|
||||
import { PaginatedList } from '../../core/data/paginated-list';
|
||||
import { Context } from '../../core/shared/context.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-viewable-collection',
|
||||
@@ -19,12 +22,13 @@ import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
})
|
||||
export class ObjectCollectionComponent implements OnInit {
|
||||
|
||||
@Input() objects: RemoteData<ListableObject[]>;
|
||||
@Input() objects: RemoteData<PaginatedList<ListableObject>>;
|
||||
@Input() config?: PaginationComponentOptions;
|
||||
@Input() sortConfig: SortOptions;
|
||||
@Input() hasBorder = false;
|
||||
@Input() hideGear = false;
|
||||
@Input() context: string;
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
@Input() context: Context;
|
||||
pageInfo: Observable<PageInfo>;
|
||||
/**
|
||||
* An event fired when the page is changed.
|
||||
|
@@ -1,90 +0,0 @@
|
||||
import { ListableObjectComponentLoaderComponent } from './listable-object-component-loader.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { PageInfo } from '../../../core/shared/page-info.model';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import * as decorator from '../item-type-decorator';
|
||||
import { getComponentByItemType} from '../item-type-decorator';
|
||||
import { ItemMetadataRepresentation } from '../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../testing/utils';
|
||||
import createSpy = jasmine.createSpy;
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
|
||||
const relationType = 'type';
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'test item'
|
||||
}
|
||||
],
|
||||
'relationship.type': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: relationType
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(), mockItem);
|
||||
let viewMode = ViewMode.StandalonePage;
|
||||
|
||||
describe('ItemTypeSwitcherComponent', () => {
|
||||
let comp: ListableObjectComponentLoaderComponent;
|
||||
let fixture: ComponentFixture<ListableObjectComponentLoaderComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ListableObjectComponentLoaderComponent ],
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).compileComponents(); // compile template and css
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ListableObjectComponentLoaderComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.object = mockItem;
|
||||
comp.viewMode = viewMode;
|
||||
spyOnProperty(decorator, 'getComponentByItemType').and.returnValue(createSpy('getComponentByItemType'))
|
||||
}));
|
||||
|
||||
describe('when the injected object is of type Item', () => {
|
||||
beforeEach(() => {
|
||||
viewMode = ViewMode.StandalonePage;
|
||||
comp.object = mockItem;
|
||||
comp.viewMode = viewMode;
|
||||
});
|
||||
|
||||
describe('when calling getComponent', () => {
|
||||
beforeEach(() => {
|
||||
(comp as any).getComponent();
|
||||
});
|
||||
|
||||
it('should call getComponentByItemType with parameters type and viewMode', () => {
|
||||
expect(decorator.getComponentByItemType).toHaveBeenCalledWith(relationType, viewMode);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the injected object is of type MetadataRepresentation', () => {
|
||||
beforeEach(() => {
|
||||
viewMode = ViewMode.MetadataField;
|
||||
comp.object = mockItemMetadataRepresentation;
|
||||
comp.viewMode = viewMode;
|
||||
});
|
||||
|
||||
describe('when calling getComponent', () => {
|
||||
beforeEach(() => {
|
||||
(comp as any).getComponent();
|
||||
});
|
||||
|
||||
it('should call getComponentByItemType with parameters type, viewMode and representationType', () => {
|
||||
expect(decorator.getComponentByItemType).toHaveBeenCalledWith(relationType, viewMode, mockItemMetadataRepresentation.representationType);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -5,6 +5,7 @@ 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 { CollectionElementLinkType } from '../../collection-element-link.type';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-listable-object-component-loader',
|
||||
@@ -28,6 +29,7 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
|
||||
@Input() viewMode: ViewMode;
|
||||
|
||||
@Input() context: Context;
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
@ViewChild(ListableObjectDirective) listableObjectDirective: ListableObjectDirective;
|
||||
|
||||
constructor(private componentFactoryResolver: ComponentFactoryResolver) {
|
||||
@@ -42,6 +44,7 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
|
||||
const componentRef = viewContainerRef.createComponent(componentFactory);
|
||||
(<Component>componentRef.instance as any).object = this.object;
|
||||
(<Component>componentRef.instance as any).index = this.index;
|
||||
(<Component>componentRef.instance as any).linkType = this.linkType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -38,7 +38,6 @@ export function getListableObjectComponent(types: string[], viewMode: ViewMode,
|
||||
const typeModeMap = typeMap.get(viewMode);
|
||||
if (hasValue(typeModeMap)) {
|
||||
if (hasValue(typeModeMap.get(context))) {
|
||||
console.log(typeModeMap.get(context));
|
||||
return typeModeMap.get(context);
|
||||
}
|
||||
if (bestMatchValue < 2 && hasValue(typeModeMap.get(DEFAULT_CONTEXT))) {
|
||||
@@ -52,6 +51,5 @@ export function getListableObjectComponent(types: string[], viewMode: ViewMode,
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(bestMatch);
|
||||
return bestMatch;
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
import { Component, Inject, Input } from '@angular/core';
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { ListableObject } from '../listable-object.model';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { CollectionElementLinkType } from '../../collection-element-link.type';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-abstract-object-element',
|
||||
@@ -8,4 +8,6 @@ import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
})
|
||||
export class AbstractListableElementComponent<T extends ListableObject> {
|
||||
@Input() object: T;
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
linkTypes = CollectionElementLinkType;
|
||||
}
|
||||
|
@@ -6,12 +6,11 @@ import { of as observableOf } from 'rxjs';
|
||||
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { ClaimedTaskSearchResultDetailElementComponent } from './claimed-task-search-result-detail-element.component';
|
||||
import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-my-dspace-result.model';
|
||||
import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||
import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model';
|
||||
|
||||
let component: ClaimedTaskSearchResultDetailElementComponent;
|
||||
let fixture: ComponentFixture<ClaimedTaskSearchResultDetailElementComponent>;
|
||||
@@ -55,15 +54,11 @@ const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdIt
|
||||
const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem);
|
||||
mockResultObject.indexableObject = Object.assign(new ClaimedTask(), { workflowitem: observableOf(rdWorkflowitem) });
|
||||
|
||||
describe('ClaimedMyDSpaceResultDetailElementComponent', () => {
|
||||
describe('ClaimedTaskSearchResultDetailElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [ClaimedTaskSearchResultDetailElementComponent],
|
||||
providers: [
|
||||
{ provide: 'objectElementProvider', useValue: (mockResultObject) },
|
||||
{ provide: 'indexElementProvider', useValue: (compIndex) }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ClaimedTaskSearchResultDetailElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<ng-container *ngVar="(bitstreams$ | async) as bitstreams">
|
||||
<ds-metadata-field-wrapper [label]="('item.page.files' | translate)">
|
||||
<div *ngIf="bitstreams?.length > 0" class="file-section">
|
||||
<a *ngFor="let file of bitstreams; let last=last;" [href]="file?.content" target="_blank" [download]="file?.name">
|
||||
<a *ngFor="let file of bitstreams; let last=last;" [href]="file?.content" target="_blank" rel="noopener noreferrer" [download]="file?.name">
|
||||
<span>{{file?.name}}</span>
|
||||
<span>({{(file?.sizeBytes) | dsFileSize }})</span>
|
||||
<span *ngIf="!last" innerHTML="{{separator}}"></span>
|
||||
|
@@ -72,7 +72,7 @@ describe('ItemDetailPreviewComponent', () => {
|
||||
fixture = TestBed.createComponent(ItemDetailPreviewComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.object = { hitHighlights: {} } as any;
|
||||
component.object = mockItem;
|
||||
component.item = mockItem;
|
||||
component.separator = ', ';
|
||||
spyOn(component.item, 'getFiles').and.returnValue(mockItem.bitstreams);
|
||||
fixture.detectChanges();
|
||||
|
@@ -47,15 +47,11 @@ mockResultObject.indexableObject = Object.assign(new Item(), {
|
||||
}
|
||||
});
|
||||
|
||||
describe('ItemMyDSpaceResultDetailElementComponent', () => {
|
||||
describe('ItemSearchResultDetailElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [ItemSearchResultDetailElementComponent],
|
||||
providers: [
|
||||
{ provide: 'objectElementProvider', useValue: (mockResultObject) },
|
||||
{ provide: 'indexElementProvider', useValue: (compIndex) }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ItemSearchResultDetailElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
|
@@ -5,12 +5,12 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { PoolSearchResultDetailElementComponent } from './pool-my-dspace-result-detail-element.component';
|
||||
import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-my-dspace-result.model';
|
||||
import { PoolTask } from '../../../../core/tasks/models/pool-task-object.model';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||
import { PoolSearchResultDetailElementComponent } from './pool-search-result-detail-element.component';
|
||||
import { PoolTaskSearchResult } from '../../../object-collection/shared/pool-task-search-result.model';
|
||||
|
||||
let component: PoolSearchResultDetailElementComponent;
|
||||
let fixture: ComponentFixture<PoolSearchResultDetailElementComponent>;
|
||||
@@ -54,7 +54,7 @@ const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdIt
|
||||
const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem);
|
||||
mockResultObject.indexableObject = Object.assign(new PoolTask(), { workflowitem: observableOf(rdWorkflowitem) });
|
||||
|
||||
describe('PoolMyDSpaceResultDetailElementComponent', () => {
|
||||
describe('PoolSearchResultDetailElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
@@ -6,11 +6,10 @@ import { of as observableOf } from 'rxjs';
|
||||
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { WorkflowItemSearchResultDetailElementComponent } from './workflow-item-search-result-detail-element.component';
|
||||
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-my-dspace-result.model';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model';
|
||||
|
||||
let component: WorkflowItemSearchResultDetailElementComponent;
|
||||
let fixture: ComponentFixture<WorkflowItemSearchResultDetailElementComponent>;
|
||||
@@ -52,7 +51,7 @@ const item = Object.assign(new Item(), {
|
||||
const rd = createSuccessfulRemoteDataObject(item);
|
||||
mockResultObject.indexableObject = Object.assign(new WorkflowItem(), { item: observableOf(rd) });
|
||||
|
||||
describe('WorkflowitemMyDSpaceResultDetailElementComponent', () => {
|
||||
describe('WorkflowItemSearchResultDetailElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
|
@@ -6,11 +6,10 @@ import { of as observableOf } from 'rxjs';
|
||||
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { WorkspaceItemSearchResultDetailElementComponent } from './workspace-item-search-result-detail-element.component';
|
||||
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workspaceitem-my-dspace-result.model';
|
||||
import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflowitem-search-result.model';
|
||||
|
||||
let component: WorkspaceItemSearchResultDetailElementComponent;
|
||||
let fixture: ComponentFixture<WorkspaceItemSearchResultDetailElementComponent>;
|
||||
@@ -52,7 +51,7 @@ const item = Object.assign(new Item(), {
|
||||
const rd = createSuccessfulRemoteDataObject(item);
|
||||
mockResultObject.indexableObject = Object.assign(new WorkspaceItem(), { item: observableOf(rd) });
|
||||
|
||||
describe('WorkspaceitemMyDSpaceResultDetailElementComponent', () => {
|
||||
describe('WorkspaceItemSearchResultDetailElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
@@ -17,6 +17,7 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode
|
||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
import { Context } from '../../core/shared/context.model';
|
||||
import { CollectionElementLinkType } from '../object-collection/collection-element-link.type';
|
||||
|
||||
/**
|
||||
* This component renders a paginated set of results in the detail view.
|
||||
@@ -51,6 +52,7 @@ export class ObjectDetailComponent {
|
||||
* A boolean representing if to hide pagination when there is only a page
|
||||
*/
|
||||
@Input() hidePagerWhenSinglePage = true;
|
||||
@Input() linkType: CollectionElementLinkType;
|
||||
@Input() context: Context;
|
||||
|
||||
/**
|
||||
|
@@ -1,14 +1,17 @@
|
||||
<div class="card">
|
||||
<a [routerLink]="['/collections/', object.id]" class="card-img-top">
|
||||
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/collections/', object.id]" class="card-img-top">
|
||||
<ds-grid-thumbnail [thumbnail]="object.logo">
|
||||
</ds-grid-thumbnail>
|
||||
</a>
|
||||
<span *ngIf="linkType == linkTypes.None" class="card-img-top">
|
||||
<ds-grid-thumbnail [thumbnail]="object.logo">
|
||||
</ds-grid-thumbnail>
|
||||
</span>
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">{{object.name}}</h4>
|
||||
<p *ngIf="object.shortDescription" class="card-text">{{object.shortDescription}}</p>
|
||||
<div class="text-center">
|
||||
<a [routerLink]="['/collections/', object.id]" class="lead btn btn-primary viewButton">View</a>
|
||||
<div *ngIf="linkType != linkTypes.None" class="text-center">
|
||||
<a [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" [routerLink]="['/collections/', object.id]" class="lead btn btn-primary viewButton">View</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user