mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #433 from atmire/Entities-grid-templates
Entities grid templates
This commit is contained in:
@@ -62,7 +62,8 @@ import { MetadataFieldWrapperComponent } from './field-components/metadata-field
|
|||||||
GenericItemPageFieldComponent,
|
GenericItemPageFieldComponent,
|
||||||
RelatedEntitiesSearchComponent,
|
RelatedEntitiesSearchComponent,
|
||||||
RelatedItemsComponent,
|
RelatedItemsComponent,
|
||||||
MetadataRepresentationListComponent
|
MetadataRepresentationListComponent,
|
||||||
|
ItemPageTitleFieldComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
PublicationComponent
|
PublicationComponent
|
||||||
|
@@ -0,0 +1,30 @@
|
|||||||
|
<ds-truncatable [id]="dso.id">
|
||||||
|
<div class="card" [@focusShadow]="(isCollapsed() | async)?'blur':'focus'">
|
||||||
|
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||||
|
<div>
|
||||||
|
<ds-grid-thumbnail [thumbnail]="this.item.getThumbnail() | async">
|
||||||
|
</ds-grid-thumbnail>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="card-body">
|
||||||
|
<ds-item-type-badge [object]="object"></ds-item-type-badge>
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
<p *ngIf="dso.hasMetadata('creativework.datePublished')" class="item-date card-text text-muted">
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
|
<span [innerHTML]="firstMetadataValue('creativework.datePublished')"></span>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
</p>
|
||||||
|
<p *ngIf="dso.hasMetadata('journal.title')" class="item-journal-title card-text">
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
|
<span [innerHTML]="firstMetadataValue('journal.title')"></span>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
</p>
|
||||||
|
<div class="text-center">
|
||||||
|
<a [routerLink]="['/items/' + dso.id]"
|
||||||
|
class="lead btn btn-primary viewButton">View</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ds-truncatable>
|
@@ -0,0 +1,47 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'creativework.datePublished': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'journal.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'The journal title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('JournalIssueGridElementComponent', getEntityGridElementTestComponent(JournalIssueGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title']));
|
@@ -0,0 +1,17 @@
|
|||||||
|
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { focusShadow } from '../../../../shared/animations/focus';
|
||||||
|
import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component';
|
||||||
|
|
||||||
|
@rendersItemType('JournalIssue', ItemViewMode.Card)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-journal-issue-grid-element',
|
||||||
|
styleUrls: ['./journal-issue-grid-element.component.scss'],
|
||||||
|
templateUrl: './journal-issue-grid-element.component.html',
|
||||||
|
animations: [focusShadow]
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying a grid element for an item of the type Journal Issue
|
||||||
|
*/
|
||||||
|
export class JournalIssueGridElementComponent extends TypedItemSearchResultGridElementComponent {
|
||||||
|
}
|
@@ -0,0 +1,30 @@
|
|||||||
|
<ds-truncatable [id]="dso.id">
|
||||||
|
<div class="card" [@focusShadow]="(isCollapsed() | async)?'blur':'focus'">
|
||||||
|
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||||
|
<div>
|
||||||
|
<ds-grid-thumbnail [thumbnail]="this.item.getThumbnail() | async">
|
||||||
|
</ds-grid-thumbnail>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="card-body">
|
||||||
|
<ds-item-type-badge [object]="object"></ds-item-type-badge>
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
<p *ngIf="dso.hasMetadata('creativework.datePublished')" class="item-date card-text text-muted">
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
|
<span [innerHTML]="firstMetadataValue('creativework.datePublished')"></span>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
</p>
|
||||||
|
<p *ngIf="dso.hasMetadata('dc.description')" class="item-description card-text">
|
||||||
|
<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]"
|
||||||
|
class="lead btn btn-primary viewButton">View</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ds-truncatable>
|
@@ -0,0 +1,47 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'creativework.datePublished': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.description': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'A description for the journal volume'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('JournalVolumeGridElementComponent', getEntityGridElementTestComponent(JournalVolumeGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description']));
|
@@ -0,0 +1,17 @@
|
|||||||
|
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { focusShadow } from '../../../../shared/animations/focus';
|
||||||
|
import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component';
|
||||||
|
|
||||||
|
@rendersItemType('JournalVolume', ItemViewMode.Card)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-journal-volume-grid-element',
|
||||||
|
styleUrls: ['./journal-volume-grid-element.component.scss'],
|
||||||
|
templateUrl: './journal-volume-grid-element.component.html',
|
||||||
|
animations: [focusShadow]
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying a grid element for an item of the type Journal Volume
|
||||||
|
*/
|
||||||
|
export class JournalVolumeGridElementComponent extends TypedItemSearchResultGridElementComponent {
|
||||||
|
}
|
@@ -0,0 +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">
|
||||||
|
<div>
|
||||||
|
<ds-grid-thumbnail [thumbnail]="this.item.getThumbnail() | async">
|
||||||
|
</ds-grid-thumbnail>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="card-body">
|
||||||
|
<ds-item-type-badge [object]="object"></ds-item-type-badge>
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
<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 *ngIf="dso.hasMetadata('creativework.publisher')" class="item-publisher">
|
||||||
|
<span>, </span>
|
||||||
|
{{dso.firstMetadataValue('creativework.publisher')}}
|
||||||
|
</span>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
</p>
|
||||||
|
<p *ngIf="dso.hasMetadata('dc.description')" class="item-description card-text">
|
||||||
|
<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]"
|
||||||
|
class="lead btn btn-primary viewButton">View</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ds-truncatable>
|
@@ -0,0 +1,53 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'creativework.editor': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith, Donald'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'creativework.publisher': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'A company'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.description': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is the description'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('JournalGridElementComponent', getEntityGridElementTestComponent(JournalGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description']));
|
@@ -0,0 +1,17 @@
|
|||||||
|
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { focusShadow } from '../../../../shared/animations/focus';
|
||||||
|
import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component';
|
||||||
|
|
||||||
|
@rendersItemType('Journal', ItemViewMode.Card)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-journal-grid-element',
|
||||||
|
styleUrls: ['./journal-grid-element.component.scss'],
|
||||||
|
templateUrl: './journal-grid-element.component.html',
|
||||||
|
animations: [focusShadow]
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying a grid element for an item of the type Journal
|
||||||
|
*/
|
||||||
|
export class JournalGridElementComponent extends TypedItemSearchResultGridElementComponent {
|
||||||
|
}
|
@@ -9,6 +9,9 @@ import { JournalListElementComponent } from './item-list-elements/journal/journa
|
|||||||
import { JournalIssueListElementComponent } from './item-list-elements/journal-issue/journal-issue-list-element.component';
|
import { JournalIssueListElementComponent } from './item-list-elements/journal-issue/journal-issue-list-element.component';
|
||||||
import { JournalVolumeListElementComponent } from './item-list-elements/journal-volume/journal-volume-list-element.component';
|
import { JournalVolumeListElementComponent } from './item-list-elements/journal-volume/journal-volume-list-element.component';
|
||||||
import { TooltipModule } from 'ngx-bootstrap';
|
import { TooltipModule } from 'ngx-bootstrap';
|
||||||
|
import { JournalIssueGridElementComponent } from './item-grid-elements/journal-issue/journal-issue-grid-element.component';
|
||||||
|
import { JournalVolumeGridElementComponent } from './item-grid-elements/journal-volume/journal-volume-grid-element.component';
|
||||||
|
import { JournalGridElementComponent } from './item-grid-elements/journal/journal-grid-element.component';
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
JournalComponent,
|
JournalComponent,
|
||||||
@@ -16,7 +19,10 @@ const ENTRY_COMPONENTS = [
|
|||||||
JournalVolumeComponent,
|
JournalVolumeComponent,
|
||||||
JournalListElementComponent,
|
JournalListElementComponent,
|
||||||
JournalIssueListElementComponent,
|
JournalIssueListElementComponent,
|
||||||
JournalVolumeListElementComponent
|
JournalVolumeListElementComponent,
|
||||||
|
JournalIssueGridElementComponent,
|
||||||
|
JournalVolumeGridElementComponent,
|
||||||
|
JournalGridElementComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@@ -0,0 +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">
|
||||||
|
<div>
|
||||||
|
<ds-grid-thumbnail [thumbnail]="this.item.getThumbnail() | async">
|
||||||
|
</ds-grid-thumbnail>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="card-body">
|
||||||
|
<ds-item-type-badge [object]="object"></ds-item-type-badge>
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('organization.legalName')"></h4>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
<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="item-location card-text">
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
|
<span class="item-country">{{dso.firstMetadataValue('organization.address.addressCountry')}}</span>
|
||||||
|
<span *ngIf="dso.hasMetadata('organization.address.addressLocality')" class="item-city">
|
||||||
|
<span>, </span>
|
||||||
|
{{dso.firstMetadataValue('organization.address.addressLocality')}}
|
||||||
|
</span>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
</p>
|
||||||
|
<div class="text-center">
|
||||||
|
<a [routerLink]="['/items/' + dso.id]"
|
||||||
|
class="lead btn btn-primary viewButton">View</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ds-truncatable>
|
@@ -0,0 +1,53 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'organization.foundingDate': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'organization.address.addressCountry': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Belgium'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'organization.address.addressLocality': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Brussels'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('OrgunitGridElementComponent', getEntityGridElementTestComponent(OrgunitGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city']));
|
@@ -0,0 +1,17 @@
|
|||||||
|
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { focusShadow } from '../../../../shared/animations/focus';
|
||||||
|
import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component';
|
||||||
|
|
||||||
|
@rendersItemType('OrgUnit', ItemViewMode.Card)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-orgunit-grid-element',
|
||||||
|
styleUrls: ['./orgunit-grid-element.component.scss'],
|
||||||
|
templateUrl: './orgunit-grid-element.component.html',
|
||||||
|
animations: [focusShadow]
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying a grid element for an item of the type Organisation Unit
|
||||||
|
*/
|
||||||
|
export class OrgunitGridElementComponent extends TypedItemSearchResultGridElementComponent {
|
||||||
|
}
|
@@ -0,0 +1,30 @@
|
|||||||
|
<ds-truncatable [id]="dso.id">
|
||||||
|
<div class="card" [@focusShadow]="(isCollapsed() | async)?'blur':'focus'">
|
||||||
|
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||||
|
<div>
|
||||||
|
<ds-grid-thumbnail [thumbnail]="this.item.getThumbnail() | async">
|
||||||
|
</ds-grid-thumbnail>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="card-body">
|
||||||
|
<ds-item-type-badge [object]="object"></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>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
<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="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]"
|
||||||
|
class="lead btn btn-primary viewButton">View</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ds-truncatable>
|
@@ -0,0 +1,47 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'person.email': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith-Donald@gmail.com'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'person.jobTitle': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Web Developer'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PersonGridElementComponent', getEntityGridElementTestComponent(PersonGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle']));
|
@@ -0,0 +1,17 @@
|
|||||||
|
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component';
|
||||||
|
import { focusShadow } from '../../../../shared/animations/focus';
|
||||||
|
|
||||||
|
@rendersItemType('Person', ItemViewMode.Card)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-person-grid-element',
|
||||||
|
styleUrls: ['./person-grid-element.component.scss'],
|
||||||
|
templateUrl: './person-grid-element.component.html',
|
||||||
|
animations: [focusShadow]
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying a grid element for an item of the type Person
|
||||||
|
*/
|
||||||
|
export class PersonGridElementComponent extends TypedItemSearchResultGridElementComponent {
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
<ds-truncatable [id]="dso.id">
|
||||||
|
<div class="card" [@focusShadow]="(isCollapsed() | async)?'blur':'focus'">
|
||||||
|
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||||
|
<div>
|
||||||
|
<ds-grid-thumbnail [thumbnail]="this.item.getThumbnail() | async">
|
||||||
|
</ds-grid-thumbnail>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="card-body">
|
||||||
|
<ds-item-type-badge [object]="object"></ds-item-type-badge>
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
<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]"
|
||||||
|
class="lead btn btn-primary viewButton">View</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ds-truncatable>
|
@@ -0,0 +1,41 @@
|
|||||||
|
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 { ProjectGridElementComponent } from './project-grid-element.component';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.description': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'The project description'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('ProjectGridElementComponent', getEntityGridElementTestComponent(ProjectGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['description']));
|
@@ -0,0 +1,17 @@
|
|||||||
|
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { focusShadow } from '../../../../shared/animations/focus';
|
||||||
|
import { TypedItemSearchResultGridElementComponent } from '../../../../shared/object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component';
|
||||||
|
|
||||||
|
@rendersItemType('Project', ItemViewMode.Card)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-project-grid-element',
|
||||||
|
styleUrls: ['./project-grid-element.component.scss'],
|
||||||
|
templateUrl: './project-grid-element.component.html',
|
||||||
|
animations: [focusShadow]
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying a grid element for an item of the type Project
|
||||||
|
*/
|
||||||
|
export class ProjectGridElementComponent extends TypedItemSearchResultGridElementComponent {
|
||||||
|
}
|
@@ -11,6 +11,9 @@ import { PersonMetadataListElementComponent } from './item-list-elements/person/
|
|||||||
import { PersonListElementComponent } from './item-list-elements/person/person-list-element.component';
|
import { PersonListElementComponent } from './item-list-elements/person/person-list-element.component';
|
||||||
import { ProjectListElementComponent } from './item-list-elements/project/project-list-element.component';
|
import { ProjectListElementComponent } from './item-list-elements/project/project-list-element.component';
|
||||||
import { TooltipModule } from 'ngx-bootstrap';
|
import { TooltipModule } from 'ngx-bootstrap';
|
||||||
|
import { PersonGridElementComponent } from './item-grid-elements/person/person-grid-element.component';
|
||||||
|
import { OrgunitGridElementComponent } from './item-grid-elements/orgunit/orgunit-grid-element.component';
|
||||||
|
import { ProjectGridElementComponent } from './item-grid-elements/project/project-grid-element.component';
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
OrgunitComponent,
|
OrgunitComponent,
|
||||||
@@ -20,7 +23,10 @@ const ENTRY_COMPONENTS = [
|
|||||||
OrgUnitMetadataListElementComponent,
|
OrgUnitMetadataListElementComponent,
|
||||||
PersonListElementComponent,
|
PersonListElementComponent,
|
||||||
PersonMetadataListElementComponent,
|
PersonMetadataListElementComponent,
|
||||||
ProjectListElementComponent
|
ProjectListElementComponent,
|
||||||
|
PersonGridElementComponent,
|
||||||
|
OrgunitGridElementComponent,
|
||||||
|
ProjectGridElementComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@@ -3,6 +3,7 @@ import { MetadataRepresentationType } from '../../core/shared/metadata-represent
|
|||||||
|
|
||||||
export enum ItemViewMode {
|
export enum ItemViewMode {
|
||||||
Element = 'element',
|
Element = 'element',
|
||||||
|
Card = 'card',
|
||||||
Full = 'full',
|
Full = 'full',
|
||||||
Metadata = 'metadata'
|
Metadata = 'metadata'
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
<img *ngIf="thumbnail && thumbnail.content" [src]="thumbnail.content" (error)="errorHandler($event)"/>
|
<img [src]="src | dsSafeUrl" (error)="errorHandler($event)"/>
|
||||||
<img *ngIf="!(thumbnail && thumbnail.content)" [src]="holderSource | dsSafeUrl"/>
|
|
||||||
</div>
|
</div>
|
||||||
|
@@ -6,7 +6,7 @@ import { GridThumbnailComponent } from './grid-thumbnail.component';
|
|||||||
import { Bitstream } from '../../../core/shared/bitstream.model';
|
import { Bitstream } from '../../../core/shared/bitstream.model';
|
||||||
import { SafeUrlPipe } from '../../utils/safe-url-pipe';
|
import { SafeUrlPipe } from '../../utils/safe-url-pipe';
|
||||||
|
|
||||||
describe('ThumbnailComponent', () => {
|
describe('GridThumbnailComponent', () => {
|
||||||
let comp: GridThumbnailComponent;
|
let comp: GridThumbnailComponent;
|
||||||
let fixture: ComponentFixture<GridThumbnailComponent>;
|
let fixture: ComponentFixture<GridThumbnailComponent>;
|
||||||
let de: DebugElement;
|
let de: DebugElement;
|
||||||
@@ -36,7 +36,7 @@ describe('ThumbnailComponent', () => {
|
|||||||
it('should display placeholder', () => {
|
it('should display placeholder', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const image: HTMLElement = de.query(By.css('img')).nativeElement;
|
const image: HTMLElement = de.query(By.css('img')).nativeElement;
|
||||||
expect(image.getAttribute('src')).toBe(comp.holderSource);
|
expect(image.getAttribute('src')).toBe(comp.defaultImage);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { Bitstream } from '../../../core/shared/bitstream.model';
|
import { Bitstream } from '../../../core/shared/bitstream.model';
|
||||||
|
import { hasValue } from '../../empty.util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders a given Bitstream as a thumbnail.
|
* This component renders a given Bitstream as a thumbnail.
|
||||||
@@ -12,7 +13,7 @@ import { Bitstream } from '../../../core/shared/bitstream.model';
|
|||||||
styleUrls: ['./grid-thumbnail.component.scss'],
|
styleUrls: ['./grid-thumbnail.component.scss'],
|
||||||
templateUrl: './grid-thumbnail.component.html'
|
templateUrl: './grid-thumbnail.component.html'
|
||||||
})
|
})
|
||||||
export class GridThumbnailComponent {
|
export class GridThumbnailComponent implements OnInit {
|
||||||
|
|
||||||
@Input() thumbnail: Bitstream;
|
@Input() thumbnail: Bitstream;
|
||||||
|
|
||||||
@@ -21,10 +22,19 @@ export class GridThumbnailComponent {
|
|||||||
/**
|
/**
|
||||||
* The default 'holder.js' image
|
* The default 'holder.js' image
|
||||||
*/
|
*/
|
||||||
holderSource = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjYwIiBoZWlnaHQ9IjE4MCIgdmlld0JveD0iMCAwIDI2MCAxODAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjwhLS0KU291cmNlIFVSTDogaG9sZGVyLmpzLzEwMCV4MTgwL3RleHQ6Tm8gVGh1bWJuYWlsCkNyZWF0ZWQgd2l0aCBIb2xkZXIuanMgMi42LjAuCkxlYXJuIG1vcmUgYXQgaHR0cDovL2hvbGRlcmpzLmNvbQooYykgMjAxMi0yMDE1IEl2YW4gTWFsb3BpbnNreSAtIGh0dHA6Ly9pbXNreS5jbwotLT48ZGVmcz48c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwhW0NEQVRBWyNob2xkZXJfMTVmNzJmMmFlMGIgdGV4dCB7IGZpbGw6I0FBQUFBQTtmb250LXdlaWdodDpib2xkO2ZvbnQtZmFtaWx5OkFyaWFsLCBIZWx2ZXRpY2EsIE9wZW4gU2Fucywgc2Fucy1zZXJpZiwgbW9ub3NwYWNlO2ZvbnQtc2l6ZToxM3B0IH0gXV0+PC9zdHlsZT48L2RlZnM+PGcgaWQ9ImhvbGRlcl8xNWY3MmYyYWUwYiI+PHJlY3Qgd2lkdGg9IjI2MCIgaGVpZ2h0PSIxODAiIGZpbGw9IiNFRUVFRUUiLz48Zz48dGV4dCB4PSI3Mi4yNDIxODc1IiB5PSI5NiI+Tm8gVGh1bWJuYWlsPC90ZXh0PjwvZz48L2c+PC9zdmc+';
|
@Input() defaultImage? = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjYwIiBoZWlnaHQ9IjE4MCIgdmlld0JveD0iMCAwIDI2MCAxODAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjwhLS0KU291cmNlIFVSTDogaG9sZGVyLmpzLzEwMCV4MTgwL3RleHQ6Tm8gVGh1bWJuYWlsCkNyZWF0ZWQgd2l0aCBIb2xkZXIuanMgMi42LjAuCkxlYXJuIG1vcmUgYXQgaHR0cDovL2hvbGRlcmpzLmNvbQooYykgMjAxMi0yMDE1IEl2YW4gTWFsb3BpbnNreSAtIGh0dHA6Ly9pbXNreS5jbwotLT48ZGVmcz48c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwhW0NEQVRBWyNob2xkZXJfMTVmNzJmMmFlMGIgdGV4dCB7IGZpbGw6I0FBQUFBQTtmb250LXdlaWdodDpib2xkO2ZvbnQtZmFtaWx5OkFyaWFsLCBIZWx2ZXRpY2EsIE9wZW4gU2Fucywgc2Fucy1zZXJpZiwgbW9ub3NwYWNlO2ZvbnQtc2l6ZToxM3B0IH0gXV0+PC9zdHlsZT48L2RlZnM+PGcgaWQ9ImhvbGRlcl8xNWY3MmYyYWUwYiI+PHJlY3Qgd2lkdGg9IjI2MCIgaGVpZ2h0PSIxODAiIGZpbGw9IiNFRUVFRUUiLz48Zz48dGV4dCB4PSI3Mi4yNDIxODc1IiB5PSI5NiI+Tm8gVGh1bWJuYWlsPC90ZXh0PjwvZz48L2c+PC9zdmc+';
|
||||||
|
|
||||||
|
src: string;
|
||||||
errorHandler(event) {
|
errorHandler(event) {
|
||||||
event.currentTarget.src = this.holderSource;
|
event.currentTarget.src = this.defaultImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
if (hasValue(this.thumbnail) && this.thumbnail.content) {
|
||||||
|
this.src = this.thumbnail.content;
|
||||||
|
} else {
|
||||||
|
this.src = this.defaultImage
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,34 @@
|
|||||||
|
<ds-truncatable [id]="dso.id">
|
||||||
|
<div class="card" [@focusShadow]="(isCollapsed() | async)?'blur':'focus'">
|
||||||
|
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
||||||
|
<div>
|
||||||
|
<ds-grid-thumbnail [thumbnail]="this.item.getThumbnail() | async">
|
||||||
|
</ds-grid-thumbnail>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="card-body">
|
||||||
|
<ds-item-type-badge [object]="object"></ds-item-type-badge>
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
<p *ngIf="dso.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])"
|
||||||
|
class="item-authors card-text text-muted">
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
|
<span *ngIf="dso.hasMetadata('dc.date.issued')" class="item-date">{{dso.firstMetadataValue('dc.date.issued')}}</span>
|
||||||
|
<span *ngFor="let author of dso.allMetadataValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);">,
|
||||||
|
<span [innerHTML]="author"></span>
|
||||||
|
</span>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
</p>
|
||||||
|
<p *ngIf="dso.hasMetadata('dc.description.abstract')" class="item-abstract card-text">
|
||||||
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
|
<span [innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
|
||||||
|
</ds-truncatable-part>
|
||||||
|
</p>
|
||||||
|
<div class="text-center">
|
||||||
|
<a [routerLink]="['/items/' + dso.id]"
|
||||||
|
class="lead btn btn-primary viewButton">View</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ds-truncatable>
|
@@ -0,0 +1,124 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||||
|
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||||
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
import { PublicationGridElementComponent } from './publication-grid-element.component';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
|
import { ITEM } from '../../../../items/switcher/item-type-switcher.component';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.contributor.author': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith, Donald'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.date.issued': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.description.abstract': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is an abstract'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PublicationGridElementComponent', getEntityGridElementTestComponent(PublicationGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract']));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create test cases for a grid component of an entity.
|
||||||
|
* @param component The component's class
|
||||||
|
* @param searchResultWithMetadata An ItemSearchResult containing an item with metadata that should be displayed in the grid element
|
||||||
|
* @param searchResultWithoutMetadata An ItemSearchResult containing an item that's missing the metadata that should be displayed in the grid element
|
||||||
|
* @param fieldsToCheck A list of fields to check. The tests expect to find html elements with class ".item-${field}", so make sure they exist in the html template of the grid element.
|
||||||
|
* For example: If one of the fields to check is labeled "authors", the html template should contain at least one element with class ".item-authors" that's
|
||||||
|
* present when the author metadata is available.
|
||||||
|
*/
|
||||||
|
export function getEntityGridElementTestComponent(component, searchResultWithMetadata: ItemSearchResult, searchResultWithoutMetadata: ItemSearchResult, fieldsToCheck: string[]) {
|
||||||
|
return () => {
|
||||||
|
let comp;
|
||||||
|
let fixture;
|
||||||
|
|
||||||
|
const truncatableServiceStub: any = {
|
||||||
|
isCollapsed: (id: number) => observableOf(true),
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [NoopAnimationsModule],
|
||||||
|
declarations: [component, TruncatePipe],
|
||||||
|
providers: [
|
||||||
|
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||||
|
{provide: ITEM, useValue: searchResultWithoutMetadata}
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).overrideComponent(component, {
|
||||||
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(component);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
}));
|
||||||
|
|
||||||
|
fieldsToCheck.forEach((field) => {
|
||||||
|
describe(`when the item has "${field}" metadata`, () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.dso = searchResultWithMetadata.indexableObject;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should show the "${field}" field`, () => {
|
||||||
|
const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`));
|
||||||
|
expect(itemAuthorField).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(`when the item has no "${field}" metadata`, () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.dso = searchResultWithoutMetadata.indexableObject;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should not show the "${field}" field`, () => {
|
||||||
|
const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`));
|
||||||
|
expect(itemAuthorField).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,18 @@
|
|||||||
|
import { TypedItemSearchResultGridElementComponent } from '../typed-item-search-result-grid-element.component';
|
||||||
|
import { DEFAULT_ITEM_TYPE, ItemViewMode, rendersItemType } from '../../../../items/item-type-decorator';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { focusShadow } from '../../../../animations/focus';
|
||||||
|
|
||||||
|
@rendersItemType('Publication', ItemViewMode.Card)
|
||||||
|
@rendersItemType(DEFAULT_ITEM_TYPE, ItemViewMode.Card)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-publication-grid-element',
|
||||||
|
styleUrls: ['./publication-grid-element.component.scss'],
|
||||||
|
templateUrl: './publication-grid-element.component.html',
|
||||||
|
animations: [focusShadow]
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying a grid element for an item of the type Publication
|
||||||
|
*/
|
||||||
|
export class PublicationGridElementComponent extends TypedItemSearchResultGridElementComponent {
|
||||||
|
}
|
@@ -0,0 +1,83 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
||||||
|
import { TruncatableService } from '../../../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 { ITEM } from '../../../items/switcher/item-type-switcher.component';
|
||||||
|
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||||
|
import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { MetadataMap } from '../../../../core/shared/metadata.models';
|
||||||
|
import { TypedItemSearchResultGridElementComponent } from './typed-item-search-result-grid-element.component';
|
||||||
|
|
||||||
|
const mockItem: Item = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []))),
|
||||||
|
metadata: [],
|
||||||
|
relationships: createRelationshipsObservable()
|
||||||
|
});
|
||||||
|
const mockSearchResult = {
|
||||||
|
indexableObject: mockItem as Item,
|
||||||
|
hitHighlights: new MetadataMap()
|
||||||
|
} as ItemSearchResult;
|
||||||
|
|
||||||
|
describe('TypedItemSearchResultGridElementComponent', () => {
|
||||||
|
let comp: TypedItemSearchResultGridElementComponent;
|
||||||
|
let fixture: ComponentFixture<TypedItemSearchResultGridElementComponent>;
|
||||||
|
|
||||||
|
describe('when injecting an Item', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [TypedItemSearchResultGridElementComponent, TruncatePipe],
|
||||||
|
providers: [
|
||||||
|
{provide: TruncatableService, useValue: {}},
|
||||||
|
{provide: ITEM, useValue: mockItem}
|
||||||
|
],
|
||||||
|
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).overrideComponent(TypedItemSearchResultGridElementComponent, {
|
||||||
|
set: {changeDetection: ChangeDetectionStrategy.Default}
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(TypedItemSearchResultGridElementComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should initiate item, object and dso correctly', () => {
|
||||||
|
expect(comp.item).toBe(mockItem);
|
||||||
|
expect(comp.dso).toBe(mockItem);
|
||||||
|
expect(comp.object.indexableObject).toBe(mockItem);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when injecting an ItemSearchResult', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [TypedItemSearchResultGridElementComponent, TruncatePipe],
|
||||||
|
providers: [
|
||||||
|
{provide: TruncatableService, useValue: {}},
|
||||||
|
{provide: ITEM, useValue: mockSearchResult}
|
||||||
|
],
|
||||||
|
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).overrideComponent(TypedItemSearchResultGridElementComponent, {
|
||||||
|
set: {changeDetection: ChangeDetectionStrategy.Default}
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(TypedItemSearchResultGridElementComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should initiate item, object and dso correctly', () => {
|
||||||
|
expect(comp.item).toBe(mockItem);
|
||||||
|
expect(comp.dso).toBe(mockItem);
|
||||||
|
expect(comp.object.indexableObject).toBe(mockItem);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,37 @@
|
|||||||
|
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { SearchResultGridElementComponent } from '../../search-result-grid-element/search-result-grid-element.component';
|
||||||
|
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||||
|
import { Component, Inject } from '@angular/core';
|
||||||
|
import { ITEM } from '../../../items/switcher/item-type-switcher.component';
|
||||||
|
import { hasValue } from '../../../empty.util';
|
||||||
|
import { MetadataMap } from '../../../../core/shared/metadata.models';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A generic component for displaying item grid elements
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-item-search-result-grid-element',
|
||||||
|
template: ''
|
||||||
|
})
|
||||||
|
export class TypedItemSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
|
||||||
|
item: Item;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
protected truncatableService: TruncatableService,
|
||||||
|
@Inject(ITEM) public obj: Item | ItemSearchResult,
|
||||||
|
) {
|
||||||
|
super(undefined, truncatableService);
|
||||||
|
if (hasValue((obj as any).indexableObject)) {
|
||||||
|
this.object = obj as ItemSearchResult;
|
||||||
|
this.dso = this.object.indexableObject;
|
||||||
|
} else {
|
||||||
|
this.object = {
|
||||||
|
indexableObject: obj as Item,
|
||||||
|
hitHighlights: new MetadataMap()
|
||||||
|
};
|
||||||
|
this.dso = obj as Item;
|
||||||
|
}
|
||||||
|
this.item = this.dso;
|
||||||
|
}
|
||||||
|
}
|
@@ -4,6 +4,11 @@ ds-wrapper-grid-element ::ng-deep {
|
|||||||
div.thumbnail > img {
|
div.thumbnail > img {
|
||||||
height: $card-thumbnail-height;
|
height: $card-thumbnail-height;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: block;
|
||||||
|
min-width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
object-position: 50% 15%;
|
||||||
}
|
}
|
||||||
div.card {
|
div.card {
|
||||||
margin-top: $ds-wrapper-grid-spacing;
|
margin-top: $ds-wrapper-grid-spacing;
|
||||||
|
@@ -1,33 +1 @@
|
|||||||
<ds-truncatable [id]="dso.id">
|
<ds-item-type-switcher [object]="object" [viewMode]="viewMode"></ds-item-type-switcher>
|
||||||
<div class="card" [@focusShadow]="(isCollapsed() | async)?'blur':'focus'">
|
|
||||||
<a [routerLink]="['/items/' + dso.id]" class="card-img-top full-width">
|
|
||||||
<div>
|
|
||||||
<ds-grid-thumbnail [thumbnail]="dso.getThumbnail()">
|
|
||||||
</ds-grid-thumbnail>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<div class="card-body">
|
|
||||||
<ds-truncatable-part [fixedHeight]="true" [id]="dso.id" [minLines]="3" type="h4">
|
|
||||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
|
||||||
</ds-truncatable-part>
|
|
||||||
<p *ngIf="dso.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])"
|
|
||||||
class="item-authors card-text text-muted">
|
|
||||||
<ds-truncatable-part [fixedHeight]="true" [id]="dso.id" [minLines]="1">
|
|
||||||
<span *ngIf="dso.hasMetadata('dc.date.issued')" class="item-date">{{dso.firstMetadataValue('dc.date.issued')}}</span>
|
|
||||||
<span *ngFor="let author of dso.allMetadataValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);">,
|
|
||||||
<span [innerHTML]="author"></span>
|
|
||||||
</span>
|
|
||||||
</ds-truncatable-part>
|
|
||||||
</p>
|
|
||||||
<p class="item-abstract card-text">
|
|
||||||
<ds-truncatable-part [fixedHeight]="true" [id]="dso.id" [minLines]="3">
|
|
||||||
<span [innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
|
|
||||||
</ds-truncatable-part>
|
|
||||||
</p>
|
|
||||||
<div class="text-center">
|
|
||||||
<a [routerLink]="['/items/' + dso.id]"
|
|
||||||
class="lead btn btn-primary viewButton">View</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ds-truncatable>
|
|
||||||
|
@@ -8,6 +8,7 @@ import { Item } from '../../../../core/shared/item.model';
|
|||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||||
|
import { ItemViewMode } from '../../../items/item-type-decorator';
|
||||||
|
|
||||||
let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
|
let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
|
||||||
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
|
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
|
||||||
@@ -16,41 +17,17 @@ const truncatableServiceStub: any = {
|
|||||||
isCollapsed: (id: number) => observableOf(true),
|
isCollapsed: (id: number) => observableOf(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
const type = 'authorOfPublication';
|
||||||
mockItemWithAuthorAndDate.hitHighlights = {};
|
|
||||||
mockItemWithAuthorAndDate.indexableObject = Object.assign(new Item(), {
|
|
||||||
bitstreams: observableOf({}),
|
|
||||||
metadata: {
|
|
||||||
'dc.contributor.author': [
|
|
||||||
{
|
|
||||||
language: 'en_US',
|
|
||||||
value: 'Smith, Donald'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'dc.date.issued': [
|
|
||||||
{
|
|
||||||
language: null,
|
|
||||||
value: '2015-06-26'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||||
mockItemWithoutAuthorAndDate.hitHighlights = {};
|
mockItemWithRelationshipType.hitHighlights = {};
|
||||||
mockItemWithoutAuthorAndDate.indexableObject = Object.assign(new Item(), {
|
mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||||
bitstreams: observableOf({}),
|
bitstreams: observableOf({}),
|
||||||
metadata: {
|
metadata: {
|
||||||
'dc.title': [
|
'relationship.type': [
|
||||||
{
|
{
|
||||||
language: 'en_US',
|
language: 'en_US',
|
||||||
value: 'This is just another title'
|
value: type
|
||||||
}
|
|
||||||
],
|
|
||||||
'dc.type': [
|
|
||||||
{
|
|
||||||
language: null,
|
|
||||||
value: 'Article'
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -63,7 +40,7 @@ describe('ItemSearchResultGridElementComponent', () => {
|
|||||||
declarations: [ItemSearchResultGridElementComponent, TruncatePipe],
|
declarations: [ItemSearchResultGridElementComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||||
{ provide: 'objectElementProvider', useValue: (mockItemWithoutAuthorAndDate) }
|
{ provide: 'objectElementProvider', useValue: (mockItemWithRelationshipType) }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(ItemSearchResultGridElementComponent, {
|
}).overrideComponent(ItemSearchResultGridElementComponent, {
|
||||||
@@ -76,51 +53,9 @@ describe('ItemSearchResultGridElementComponent', () => {
|
|||||||
itemSearchResultGridElementComponent = fixture.componentInstance;
|
itemSearchResultGridElementComponent = fixture.componentInstance;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('When the item has an author', () => {
|
it('should show send the object to item-type-switcher using viewMode "Card"', () => {
|
||||||
beforeEach(() => {
|
const itemTypeSwitcherComp = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance;
|
||||||
itemSearchResultGridElementComponent.dso = mockItemWithAuthorAndDate.indexableObject;
|
expect(itemTypeSwitcherComp.object).toBe(mockItemWithRelationshipType);
|
||||||
fixture.detectChanges();
|
expect(itemTypeSwitcherComp.viewMode).toEqual(ItemViewMode.Card);
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the author paragraph', () => {
|
|
||||||
const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors'));
|
|
||||||
expect(itemAuthorField).not.toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('When the item has no author', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
itemSearchResultGridElementComponent.dso = mockItemWithoutAuthorAndDate.indexableObject;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show the author paragraph', () => {
|
|
||||||
const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors'));
|
|
||||||
expect(itemAuthorField).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('When the item has an issuedate', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
itemSearchResultGridElementComponent.dso = mockItemWithAuthorAndDate.indexableObject;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the issuedate span', () => {
|
|
||||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-date'));
|
|
||||||
expect(itemAuthorField).not.toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('When the item has no issuedate', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
itemSearchResultGridElementComponent.dso = mockItemWithoutAuthorAndDate.indexableObject;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show the issuedate span', () => {
|
|
||||||
const dateField = fixture.debugElement.query(By.css('span.item-date'));
|
|
||||||
expect(dateField).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -6,6 +6,7 @@ import { Item } from '../../../../core/shared/item.model';
|
|||||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||||
import { SetViewMode } from '../../../view-mode';
|
import { SetViewMode } from '../../../view-mode';
|
||||||
import { focusShadow } from '../../../../shared/animations/focus';
|
import { focusShadow } from '../../../../shared/animations/focus';
|
||||||
|
import { ItemViewMode } from '../../../items/item-type-decorator';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item-search-result-grid-element',
|
selector: 'ds-item-search-result-grid-element',
|
||||||
@@ -15,4 +16,6 @@ import { focusShadow } from '../../../../shared/animations/focus';
|
|||||||
})
|
})
|
||||||
|
|
||||||
@renderElementsFor(ItemSearchResult, SetViewMode.Grid)
|
@renderElementsFor(ItemSearchResult, SetViewMode.Grid)
|
||||||
export class ItemSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {}
|
export class ItemSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> {
|
||||||
|
viewMode = ItemViewMode.Card;
|
||||||
|
}
|
||||||
|
@@ -7,6 +7,7 @@ import { ListableObject } from '../../object-collection/shared/listable-object.m
|
|||||||
import { TruncatableService } from '../../truncatable/truncatable.service';
|
import { TruncatableService } from '../../truncatable/truncatable.service';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { Metadata } from '../../../core/shared/metadata.utils';
|
import { Metadata } from '../../../core/shared/metadata.utils';
|
||||||
|
import { hasValue } from '../../empty.util';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-result-grid-element',
|
selector: 'ds-search-result-grid-element',
|
||||||
@@ -16,9 +17,11 @@ import { Metadata } from '../../../core/shared/metadata.utils';
|
|||||||
export class SearchResultGridElementComponent<T extends SearchResult<K>, K extends DSpaceObject> extends AbstractListableElementComponent<T> {
|
export class SearchResultGridElementComponent<T extends SearchResult<K>, K extends DSpaceObject> extends AbstractListableElementComponent<T> {
|
||||||
dso: K;
|
dso: K;
|
||||||
|
|
||||||
public constructor(@Inject('objectElementProvider') public listableObject: ListableObject, private truncatableService: TruncatableService) {
|
public constructor(@Inject('objectElementProvider') public listableObject: ListableObject, protected truncatableService: TruncatableService) {
|
||||||
super(listableObject);
|
super(listableObject);
|
||||||
this.dso = this.object.indexableObject;
|
if (hasValue(this.object)) {
|
||||||
|
this.dso = this.object.indexableObject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -24,7 +24,7 @@ const mockSearchResult = {
|
|||||||
hitHighlights: new MetadataMap()
|
hitHighlights: new MetadataMap()
|
||||||
} as ItemSearchResult;
|
} as ItemSearchResult;
|
||||||
|
|
||||||
describe('ItemSearchResultComponent', () => {
|
describe('TypedItemSearchResultListElementComponent', () => {
|
||||||
let comp: TypedItemSearchResultListElementComponent;
|
let comp: TypedItemSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<TypedItemSearchResultListElementComponent>;
|
let fixture: ComponentFixture<TypedItemSearchResultListElementComponent>;
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ import { MetadataMap } from '../../../../core/shared/metadata.models';
|
|||||||
* A generic component for displaying item list elements
|
* A generic component for displaying item list elements
|
||||||
*/
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item-search-result',
|
selector: 'ds-item-search-result-list-element',
|
||||||
template: ''
|
template: ''
|
||||||
})
|
})
|
||||||
export class TypedItemSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
|
export class TypedItemSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
|
||||||
|
@@ -0,0 +1,3 @@
|
|||||||
|
<div *ngIf="object && object.indexableObject && object.indexableObject.firstMetadataValue('relationship.type') as type">
|
||||||
|
<span class="badge badge-light">{{ type.toLowerCase() + '.listelement.badge' | translate }}</span>
|
||||||
|
</div>
|
@@ -0,0 +1,83 @@
|
|||||||
|
import { ItemSearchResult } from '../../object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../core/shared/item.model';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { TruncatePipe } from '../../utils/truncate.pipe';
|
||||||
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { ItemTypeBadgeComponent } from './item-type-badge.component';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
|
let comp: ItemTypeBadgeComponent;
|
||||||
|
let fixture: ComponentFixture<ItemTypeBadgeComponent>;
|
||||||
|
|
||||||
|
const type = 'authorOfPublication';
|
||||||
|
|
||||||
|
const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithRelationshipType.hitHighlights = {};
|
||||||
|
mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'relationship.type': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: type
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutRelationshipType.hitHighlights = {};
|
||||||
|
mockItemWithoutRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('ItemTypeBadgeComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot()],
|
||||||
|
declarations: [ItemTypeBadgeComponent, TruncatePipe],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).overrideComponent(ItemTypeBadgeComponent, {
|
||||||
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(ItemTypeBadgeComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('When the item has a relationship type', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.object = mockItemWithRelationshipType;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show the relationship type badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('span.badge'));
|
||||||
|
expect(badge.nativeElement.textContent).toContain(type.toLowerCase());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When the item has no relationship type', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.object = mockItemWithoutRelationshipType;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show a badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('span.badge'));
|
||||||
|
expect(badge).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,12 @@
|
|||||||
|
import { Component, Input } from '@angular/core';
|
||||||
|
import { ListableObject } from '../../object-collection/shared/listable-object.model';
|
||||||
|
import { SearchResult } from '../../../+search-page/search-result.model';
|
||||||
|
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-item-type-badge',
|
||||||
|
templateUrl: './item-type-badge.component.html'
|
||||||
|
})
|
||||||
|
export class ItemTypeBadgeComponent {
|
||||||
|
@Input() object: SearchResult<DSpaceObject>;
|
||||||
|
}
|
@@ -1,4 +1,2 @@
|
|||||||
<div *ngIf="object && object.indexableObject && object.indexableObject.firstMetadataValue('relationship.type') as type">
|
<ds-item-type-badge [object]="object"></ds-item-type-badge>
|
||||||
<span class="badge badge-light">{{ type.toLowerCase() + '.listelement.badge' | translate }}</span>
|
|
||||||
</div>
|
|
||||||
<ds-item-type-switcher [object]="object" [viewMode]="viewMode"></ds-item-type-switcher>
|
<ds-item-type-switcher [object]="object" [viewMode]="viewMode"></ds-item-type-switcher>
|
||||||
|
@@ -33,20 +33,6 @@ mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockItemWithoutRelationshipType: ItemSearchResult = new ItemSearchResult();
|
|
||||||
mockItemWithoutRelationshipType.hitHighlights = {};
|
|
||||||
mockItemWithoutRelationshipType.indexableObject = Object.assign(new Item(), {
|
|
||||||
bitstreams: observableOf({}),
|
|
||||||
metadata: {
|
|
||||||
'dc.title': [
|
|
||||||
{
|
|
||||||
language: 'en_US',
|
|
||||||
value: 'This is just another title'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('ItemSearchResultListElementComponent', () => {
|
describe('ItemSearchResultListElementComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -54,7 +40,7 @@ describe('ItemSearchResultListElementComponent', () => {
|
|||||||
declarations: [ItemSearchResultListElementComponent, TruncatePipe],
|
declarations: [ItemSearchResultListElementComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||||
{ provide: 'objectElementProvider', useValue: (mockItemWithoutRelationshipType) }
|
{ provide: 'objectElementProvider', useValue: (mockItemWithRelationshipType) }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(ItemSearchResultListElementComponent, {
|
}).overrideComponent(ItemSearchResultListElementComponent, {
|
||||||
@@ -67,27 +53,8 @@ describe('ItemSearchResultListElementComponent', () => {
|
|||||||
itemSearchResultListElementComponent = fixture.componentInstance;
|
itemSearchResultListElementComponent = fixture.componentInstance;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('When the item has a relationship type', () => {
|
it('should show a badge on top of the list element', () => {
|
||||||
beforeEach(() => {
|
const badge = fixture.debugElement.query(By.css('ds-item-type-badge')).componentInstance;
|
||||||
itemSearchResultListElementComponent.object = mockItemWithRelationshipType;
|
expect(badge.object).toBe(mockItemWithRelationshipType);
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the relationship type badge', () => {
|
|
||||||
const badge = fixture.debugElement.query(By.css('span.badge'));
|
|
||||||
expect(badge.nativeElement.textContent).toContain(type.toLowerCase());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('When the item has no relationship type', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
itemSearchResultListElementComponent.object = mockItemWithoutRelationshipType;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show a badge', () => {
|
|
||||||
const badge = fixture.debugElement.query(By.css('span.badge'));
|
|
||||||
expect(badge).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -138,6 +138,9 @@ import { RoleDirective } from './roles/role.directive';
|
|||||||
import { UserMenuComponent } from './auth-nav-menu/user-menu/user-menu.component';
|
import { UserMenuComponent } from './auth-nav-menu/user-menu/user-menu.component';
|
||||||
import { ClaimedTaskActionsReturnToPoolComponent } from './mydspace-actions/claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component';
|
import { ClaimedTaskActionsReturnToPoolComponent } from './mydspace-actions/claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component';
|
||||||
import { ItemDetailPreviewFieldComponent } from './object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component';
|
import { ItemDetailPreviewFieldComponent } from './object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component';
|
||||||
|
import { TypedItemSearchResultGridElementComponent } from './object-grid/item-grid-element/item-types/typed-item-search-result-grid-element.component';
|
||||||
|
import { PublicationGridElementComponent } from './object-grid/item-grid-element/item-types/publication/publication-grid-element.component';
|
||||||
|
import { ItemTypeBadgeComponent } from './object-list/item-type-badge/item-type-badge.component';
|
||||||
|
|
||||||
const MODULES = [
|
const MODULES = [
|
||||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||||
@@ -256,8 +259,10 @@ const COMPONENTS = [
|
|||||||
CollectionSearchResultListElementComponent,
|
CollectionSearchResultListElementComponent,
|
||||||
ItemSearchResultListElementComponent,
|
ItemSearchResultListElementComponent,
|
||||||
TypedItemSearchResultListElementComponent,
|
TypedItemSearchResultListElementComponent,
|
||||||
|
TypedItemSearchResultGridElementComponent,
|
||||||
ItemTypeSwitcherComponent,
|
ItemTypeSwitcherComponent,
|
||||||
BrowseByComponent
|
BrowseByComponent,
|
||||||
|
ItemTypeBadgeComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
@@ -275,6 +280,7 @@ const ENTRY_COMPONENTS = [
|
|||||||
CommunityGridElementComponent,
|
CommunityGridElementComponent,
|
||||||
SearchResultGridElementComponent,
|
SearchResultGridElementComponent,
|
||||||
PublicationListElementComponent,
|
PublicationListElementComponent,
|
||||||
|
PublicationGridElementComponent,
|
||||||
BrowseEntryListElementComponent,
|
BrowseEntryListElementComponent,
|
||||||
MyDSpaceResultDetailElementComponent,
|
MyDSpaceResultDetailElementComponent,
|
||||||
SearchResultGridElementComponent,
|
SearchResultGridElementComponent,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
@import 'src/app/+item-page/simple/item-types/journal-issue/journal-issue.component.scss';
|
@import 'src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.scss';
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
> * {
|
> * {
|
@@ -1,4 +1,4 @@
|
|||||||
@import 'src/app/+item-page/simple/item-types/journal-volume/journal-volume.component.scss';
|
@import 'src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.scss';
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
> * {
|
> * {
|
@@ -1,4 +1,4 @@
|
|||||||
@import 'src/app/+item-page/simple/item-types/journal/journal.component.scss';
|
@import 'src/app/entity-groups/journal-entities/item-pages/journal/journal.component.scss';
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
> * {
|
> * {
|
@@ -1,4 +1,4 @@
|
|||||||
@import 'src/app/+item-page/simple/item-types/orgunit/orgunit.component.scss';
|
@import 'src/app/entity-groups/research-entities/item-pages/orgunit/orgunit.component.scss';
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
> * {
|
> * {
|
@@ -1,4 +1,4 @@
|
|||||||
@import 'src/app/+item-page/simple/item-types/person/person.component.scss';
|
@import 'src/app/entity-groups/research-entities/item-pages/person/person.component.scss';
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
> * {
|
> * {
|
@@ -1,4 +1,4 @@
|
|||||||
@import 'src/app/+item-page/simple/item-types/project/project.component.scss';
|
@import 'src/app/entity-groups/research-entities/item-pages/project/project.component.scss';
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
> * {
|
> * {
|
Reference in New Issue
Block a user