Skip to content

Commit c233927

Browse files
authored
Merge pull request DSpace#2211 from enea4science/feature/8384-edit-item-curate
Fixes #8384: Added Curate tab in Edit Item page
2 parents 5e27741 + 57eb6da commit c233927

7 files changed

Lines changed: 135 additions & 4 deletions

File tree

src/app/curation-form/curation-form.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, OnInit } from '@angular/core';
1+
import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
22
import { ScriptDataService } from '../core/data/processes/script-data.service';
33
import { FormControl, FormGroup } from '@angular/forms';
44
import { getFirstCompletedRemoteData } from '../core/shared/operators';
@@ -40,7 +40,8 @@ export class CurationFormComponent implements OnInit {
4040
private notificationsService: NotificationsService,
4141
private translateService: TranslateService,
4242
private handleService: HandleService,
43-
private router: Router
43+
private router: Router,
44+
private cdr: ChangeDetectorRef
4445
) {
4546
}
4647

@@ -59,6 +60,7 @@ export class CurationFormComponent implements OnInit {
5960
.filter((value) => isNotEmpty(value) && value.includes('='))
6061
.map((value) => value.split('=')[1].trim());
6162
this.form.get('task').patchValue(this.tasks[0]);
63+
this.cdr.detectChanges();
6264
});
6365
}
6466

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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="container mt-3">
2+
<h3>{{'item.edit.curate.title' |translate:{item: (itemName$ |async)} }}</h3>
3+
<ds-curation-form
4+
*ngIf="dsoRD$ | async as dsoRD"
5+
[dsoHandle]="dsoRD?.payload.handle"
6+
></ds-curation-form>
7+
</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+
describe('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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { filter, map, take } 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 { hasValue } from '../../../shared/empty.util';
8+
import { Item } from '../../../core/shared/item.model';
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 implements OnInit {
18+
dsoRD$: Observable<RemoteData<Item>>;
19+
itemName$: Observable<string>;
20+
21+
constructor(
22+
private route: ActivatedRoute,
23+
private dsoNameService: DSONameService,
24+
) {}
25+
26+
ngOnInit(): void {
27+
this.dsoRD$ = this.route.parent.data.pipe(
28+
take(1),
29+
map((data) => data.dso),
30+
);
31+
32+
this.itemName$ = this.dsoRD$.pipe(
33+
filter((rd: RemoteData<Item>) => hasValue(rd)),
34+
map((rd: RemoteData<Item>) => {
35+
return this.dsoNameService.getName(rd.payload);
36+
})
37+
);
38+
}
39+
}

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)