mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #829 from atmire/Put-dynamic-workflowgroup-links-on-Collections-in-an-array
Put dynamic workflowgroup links on Collections in an array
This commit is contained in:
@@ -30,24 +30,27 @@ describe('CollectionRolesComponent', () => {
|
|||||||
undefined,
|
undefined,
|
||||||
Object.assign(new Collection(), {
|
Object.assign(new Collection(), {
|
||||||
_links: {
|
_links: {
|
||||||
'irrelevant': {
|
irrelevant: {
|
||||||
href: 'irrelevant link',
|
href: 'irrelevant link',
|
||||||
},
|
},
|
||||||
'adminGroup': {
|
adminGroup: {
|
||||||
href: 'adminGroup link',
|
href: 'adminGroup link',
|
||||||
},
|
},
|
||||||
'submittersGroup': {
|
submittersGroup: {
|
||||||
href: 'submittersGroup link',
|
href: 'submittersGroup link',
|
||||||
},
|
},
|
||||||
'itemReadGroup': {
|
itemReadGroup: {
|
||||||
href: 'itemReadGroup link',
|
href: 'itemReadGroup link',
|
||||||
},
|
},
|
||||||
'bitstreamReadGroup': {
|
bitstreamReadGroup: {
|
||||||
href: 'bitstreamReadGroup link',
|
href: 'bitstreamReadGroup link',
|
||||||
},
|
},
|
||||||
'workflowGroups/test': {
|
workflowGroups: [
|
||||||
href: 'test workflow group link',
|
{
|
||||||
},
|
name: 'test',
|
||||||
|
href: 'test workflow group link',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
@@ -5,7 +5,7 @@ import { first, map } from 'rxjs/operators';
|
|||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { Collection } from '../../../core/shared/collection.model';
|
import { Collection } from '../../../core/shared/collection.model';
|
||||||
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../core/shared/operators';
|
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../core/shared/operators';
|
||||||
import { ComcolRole } from '../../../shared/comcol-forms/edit-comcol-page/comcol-role/comcol-role';
|
import { HALLink } from '../../../core/shared/hal-link.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component for managing a collection's roles
|
* Component for managing a collection's roles
|
||||||
@@ -31,19 +31,27 @@ export class CollectionRolesComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* The different roles for the collection, as an observable.
|
* The different roles for the collection, as an observable.
|
||||||
*/
|
*/
|
||||||
getComcolRoles(): Observable<ComcolRole[]> {
|
getComcolRoles(): Observable<HALLink[]> {
|
||||||
return this.collection$.pipe(
|
return this.collection$.pipe(
|
||||||
map((collection) =>
|
map((collection) => [
|
||||||
[
|
{
|
||||||
ComcolRole.COLLECTION_ADMIN,
|
name: 'collection-admin',
|
||||||
ComcolRole.SUBMITTERS,
|
href: collection._links.adminGroup.href,
|
||||||
ComcolRole.ITEM_READ,
|
},
|
||||||
ComcolRole.BITSTREAM_READ,
|
{
|
||||||
...Object.keys(collection._links)
|
name: 'submitters',
|
||||||
.filter((link) => link.startsWith('workflowGroups/'))
|
href: collection._links.submittersGroup.href,
|
||||||
.map((link) => new ComcolRole(link.substr('workflowGroups/'.length), link)),
|
},
|
||||||
]
|
{
|
||||||
),
|
name: 'item_read',
|
||||||
|
href: collection._links.itemReadGroup.href,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'bitstream_read',
|
||||||
|
href: collection._links.bitstreamReadGroup.href,
|
||||||
|
},
|
||||||
|
...collection._links.workflowGroups,
|
||||||
|
]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<ds-comcol-role
|
<ds-comcol-role
|
||||||
*ngFor="let comcolRole of getComcolRoles()"
|
*ngFor="let comcolRole of getComcolRoles$() | async"
|
||||||
[dso]="community$ | async"
|
[dso]="community$ | async"
|
||||||
[comcolRole]="comcolRole"
|
[comcolRole]="comcolRole"
|
||||||
>
|
>
|
||||||
|
@@ -4,8 +4,8 @@ import { Observable } from 'rxjs';
|
|||||||
import { first, map } from 'rxjs/operators';
|
import { first, map } from 'rxjs/operators';
|
||||||
import { Community } from '../../../core/shared/community.model';
|
import { Community } from '../../../core/shared/community.model';
|
||||||
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../core/shared/operators';
|
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../core/shared/operators';
|
||||||
import { ComcolRole } from '../../../shared/comcol-forms/edit-comcol-page/comcol-role/comcol-role';
|
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
|
import { HALLink } from '../../../core/shared/hal-link.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component for managing a community's roles
|
* Component for managing a community's roles
|
||||||
@@ -31,10 +31,15 @@ export class CommunityRolesComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* The different roles for the community.
|
* The different roles for the community.
|
||||||
*/
|
*/
|
||||||
getComcolRoles(): ComcolRole[] {
|
getComcolRoles$(): Observable<HALLink[]> {
|
||||||
return [
|
return this.community$.pipe(
|
||||||
ComcolRole.COMMUNITY_ADMIN,
|
map((community) => [
|
||||||
];
|
{
|
||||||
|
name: 'community-admin',
|
||||||
|
href: community._links.adminGroup.href,
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@@ -40,7 +40,6 @@ import { GROUP } from './models/group.resource-type';
|
|||||||
import { DSONameService } from '../breadcrumbs/dso-name.service';
|
import { DSONameService } from '../breadcrumbs/dso-name.service';
|
||||||
import { Community } from '../shared/community.model';
|
import { Community } from '../shared/community.model';
|
||||||
import { Collection } from '../shared/collection.model';
|
import { Collection } from '../shared/collection.model';
|
||||||
import { ComcolRole } from '../../shared/comcol-forms/edit-comcol-page/comcol-role/comcol-role';
|
|
||||||
|
|
||||||
const groupRegistryStateSelector = (state: AppState) => state.groupRegistry;
|
const groupRegistryStateSelector = (state: AppState) => state.groupRegistry;
|
||||||
const editGroupSelector = createSelector(groupRegistryStateSelector, (groupRegistryState: GroupRegistryState) => groupRegistryState.editGroup);
|
const editGroupSelector = createSelector(groupRegistryStateSelector, (groupRegistryState: GroupRegistryState) => groupRegistryState.editGroup);
|
||||||
@@ -324,16 +323,17 @@ export class GroupDataService extends DataService<Group> {
|
|||||||
* Create a group for a given role for a given community or collection.
|
* Create a group for a given role for a given community or collection.
|
||||||
*
|
*
|
||||||
* @param dso The community or collection for which to create a group
|
* @param dso The community or collection for which to create a group
|
||||||
|
* @param role The name of the role for which to create a group
|
||||||
* @param link The REST endpoint to create the group
|
* @param link The REST endpoint to create the group
|
||||||
*/
|
*/
|
||||||
createComcolGroup(dso: Community|Collection, link: string): Observable<RestResponse> {
|
createComcolGroup(dso: Community|Collection, role: string, link: string): Observable<RestResponse> {
|
||||||
|
|
||||||
const requestId = this.requestService.generateRequestId();
|
const requestId = this.requestService.generateRequestId();
|
||||||
const group = Object.assign(new Group(), {
|
const group = Object.assign(new Group(), {
|
||||||
metadata: {
|
metadata: {
|
||||||
'dc.description': [
|
'dc.description': [
|
||||||
{
|
{
|
||||||
value: `${this.nameService.getName(dso)} admin group`,
|
value: `${this.nameService.getName(dso)} ${role} group`,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@@ -15,8 +15,6 @@ import { RESOURCE_POLICY } from '../resource-policy/models/resource-policy.resou
|
|||||||
import { COMMUNITY } from './community.resource-type';
|
import { COMMUNITY } from './community.resource-type';
|
||||||
import { Community } from './community.model';
|
import { Community } from './community.model';
|
||||||
import { ChildHALResource } from './child-hal-resource.model';
|
import { ChildHALResource } from './child-hal-resource.model';
|
||||||
import { GROUP } from '../eperson/models/group.resource-type';
|
|
||||||
import { Group } from '../eperson/models/group.model';
|
|
||||||
|
|
||||||
@typedObject
|
@typedObject
|
||||||
@inheritSerialization(DSpaceObject)
|
@inheritSerialization(DSpaceObject)
|
||||||
@@ -41,6 +39,11 @@ export class Collection extends DSpaceObject implements ChildHALResource {
|
|||||||
defaultAccessConditions: HALLink;
|
defaultAccessConditions: HALLink;
|
||||||
logo: HALLink;
|
logo: HALLink;
|
||||||
parentCommunity: HALLink;
|
parentCommunity: HALLink;
|
||||||
|
workflowGroups: HALLink[];
|
||||||
|
adminGroup: HALLink;
|
||||||
|
submittersGroup: HALLink;
|
||||||
|
itemReadGroup: HALLink;
|
||||||
|
bitstreamReadGroup: HALLink;
|
||||||
self: HALLink;
|
self: HALLink;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -72,12 +75,6 @@ export class Collection extends DSpaceObject implements ChildHALResource {
|
|||||||
@link(COMMUNITY, false)
|
@link(COMMUNITY, false)
|
||||||
parentCommunity?: Observable<RemoteData<Community>>;
|
parentCommunity?: Observable<RemoteData<Community>>;
|
||||||
|
|
||||||
/**
|
|
||||||
* The administrators group of this community.
|
|
||||||
*/
|
|
||||||
@link(GROUP)
|
|
||||||
adminGroup?: Observable<RemoteData<Group>>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The introductory text of this Collection
|
* The introductory text of this Collection
|
||||||
* Corresponds to the metadata field dc.description
|
* Corresponds to the metadata field dc.description
|
||||||
|
@@ -3,8 +3,6 @@ import { Observable } from 'rxjs';
|
|||||||
import { link, typedObject } from '../cache/builders/build-decorators';
|
import { link, typedObject } from '../cache/builders/build-decorators';
|
||||||
import { PaginatedList } from '../data/paginated-list';
|
import { PaginatedList } from '../data/paginated-list';
|
||||||
import { RemoteData } from '../data/remote-data';
|
import { RemoteData } from '../data/remote-data';
|
||||||
import { Group } from '../eperson/models/group.model';
|
|
||||||
import { GROUP } from '../eperson/models/group.resource-type';
|
|
||||||
import { Bitstream } from './bitstream.model';
|
import { Bitstream } from './bitstream.model';
|
||||||
import { BITSTREAM } from './bitstream.resource-type';
|
import { BITSTREAM } from './bitstream.resource-type';
|
||||||
import { Collection } from './collection.model';
|
import { Collection } from './collection.model';
|
||||||
@@ -66,12 +64,6 @@ export class Community extends DSpaceObject implements ChildHALResource {
|
|||||||
@link(COMMUNITY, false)
|
@link(COMMUNITY, false)
|
||||||
parentCommunity?: Observable<RemoteData<Community>>;
|
parentCommunity?: Observable<RemoteData<Community>>;
|
||||||
|
|
||||||
/**
|
|
||||||
* The administrators group of this community.
|
|
||||||
*/
|
|
||||||
@link(GROUP)
|
|
||||||
adminGroup?: Observable<RemoteData<Group>>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The introductory text of this Community
|
* The introductory text of this Community
|
||||||
* Corresponds to the metadata field dc.description
|
* Corresponds to the metadata field dc.description
|
||||||
|
@@ -22,6 +22,6 @@ export class HALResource {
|
|||||||
/**
|
/**
|
||||||
* {@link HALLink}s to related {@link HALResource}s
|
* {@link HALLink}s to related {@link HALResource}s
|
||||||
*/
|
*/
|
||||||
[k: string]: HALLink;
|
[k: string]: HALLink | HALLink[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -4,13 +4,11 @@ import { GroupDataService } from '../../../../core/eperson/group-data.service';
|
|||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { SharedModule } from '../../../shared.module';
|
import { SharedModule } from '../../../shared.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { ChangeDetectorRef, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { RequestService } from '../../../../core/data/request.service';
|
import { RequestService } from '../../../../core/data/request.service';
|
||||||
import { ComcolRole } from './comcol-role';
|
|
||||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
|
||||||
|
|
||||||
describe('ComcolRoleComponent', () => {
|
describe('ComcolRoleComponent', () => {
|
||||||
|
|
||||||
@@ -65,20 +63,10 @@ describe('ComcolRoleComponent', () => {
|
|||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
de = fixture.debugElement;
|
de = fixture.debugElement;
|
||||||
|
|
||||||
comp.comcolRole = new ComcolRole(
|
comp.comcolRole = {
|
||||||
'test role name',
|
name: 'test role name',
|
||||||
'test role endpoint',
|
href: 'test role link',
|
||||||
);
|
};
|
||||||
|
|
||||||
comp.dso = Object.assign(
|
|
||||||
new Collection(), {
|
|
||||||
_links: {
|
|
||||||
'test role endpoint': {
|
|
||||||
href: 'test role link',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
@@ -138,7 +126,7 @@ describe('ComcolRoleComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call the groupService create method', () => {
|
it('should call the groupService create method', () => {
|
||||||
expect(groupService.createComcolGroup).toHaveBeenCalledWith(comp.dso, 'test role link');
|
expect(groupService.createComcolGroup).toHaveBeenCalledWith(comp.dso, 'test role name', 'test role link');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -7,9 +7,9 @@ import { GroupDataService } from '../../../../core/eperson/group-data.service';
|
|||||||
import { Collection } from '../../../../core/shared/collection.model';
|
import { Collection } from '../../../../core/shared/collection.model';
|
||||||
import { filter, map } from 'rxjs/operators';
|
import { filter, map } from 'rxjs/operators';
|
||||||
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators';
|
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators';
|
||||||
import { ComcolRole } from './comcol-role';
|
|
||||||
import { RequestService } from '../../../../core/data/request.service';
|
import { RequestService } from '../../../../core/data/request.service';
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
|
import { HALLink } from '../../../../core/shared/hal-link.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component for managing a community or collection role.
|
* Component for managing a community or collection role.
|
||||||
@@ -31,7 +31,7 @@ export class ComcolRoleComponent implements OnInit {
|
|||||||
* The role to manage
|
* The role to manage
|
||||||
*/
|
*/
|
||||||
@Input()
|
@Input()
|
||||||
comcolRole: ComcolRole;
|
comcolRole: HALLink;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
@@ -43,7 +43,7 @@ export class ComcolRoleComponent implements OnInit {
|
|||||||
* The link to the related group.
|
* The link to the related group.
|
||||||
*/
|
*/
|
||||||
get groupLink(): string {
|
get groupLink(): string {
|
||||||
return this.dso._links[this.comcolRole.linkName].href;
|
return this.comcolRole.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,7 +106,7 @@ export class ComcolRoleComponent implements OnInit {
|
|||||||
* Create a group for this community or collection role.
|
* Create a group for this community or collection role.
|
||||||
*/
|
*/
|
||||||
create() {
|
create() {
|
||||||
this.groupService.createComcolGroup(this.dso, this.groupLink).subscribe();
|
this.groupService.createComcolGroup(this.dso, this.comcolRole.name, this.groupLink).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,77 +0,0 @@
|
|||||||
import { Community } from '../../../../core/shared/community.model';
|
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class representing a community or collection role.
|
|
||||||
*/
|
|
||||||
export class ComcolRole {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The community admin role.
|
|
||||||
*/
|
|
||||||
public static COMMUNITY_ADMIN = new ComcolRole(
|
|
||||||
'community-admin',
|
|
||||||
'adminGroup',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The collection admin role.
|
|
||||||
*/
|
|
||||||
public static COLLECTION_ADMIN = new ComcolRole(
|
|
||||||
'collection-admin',
|
|
||||||
'adminGroup',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The submitters role.
|
|
||||||
*/
|
|
||||||
public static SUBMITTERS = new ComcolRole(
|
|
||||||
'submitters',
|
|
||||||
'submittersGroup',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default item read role.
|
|
||||||
*/
|
|
||||||
public static ITEM_READ = new ComcolRole(
|
|
||||||
'item_read',
|
|
||||||
'itemReadGroup',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default bitstream read role.
|
|
||||||
*/
|
|
||||||
public static BITSTREAM_READ = new ComcolRole(
|
|
||||||
'bitstream_read',
|
|
||||||
'bitstreamReadGroup',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name The name for this community or collection role.
|
|
||||||
* @param linkName The path linking to this community or collection role.
|
|
||||||
*/
|
|
||||||
constructor(
|
|
||||||
public name,
|
|
||||||
public linkName,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the REST endpoint for managing this role for a given community or collection.
|
|
||||||
* @param dso
|
|
||||||
*/
|
|
||||||
public getEndpoint(dso: Community | Collection) {
|
|
||||||
|
|
||||||
let linkPath;
|
|
||||||
switch (dso.type + '') {
|
|
||||||
case 'community':
|
|
||||||
linkPath = 'communities';
|
|
||||||
break;
|
|
||||||
case 'collection':
|
|
||||||
linkPath = 'collections';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${linkPath}/${dso.uuid}/${this.linkName}`;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user