mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #2250 from damian-joz/1787-coll-comm-item-counts
Displaying item counts at Communities and Collections list view.
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
<a [routerLink]="node.route" class="lead">
|
||||
{{ dsoNameService.getName(node.payload) }}
|
||||
</a>
|
||||
<span *ngIf="node.payload.archivedItemsCount >= 0" class="archived-items-lead">[{{node.payload.archivedItemsCount}}]</span>
|
||||
</h5>
|
||||
</div>
|
||||
<ds-truncatable [id]="node.id">
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { deserialize, inheritSerialization } from 'cerialize';
|
||||
import {autoserialize, deserialize, inheritSerialization} from 'cerialize';
|
||||
import { Observable } from 'rxjs';
|
||||
import { link, typedObject } from '../cache/builders/build-decorators';
|
||||
import { PaginatedList } from '../data/paginated-list.model';
|
||||
@@ -16,12 +16,17 @@ import { COMMUNITY } from './community.resource-type';
|
||||
import { Community } from './community.model';
|
||||
import { ChildHALResource } from './child-hal-resource.model';
|
||||
import { HandleObject } from './handle-object.model';
|
||||
import { excludeFromEquals } from '../utilities/equals.decorators';
|
||||
|
||||
@typedObject
|
||||
@inheritSerialization(DSpaceObject)
|
||||
export class Collection extends DSpaceObject implements ChildHALResource, HandleObject {
|
||||
static type = COLLECTION;
|
||||
|
||||
@excludeFromEquals
|
||||
@autoserialize
|
||||
archivedItemsCount: number;
|
||||
|
||||
/**
|
||||
* The {@link HALLink}s for this Collection
|
||||
*/
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { deserialize, inheritSerialization } from 'cerialize';
|
||||
import {autoserialize, deserialize, inheritSerialization} from 'cerialize';
|
||||
import { Observable } from 'rxjs';
|
||||
import { link, typedObject } from '../cache/builders/build-decorators';
|
||||
import { PaginatedList } from '../data/paginated-list.model';
|
||||
@@ -12,12 +12,17 @@ import { DSpaceObject } from './dspace-object.model';
|
||||
import { HALLink } from './hal-link.model';
|
||||
import { ChildHALResource } from './child-hal-resource.model';
|
||||
import { HandleObject } from './handle-object.model';
|
||||
import {excludeFromEquals} from '../utilities/equals.decorators';
|
||||
|
||||
@typedObject
|
||||
@inheritSerialization(DSpaceObject)
|
||||
export class Community extends DSpaceObject implements ChildHALResource, HandleObject {
|
||||
static type = COMMUNITY;
|
||||
|
||||
@excludeFromEquals
|
||||
@autoserialize
|
||||
archivedItemsCount: number;
|
||||
|
||||
/**
|
||||
* The {@link HALLink}s for this Community
|
||||
*/
|
||||
|
@@ -4,6 +4,7 @@
|
||||
<span *ngIf="linkType == linkTypes.None" class="lead">
|
||||
{{ dsoNameService.getName(object) }}
|
||||
</span>
|
||||
<span *ngIf="object.archivedItemsCount >= 0" class="lead archived-items-lead">[{{object.archivedItemsCount}}]</span>
|
||||
<div *ngIf="object.shortDescription" class="text-muted abstract-text">
|
||||
{{object.shortDescription}}
|
||||
</div>
|
||||
|
@@ -9,6 +9,29 @@ import { DSONameServiceMock } from '../../mocks/dso-name.service.mock';
|
||||
let collectionListElementComponent: CollectionListElementComponent;
|
||||
let fixture: ComponentFixture<CollectionListElementComponent>;
|
||||
|
||||
const mockCollectionWithArchivedItems: Collection = Object.assign(new Collection(), {
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'Test title'
|
||||
}
|
||||
]
|
||||
}, archivedItemsCount: 1
|
||||
});
|
||||
|
||||
const mockCollectionWithArchivedItemsDisabledAtBackend: Collection = Object.assign(new Collection(), {
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'Test title'
|
||||
}
|
||||
]
|
||||
}, archivedItemsCount: -1
|
||||
});
|
||||
|
||||
|
||||
const mockCollectionWithAbstract: Collection = Object.assign(new Collection(), {
|
||||
metadata: {
|
||||
'dc.description.abstract': [
|
||||
@@ -17,7 +40,7 @@ const mockCollectionWithAbstract: Collection = Object.assign(new Collection(), {
|
||||
value: 'Short description'
|
||||
}
|
||||
]
|
||||
}
|
||||
}, archivedItemsCount: 1
|
||||
});
|
||||
|
||||
const mockCollectionWithoutAbstract: Collection = Object.assign(new Collection(), {
|
||||
@@ -28,7 +51,7 @@ const mockCollectionWithoutAbstract: Collection = Object.assign(new Collection()
|
||||
value: 'Test title'
|
||||
}
|
||||
]
|
||||
}
|
||||
}, archivedItemsCount: 1
|
||||
});
|
||||
|
||||
describe('CollectionListElementComponent', () => {
|
||||
@@ -74,4 +97,29 @@ describe('CollectionListElementComponent', () => {
|
||||
expect(collectionAbstractField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('When the collection has archived items', () => {
|
||||
beforeEach(() => {
|
||||
collectionListElementComponent.object = mockCollectionWithArchivedItems;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the archived items paragraph', () => {
|
||||
const field = fixture.debugElement.query(By.css('span.archived-items-lead'));
|
||||
expect(field).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the collection archived items are disabled at backend', () => {
|
||||
beforeEach(() => {
|
||||
collectionListElementComponent.object = mockCollectionWithArchivedItemsDisabledAtBackend;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the archived items paragraph', () => {
|
||||
const field = fixture.debugElement.query(By.css('span.archived-items-lead'));
|
||||
expect(field).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -4,6 +4,7 @@
|
||||
<span *ngIf="linkType == linkTypes.None" class="lead">
|
||||
{{ dsoNameService.getName(object) }}
|
||||
</span>
|
||||
<span *ngIf="object.archivedItemsCount >= 0" class="lead archived-items-lead">[{{object.archivedItemsCount}}]</span>
|
||||
<div *ngIf="object.shortDescription" class="text-muted abstract-text">
|
||||
{{object.shortDescription}}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user