Skip to content

Commit 0c9baf2

Browse files
authored
Merge pull request DSpace#2250 from damian-joz/1787-coll-comm-item-counts
Displaying item counts at Communities and Collections list view.
2 parents 25ca137 + 8bcceff commit 0c9baf2

6 files changed

Lines changed: 65 additions & 4 deletions

File tree

src/app/community-list-page/community-list/community-list.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ <h5 class="align-middle pt-2">
3737
<a [routerLink]="node.route" class="lead">
3838
{{ dsoNameService.getName(node.payload) }}
3939
</a>
40+
<span *ngIf="node.payload.archivedItemsCount >= 0" class="archived-items-lead">[{{node.payload.archivedItemsCount}}]</span>
4041
</h5>
4142
</div>
4243
<ds-truncatable [id]="node.id">

src/app/core/shared/collection.model.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { deserialize, inheritSerialization } from 'cerialize';
1+
import {autoserialize, deserialize, inheritSerialization} from 'cerialize';
22
import { Observable } from 'rxjs';
33
import { link, typedObject } from '../cache/builders/build-decorators';
44
import { PaginatedList } from '../data/paginated-list.model';
@@ -16,12 +16,17 @@ import { COMMUNITY } from './community.resource-type';
1616
import { Community } from './community.model';
1717
import { ChildHALResource } from './child-hal-resource.model';
1818
import { HandleObject } from './handle-object.model';
19+
import { excludeFromEquals } from '../utilities/equals.decorators';
1920

2021
@typedObject
2122
@inheritSerialization(DSpaceObject)
2223
export class Collection extends DSpaceObject implements ChildHALResource, HandleObject {
2324
static type = COLLECTION;
2425

26+
@excludeFromEquals
27+
@autoserialize
28+
archivedItemsCount: number;
29+
2530
/**
2631
* The {@link HALLink}s for this Collection
2732
*/

src/app/core/shared/community.model.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { deserialize, inheritSerialization } from 'cerialize';
1+
import {autoserialize, deserialize, inheritSerialization} from 'cerialize';
22
import { Observable } from 'rxjs';
33
import { link, typedObject } from '../cache/builders/build-decorators';
44
import { PaginatedList } from '../data/paginated-list.model';
@@ -12,12 +12,17 @@ import { DSpaceObject } from './dspace-object.model';
1212
import { HALLink } from './hal-link.model';
1313
import { ChildHALResource } from './child-hal-resource.model';
1414
import { HandleObject } from './handle-object.model';
15+
import {excludeFromEquals} from '../utilities/equals.decorators';
1516

1617
@typedObject
1718
@inheritSerialization(DSpaceObject)
1819
export class Community extends DSpaceObject implements ChildHALResource, HandleObject {
1920
static type = COMMUNITY;
2021

22+
@excludeFromEquals
23+
@autoserialize
24+
archivedItemsCount: number;
25+
2126
/**
2227
* The {@link HALLink}s for this Community
2328
*/

src/app/shared/object-list/collection-list-element/collection-list-element.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<span *ngIf="linkType == linkTypes.None" class="lead">
55
{{ dsoNameService.getName(object) }}
66
</span>
7+
<span *ngIf="object.archivedItemsCount >= 0" class="lead archived-items-lead">[{{object.archivedItemsCount}}]</span>
78
<div *ngIf="object.shortDescription" class="text-muted abstract-text">
89
{{object.shortDescription}}
910
</div>

src/app/shared/object-list/collection-list-element/collection-list-element.component.spec.ts

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ import { DSONameServiceMock } from '../../mocks/dso-name.service.mock';
99
let collectionListElementComponent: CollectionListElementComponent;
1010
let fixture: ComponentFixture<CollectionListElementComponent>;
1111

12+
const mockCollectionWithArchivedItems: Collection = Object.assign(new Collection(), {
13+
metadata: {
14+
'dc.title': [
15+
{
16+
language: 'en_US',
17+
value: 'Test title'
18+
}
19+
]
20+
}, archivedItemsCount: 1
21+
});
22+
23+
const mockCollectionWithArchivedItemsDisabledAtBackend: Collection = Object.assign(new Collection(), {
24+
metadata: {
25+
'dc.title': [
26+
{
27+
language: 'en_US',
28+
value: 'Test title'
29+
}
30+
]
31+
}, archivedItemsCount: -1
32+
});
33+
34+
1235
const mockCollectionWithAbstract: Collection = Object.assign(new Collection(), {
1336
metadata: {
1437
'dc.description.abstract': [
@@ -17,7 +40,7 @@ const mockCollectionWithAbstract: Collection = Object.assign(new Collection(), {
1740
value: 'Short description'
1841
}
1942
]
20-
}
43+
}, archivedItemsCount: 1
2144
});
2245

2346
const mockCollectionWithoutAbstract: Collection = Object.assign(new Collection(), {
@@ -28,7 +51,7 @@ const mockCollectionWithoutAbstract: Collection = Object.assign(new Collection()
2851
value: 'Test title'
2952
}
3053
]
31-
}
54+
}, archivedItemsCount: 1
3255
});
3356

3457
describe('CollectionListElementComponent', () => {
@@ -74,4 +97,29 @@ describe('CollectionListElementComponent', () => {
7497
expect(collectionAbstractField).toBeNull();
7598
});
7699
});
100+
101+
102+
describe('When the collection has archived items', () => {
103+
beforeEach(() => {
104+
collectionListElementComponent.object = mockCollectionWithArchivedItems;
105+
fixture.detectChanges();
106+
});
107+
108+
it('should show the archived items paragraph', () => {
109+
const field = fixture.debugElement.query(By.css('span.archived-items-lead'));
110+
expect(field).not.toBeNull();
111+
});
112+
});
113+
114+
describe('When the collection archived items are disabled at backend', () => {
115+
beforeEach(() => {
116+
collectionListElementComponent.object = mockCollectionWithArchivedItemsDisabledAtBackend;
117+
fixture.detectChanges();
118+
});
119+
120+
it('should not show the archived items paragraph', () => {
121+
const field = fixture.debugElement.query(By.css('span.archived-items-lead'));
122+
expect(field).toBeNull();
123+
});
124+
});
77125
});

src/app/shared/object-list/community-list-element/community-list-element.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<span *ngIf="linkType == linkTypes.None" class="lead">
55
{{ dsoNameService.getName(object) }}
66
</span>
7+
<span *ngIf="object.archivedItemsCount >= 0" class="lead archived-items-lead">[{{object.archivedItemsCount}}]</span>
78
<div *ngIf="object.shortDescription" class="text-muted abstract-text">
89
{{object.shortDescription}}
910
</div>

0 commit comments

Comments
 (0)