mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
Added authorizations edit page for collections
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
<div class="container">
|
||||
<ds-resource-policies [resourceType]="'collection'" [resourceUUID]="(dsoRD$ | async)?.payload?.id"></ds-resource-policies>
|
||||
</div>
|
@@ -0,0 +1,71 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ChangeDetectorRef, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { cold } from 'jasmine-marbles';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { CollectionAuthorizationsComponent } from './collection-authorizations.component';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
|
||||
|
||||
describe('CollectionAuthorizationsComponent', () => {
|
||||
let comp: CollectionAuthorizationsComponent<DSpaceObject>;
|
||||
let fixture: ComponentFixture<CollectionAuthorizationsComponent<any>>;
|
||||
|
||||
const collection = Object.assign(new Collection(), {
|
||||
uuid: 'collection',
|
||||
id: 'collection',
|
||||
_links: {
|
||||
self: { href: 'collection-selflink' }
|
||||
}
|
||||
});
|
||||
|
||||
const collectionRD = createSuccessfulRemoteDataObject(collection);
|
||||
|
||||
const routeStub = {
|
||||
parent: {
|
||||
data: observableOf({
|
||||
dso: collectionRD
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
declarations: [CollectionAuthorizationsComponent],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: routeStub },
|
||||
ChangeDetectorRef,
|
||||
CollectionAuthorizationsComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CollectionAuthorizationsComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
comp = null;
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(comp).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should init dso remote data properly', (done) => {
|
||||
const expected = cold('(a|)', { a: collectionRD });
|
||||
expect(comp.dsoRD$).toBeObservable(expected);
|
||||
done();
|
||||
});
|
||||
});
|
@@ -0,0 +1,40 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { first, map } from 'rxjs/operators';
|
||||
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-collection-authorizations',
|
||||
templateUrl: './collection-authorizations.component.html',
|
||||
})
|
||||
/**
|
||||
* Component that handles the Collection Authorizations
|
||||
*/
|
||||
export class CollectionAuthorizationsComponent<TDomain extends DSpaceObject> implements OnInit {
|
||||
|
||||
/**
|
||||
* The initial DSO object
|
||||
*/
|
||||
public dsoRD$: Observable<RemoteData<TDomain>>;
|
||||
|
||||
/**
|
||||
* Initialize instance variables
|
||||
*
|
||||
* @param {ActivatedRoute} route
|
||||
*/
|
||||
constructor(
|
||||
private route: ActivatedRoute
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the component, setting up the collection
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.dsoRD$ = this.route.parent.data.pipe(first(), map((data) => data.dso));
|
||||
}
|
||||
}
|
@@ -8,6 +8,7 @@ import { CollectionPageModule } from '../collection-page.module';
|
||||
import { CollectionRolesComponent } from './collection-roles/collection-roles.component';
|
||||
import { CollectionCurateComponent } from './collection-curate/collection-curate.component';
|
||||
import { CollectionSourceComponent } from './collection-source/collection-source.component';
|
||||
import { CollectionAuthorizationsComponent } from './collection-authorizations/collection-authorizations.component';
|
||||
|
||||
/**
|
||||
* Module that contains all components related to the Edit Collection page administrator functionality
|
||||
@@ -24,7 +25,8 @@ import { CollectionSourceComponent } from './collection-source/collection-source
|
||||
CollectionMetadataComponent,
|
||||
CollectionRolesComponent,
|
||||
CollectionCurateComponent,
|
||||
CollectionSourceComponent
|
||||
CollectionSourceComponent,
|
||||
CollectionAuthorizationsComponent
|
||||
]
|
||||
})
|
||||
export class EditCollectionPageModule {
|
||||
|
@@ -5,6 +5,7 @@ import { CollectionMetadataComponent } from './collection-metadata/collection-me
|
||||
import { CollectionRolesComponent } from './collection-roles/collection-roles.component';
|
||||
import { CollectionSourceComponent } from './collection-source/collection-source.component';
|
||||
import { CollectionCurateComponent } from './collection-curate/collection-curate.component';
|
||||
import { CollectionAuthorizationsComponent } from './collection-authorizations/collection-authorizations.component';
|
||||
import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||
|
||||
/**
|
||||
@@ -49,7 +50,12 @@ import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.r
|
||||
path: 'curate',
|
||||
component: CollectionCurateComponent,
|
||||
data: { title: 'collection.edit.tabs.curate.title', showBreadcrumbs: true }
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'authorizations',
|
||||
component: CollectionAuthorizationsComponent,
|
||||
data: { title: 'collection.edit.tabs.authorizations.title', showBreadcrumbs: true }
|
||||
},
|
||||
]
|
||||
}
|
||||
])
|
||||
|
Reference in New Issue
Block a user