mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #2211 from enea4science/feature/8384-edit-item-curate
Fixes #8384: Added Curate tab in Edit Item page
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
|
||||||
import { ScriptDataService } from '../core/data/processes/script-data.service';
|
import { ScriptDataService } from '../core/data/processes/script-data.service';
|
||||||
import { FormControl, FormGroup } from '@angular/forms';
|
import { FormControl, FormGroup } from '@angular/forms';
|
||||||
import { getFirstCompletedRemoteData } from '../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../core/shared/operators';
|
||||||
@@ -40,7 +40,8 @@ export class CurationFormComponent implements OnInit {
|
|||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private handleService: HandleService,
|
private handleService: HandleService,
|
||||||
private router: Router
|
private router: Router,
|
||||||
|
private cdr: ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ export class CurationFormComponent implements OnInit {
|
|||||||
.filter((value) => isNotEmpty(value) && value.includes('='))
|
.filter((value) => isNotEmpty(value) && value.includes('='))
|
||||||
.map((value) => value.split('=')[1].trim());
|
.map((value) => value.split('=')[1].trim());
|
||||||
this.form.get('task').patchValue(this.tasks[0]);
|
this.form.get('task').patchValue(this.tasks[0]);
|
||||||
|
this.cdr.detectChanges();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ import { IdentifierDataService } from '../../core/data/identifier-data.service';
|
|||||||
import { IdentifierDataComponent } from '../../shared/object-list/identifier-data/identifier-data.component';
|
import { IdentifierDataComponent } from '../../shared/object-list/identifier-data/identifier-data.component';
|
||||||
import { ItemRegisterDoiComponent } from './item-register-doi/item-register-doi.component';
|
import { ItemRegisterDoiComponent } from './item-register-doi/item-register-doi.component';
|
||||||
import { DsoSharedModule } from '../../dso-shared/dso-shared.module';
|
import { DsoSharedModule } from '../../dso-shared/dso-shared.module';
|
||||||
|
import { ItemCurateComponent } from './item-curate/item-curate.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module that contains all components related to the Edit Item page administrator functionality
|
* 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';
|
|||||||
VirtualMetadataComponent,
|
VirtualMetadataComponent,
|
||||||
ItemAuthorizationsComponent,
|
ItemAuthorizationsComponent,
|
||||||
IdentifierDataComponent,
|
IdentifierDataComponent,
|
||||||
ItemRegisterDoiComponent
|
ItemRegisterDoiComponent,
|
||||||
|
ItemCurateComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
BundleDataService,
|
BundleDataService,
|
||||||
|
@@ -41,6 +41,7 @@ import { ItemPageVersionHistoryGuard } from './item-page-version-history.guard';
|
|||||||
import { ItemPageCollectionMapperGuard } from './item-page-collection-mapper.guard';
|
import { ItemPageCollectionMapperGuard } from './item-page-collection-mapper.guard';
|
||||||
import { ThemedDsoEditMetadataComponent } from '../../dso-shared/dso-edit-metadata/themed-dso-edit-metadata.component';
|
import { ThemedDsoEditMetadataComponent } from '../../dso-shared/dso-edit-metadata/themed-dso-edit-metadata.component';
|
||||||
import { ItemPageRegisterDoiGuard } from './item-page-register-doi.guard';
|
import { ItemPageRegisterDoiGuard } from './item-page-register-doi.guard';
|
||||||
|
import { ItemCurateComponent } from './item-curate/item-curate.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routing module that handles the routing for the Edit Item page administrator functionality
|
* 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';
|
|||||||
data: { title: 'item.edit.tabs.metadata.title', showBreadcrumbs: true },
|
data: { title: 'item.edit.tabs.metadata.title', showBreadcrumbs: true },
|
||||||
canActivate: [ItemPageMetadataGuard]
|
canActivate: [ItemPageMetadataGuard]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'curate',
|
||||||
|
component: ItemCurateComponent,
|
||||||
|
data: { title: 'item.edit.tabs.curate.title', showBreadcrumbs: true }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'relationships',
|
path: 'relationships',
|
||||||
component: ItemRelationshipsComponent,
|
component: ItemRelationshipsComponent,
|
||||||
|
@@ -0,0 +1,7 @@
|
|||||||
|
<div class="container mt-3">
|
||||||
|
<h3>{{'item.edit.curate.title' |translate:{item: (itemName$ |async)} }}</h3>
|
||||||
|
<ds-curation-form
|
||||||
|
*ngIf="dsoRD$ | async as dsoRD"
|
||||||
|
[dsoHandle]="dsoRD?.payload.handle"
|
||||||
|
></ds-curation-form>
|
||||||
|
</div>
|
@@ -0,0 +1,75 @@
|
|||||||
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
|
||||||
|
import { ItemCurateComponent } from './item-curate.component';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { Item } from '../../../core/shared/item.model';
|
||||||
|
|
||||||
|
describe('ItemCurateComponent', () => {
|
||||||
|
let comp: ItemCurateComponent;
|
||||||
|
let fixture: ComponentFixture<ItemCurateComponent>;
|
||||||
|
let debugEl: DebugElement;
|
||||||
|
|
||||||
|
let routeStub;
|
||||||
|
let dsoNameService;
|
||||||
|
|
||||||
|
const item = Object.assign(new Item(), {
|
||||||
|
handle: '123456789/1',
|
||||||
|
metadata: {'dc.title': ['Item Name']}
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
routeStub = {
|
||||||
|
parent: {
|
||||||
|
data: observableOf({
|
||||||
|
dso: createSuccessfulRemoteDataObject(item)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
dsoNameService = jasmine.createSpyObj('dsoNameService', {
|
||||||
|
getName: 'Item Name'
|
||||||
|
});
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot()],
|
||||||
|
declarations: [ItemCurateComponent],
|
||||||
|
providers: [
|
||||||
|
{provide: ActivatedRoute, useValue: routeStub},
|
||||||
|
{provide: DSONameService, useValue: dsoNameService}
|
||||||
|
],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ItemCurateComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
debugEl = fixture.debugElement;
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
describe('init', () => {
|
||||||
|
it('should initialise the comp', () => {
|
||||||
|
expect(comp).toBeDefined();
|
||||||
|
expect(debugEl.nativeElement.innerHTML).toContain('ds-curation-form');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should contain the item information provided in the route', (done) => {
|
||||||
|
comp.dsoRD$.subscribe((value) => {
|
||||||
|
expect(value.payload.handle).toEqual('123456789/1');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should contain the item name', (done) => {
|
||||||
|
comp.itemName$.subscribe((value) => {
|
||||||
|
expect(value).toEqual('Item Name');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,39 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { filter, map, take } from 'rxjs/operators';
|
||||||
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { hasValue } from '../../../shared/empty.util';
|
||||||
|
import { Item } from '../../../core/shared/item.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component for managing a collection's curation tasks
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-item-curate',
|
||||||
|
templateUrl: './item-curate.component.html',
|
||||||
|
})
|
||||||
|
export class ItemCurateComponent implements OnInit {
|
||||||
|
dsoRD$: Observable<RemoteData<Item>>;
|
||||||
|
itemName$: Observable<string>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private dsoNameService: DSONameService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.dsoRD$ = this.route.parent.data.pipe(
|
||||||
|
take(1),
|
||||||
|
map((data) => data.dso),
|
||||||
|
);
|
||||||
|
|
||||||
|
this.itemName$ = this.dsoRD$.pipe(
|
||||||
|
filter((rd: RemoteData<Item>) => hasValue(rd)),
|
||||||
|
map((rd: RemoteData<Item>) => {
|
||||||
|
return this.dsoNameService.getName(rd.payload);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -2291,6 +2291,7 @@
|
|||||||
"item.edit.tabs.curate.head": "Curate",
|
"item.edit.tabs.curate.head": "Curate",
|
||||||
|
|
||||||
"item.edit.tabs.curate.title": "Item Edit - Curate",
|
"item.edit.tabs.curate.title": "Item Edit - Curate",
|
||||||
|
"item.edit.curate.title": "Curate Item: {{item}}",
|
||||||
|
|
||||||
"item.edit.tabs.metadata.head": "Metadata",
|
"item.edit.tabs.metadata.head": "Metadata",
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user