Skip to content

Commit 2e6b1cc

Browse files
committed
Added Curate tab in Edit Item page
1 parent 4847fc6 commit 2e6b1cc

6 files changed

Lines changed: 126 additions & 2 deletions

File tree

src/app/item-page/edit-item-page/edit-item-page.module.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { IdentifierDataService } from '../../core/data/identifier-data.service';
3838
import { IdentifierDataComponent } from '../../shared/object-list/identifier-data/identifier-data.component';
3939
import { ItemRegisterDoiComponent } from './item-register-doi/item-register-doi.component';
4040
import { DsoSharedModule } from '../../dso-shared/dso-shared.module';
41-
41+
import { ItemCurateComponent } from './item-curate/item-curate.component';
4242

4343
/**
4444
* Module that contains all components related to the Edit Item page administrator functionality
@@ -81,7 +81,8 @@ import { DsoSharedModule } from '../../dso-shared/dso-shared.module';
8181
VirtualMetadataComponent,
8282
ItemAuthorizationsComponent,
8383
IdentifierDataComponent,
84-
ItemRegisterDoiComponent
84+
ItemRegisterDoiComponent,
85+
ItemCurateComponent
8586
],
8687
providers: [
8788
BundleDataService,

src/app/item-page/edit-item-page/edit-item-page.routing.module.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { ItemPageVersionHistoryGuard } from './item-page-version-history.guard';
4141
import { ItemPageCollectionMapperGuard } from './item-page-collection-mapper.guard';
4242
import { ThemedDsoEditMetadataComponent } from '../../dso-shared/dso-edit-metadata/themed-dso-edit-metadata.component';
4343
import { ItemPageRegisterDoiGuard } from './item-page-register-doi.guard';
44+
import { ItemCurateComponent } from './item-curate/item-curate.component';
4445

4546
/**
4647
* Routing module that handles the routing for the Edit Item page administrator functionality
@@ -82,6 +83,11 @@ import { ItemPageRegisterDoiGuard } from './item-page-register-doi.guard';
8283
data: { title: 'item.edit.tabs.metadata.title', showBreadcrumbs: true },
8384
canActivate: [ItemPageMetadataGuard]
8485
},
86+
{
87+
path: 'curate',
88+
component: ItemCurateComponent,
89+
data: { title: 'item.edit.tabs.curate.title', showBreadcrumbs: true }
90+
},
8591
{
8692
path: 'relationships',
8793
component: ItemRelationshipsComponent,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="container mt-3">
2+
<h3>{{'item.edit.curate.title' |translate:{item: (itemName$ |async)} }}</h3>
3+
<ds-curation-form
4+
[dsoHandle]="(dsoRD$|async)?.payload.handle"
5+
></ds-curation-form>
6+
</div>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2+
import { TranslateModule } from '@ngx-translate/core';
3+
import { CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
4+
import { ItemCurateComponent } from './item-curate.component';
5+
import { of as observableOf } from 'rxjs';
6+
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
7+
import { ActivatedRoute } from '@angular/router';
8+
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
9+
import { Item } from '../../../core/shared/item.model';
10+
11+
fdescribe('ItemCurateComponent', () => {
12+
let comp: ItemCurateComponent;
13+
let fixture: ComponentFixture<ItemCurateComponent>;
14+
let debugEl: DebugElement;
15+
16+
let routeStub;
17+
let dsoNameService;
18+
19+
const item = Object.assign(new Item(), {
20+
handle: '123456789/1',
21+
metadata: {'dc.title': ['Item Name']}
22+
});
23+
24+
beforeEach(waitForAsync(() => {
25+
routeStub = {
26+
parent: {
27+
data: observableOf({
28+
dso: createSuccessfulRemoteDataObject(item)
29+
})
30+
}
31+
};
32+
33+
dsoNameService = jasmine.createSpyObj('dsoNameService', {
34+
getName: 'Item Name'
35+
});
36+
37+
TestBed.configureTestingModule({
38+
imports: [TranslateModule.forRoot()],
39+
declarations: [ItemCurateComponent],
40+
providers: [
41+
{provide: ActivatedRoute, useValue: routeStub},
42+
{provide: DSONameService, useValue: dsoNameService}
43+
],
44+
schemas: [CUSTOM_ELEMENTS_SCHEMA]
45+
}).compileComponents();
46+
}));
47+
48+
beforeEach(() => {
49+
fixture = TestBed.createComponent(ItemCurateComponent);
50+
comp = fixture.componentInstance;
51+
debugEl = fixture.debugElement;
52+
53+
fixture.detectChanges();
54+
});
55+
describe('init', () => {
56+
it('should initialise the comp', () => {
57+
expect(comp).toBeDefined();
58+
expect(debugEl.nativeElement.innerHTML).toContain('ds-curation-form');
59+
});
60+
61+
it('should contain the item information provided in the route', (done) => {
62+
comp.dsoRD$.subscribe((value) => {
63+
expect(value.payload.handle).toEqual('123456789/1');
64+
done();
65+
});
66+
});
67+
68+
it('should contain the item name', (done) => {
69+
comp.itemName$.subscribe((value) => {
70+
expect(value).toEqual('Item Name');
71+
done();
72+
});
73+
});
74+
});
75+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Component } from '@angular/core';
2+
import { filter, map, shareReplay } from 'rxjs/operators';
3+
import { RemoteData } from '../../../core/data/remote-data';
4+
import { Observable } from 'rxjs';
5+
import { ActivatedRoute } from '@angular/router';
6+
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
7+
import { Collection } from '../../../core/shared/collection.model';
8+
import { hasValue } from '../../../shared/empty.util';
9+
10+
/**
11+
* Component for managing a collection's curation tasks
12+
*/
13+
@Component({
14+
selector: 'ds-item-curate',
15+
templateUrl: './item-curate.component.html',
16+
})
17+
export class ItemCurateComponent {
18+
dsoRD$: Observable<RemoteData<Collection>> = this.route.parent.data.pipe(
19+
map((data) => data.dso),
20+
shareReplay(1)
21+
);
22+
23+
itemName$: Observable<string> = this.dsoRD$.pipe(
24+
filter((rd: RemoteData<Collection>) => hasValue(rd)),
25+
map((rd: RemoteData<Collection>) => {
26+
console.log(rd);
27+
return this.dsoNameService.getName(rd.payload);
28+
})
29+
);
30+
31+
constructor(
32+
private route: ActivatedRoute,
33+
private dsoNameService: DSONameService,
34+
) {}
35+
}

src/assets/i18n/en.json5

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,7 @@
22912291
"item.edit.tabs.curate.head": "Curate",
22922292

22932293
"item.edit.tabs.curate.title": "Item Edit - Curate",
2294+
"item.edit.curate.title": "Curate Item: {{item}}",
22942295

22952296
"item.edit.tabs.metadata.head": "Metadata",
22962297

0 commit comments

Comments
 (0)