[CST-7755] LYRASIS: Supervisor orders (Angular)

This commit is contained in:
Sufiyan Shaikh
2022-12-29 18:16:54 +05:30
parent 4915f10b0e
commit 09781c9057
47 changed files with 1531 additions and 52 deletions

View File

@@ -1 +1 @@
<ds-configuration-search-page configuration="workflowAdmin" [context]="context"></ds-configuration-search-page> <ds-configuration-search-page configuration="supervision" [context]="context"></ds-configuration-search-page>

View File

@@ -1,6 +1,9 @@
<div class="workflow-badge"> <div class="workflow-badge" *ngIf="dso?.type === 'workflowitem'">
<span class="badge badge-info">{{ "admin.workflow.item.workflow" | translate }}</span> <span class="badge badge-info">{{ "admin.workflow.item.workflow" | translate }}</span>
</div> </div>
<div class="workspace-badge" *ngIf="dso?.type === 'workspaceitem'">
<span class="badge badge-info">{{ "admin.workflow.item.workspace" | translate }}</span>
</div>
<ds-listable-object-component-loader *ngIf="item$ | async" <ds-listable-object-component-loader *ngIf="item$ | async"
[object]="item$ | async" [object]="item$ | async"
[viewMode]="viewModes.ListElement" [viewMode]="viewModes.ListElement"

View File

@@ -14,8 +14,10 @@ import { TruncatableService } from '../../../../../shared/truncatable/truncatabl
import { WorkflowItemSearchResult } from '../../../../../shared/object-collection/shared/workflow-item-search-result.model'; import { WorkflowItemSearchResult } from '../../../../../shared/object-collection/shared/workflow-item-search-result.model';
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
import { APP_CONFIG, AppConfig } from '../../../../../../config/app-config.interface'; import { APP_CONFIG, AppConfig } from '../../../../../../config/app-config.interface';
import { WorkspaceItemSearchResult } from '../../../../../shared/object-collection/shared/workspace-item-search-result.model';
@listableObjectComponent(WorkflowItemSearchResult, ViewMode.ListElement, Context.AdminWorkflowSearch) @listableObjectComponent(WorkflowItemSearchResult, ViewMode.ListElement, Context.AdminWorkflowSearch)
@listableObjectComponent(WorkspaceItemSearchResult, ViewMode.ListElement, Context.AdminWorkflowSearch)
@Component({ @Component({
selector: 'ds-workflow-item-search-result-admin-workflow-list-element', selector: 'ds-workflow-item-search-result-admin-workflow-list-element',
styleUrls: ['./workflow-item-search-result-admin-workflow-list-element.component.scss'], styleUrls: ['./workflow-item-search-result-admin-workflow-list-element.component.scss'],

View File

@@ -5,4 +5,11 @@
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 send-back-link" [routerLink]="[getSendBackRoute()]" [title]="'admin.workflow.item.send-back' | translate"> <a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 send-back-link" [routerLink]="[getSendBackRoute()]" [title]="'admin.workflow.item.send-back' | translate">
<i class="fa fa-hand-point-left"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.workflow.item.send-back" | translate}}</span> <i class="fa fa-hand-point-left"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.workflow.item.send-back" | translate}}</span>
</a> </a>
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 policies-link" [routerLink]="[getPoliciesRoute() | async]" [title]="'admin.workflow.item.policies' | translate">
<i class="fas fa-edit"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{'admin.workflow.item.policies' | translate}}</span>
</a>
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 supervision-group-selector" [title]="'admin.workflow.item.supervision' | translate"
*ngIf="wfi?.type === 'workspaceitem'" (click)="openSupervisionModal()">
<i class="fas fa-users-cog"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{'admin.workflow.item.supervision' | translate}}</span>
</a>
</div> </div>

View File

@@ -11,17 +11,25 @@ import {
getWorkflowItemDeleteRoute, getWorkflowItemDeleteRoute,
getWorkflowItemSendBackRoute getWorkflowItemSendBackRoute
} from '../../../workflowitems-edit-page/workflowitems-edit-page-routing-paths'; } from '../../../workflowitems-edit-page/workflowitems-edit-page-routing-paths';
import { of } from 'rxjs';
import { Item } from 'src/app/core/shared/item.model';
import { RemoteData } from 'src/app/core/data/remote-data';
import { RequestEntryState } from 'src/app/core/data/request-entry-state.model';
describe('WorkflowItemAdminWorkflowActionsComponent', () => { describe('WorkflowItemAdminWorkflowActionsComponent', () => {
let component: WorkflowItemAdminWorkflowActionsComponent; let component: WorkflowItemAdminWorkflowActionsComponent;
let fixture: ComponentFixture<WorkflowItemAdminWorkflowActionsComponent>; let fixture: ComponentFixture<WorkflowItemAdminWorkflowActionsComponent>;
let id; let id;
let wfi; let wfi;
let item = new Item();
item.uuid = 'itemUUID1111';
const rd = new RemoteData(undefined, undefined, undefined, RequestEntryState.Success, undefined, item, 200);
function init() { function init() {
id = '780b2588-bda5-4112-a1cd-0b15000a5339'; id = '780b2588-bda5-4112-a1cd-0b15000a5339';
wfi = new WorkflowItem(); wfi = new WorkflowItem();
wfi.id = id; wfi.id = id;
wfi.item = of(rd);
} }
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
@@ -59,4 +67,11 @@ describe('WorkflowItemAdminWorkflowActionsComponent', () => {
const link = a.nativeElement.href; const link = a.nativeElement.href;
expect(link).toContain(new URLCombiner(getWorkflowItemSendBackRoute(wfi.id)).toString()); expect(link).toContain(new URLCombiner(getWorkflowItemSendBackRoute(wfi.id)).toString());
}); });
it('should render a policies button with the correct link', () => {
const a = fixture.debugElement.query(By.css('a.policies-link'));
const link = a.nativeElement.href;
expect(link).toContain(new URLCombiner('/items/itemUUID1111/edit/bitstreams').toString());
});
}); });

View File

@@ -1,4 +1,9 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { map, Observable } from 'rxjs';
import { Item } from '../../../core/shared/item.model';
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
import { SupervisionGroupSelectorComponent } from '../../../shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component';
import { WorkflowItem } from '../../../core/submission/models/workflowitem.model'; import { WorkflowItem } from '../../../core/submission/models/workflowitem.model';
import { import {
getWorkflowItemSendBackRoute, getWorkflowItemSendBackRoute,
@@ -25,6 +30,10 @@ export class WorkflowItemAdminWorkflowActionsComponent {
*/ */
@Input() public small: boolean; @Input() public small: boolean;
constructor(
private modalService: NgbModal
) { }
/** /**
* Returns the path to the delete page of this workflow item * Returns the path to the delete page of this workflow item
*/ */
@@ -39,4 +48,28 @@ export class WorkflowItemAdminWorkflowActionsComponent {
getSendBackRoute(): string { getSendBackRoute(): string {
return getWorkflowItemSendBackRoute(this.wfi.id); return getWorkflowItemSendBackRoute(this.wfi.id);
} }
/**
* Returns the path to the to administrative edit page policies tab
*/
getPoliciesRoute(): Observable<string> {
return this.wfi.item.pipe(
getFirstSucceededRemoteDataPayload(),
map((item: Item) => {
return '/items/' + item.uuid + '/edit/bitstreams';
})
);
}
/**
* Opens the Supervision Modal to create a supervision order
*/
openSupervisionModal() {
this.wfi.item.pipe(
getFirstSucceededRemoteDataPayload(),
).subscribe((item: Item) => {
const supervisionModal = this.modalService.open(SupervisionGroupSelectorComponent, { size: 'lg', backdrop: 'static' });
supervisionModal.componentInstance.itemUUID = item.uuid;
});
}
} }

View File

@@ -170,6 +170,7 @@ import { OrcidHistory } from './orcid/model/orcid-history.model';
import { OrcidAuthService } from './orcid/orcid-auth.service'; import { OrcidAuthService } from './orcid/orcid-auth.service';
import { VocabularyDataService } from './submission/vocabularies/vocabulary.data.service'; import { VocabularyDataService } from './submission/vocabularies/vocabulary.data.service';
import { VocabularyEntryDetailsDataService } from './submission/vocabularies/vocabulary-entry-details.data.service'; import { VocabularyEntryDetailsDataService } from './submission/vocabularies/vocabulary-entry-details.data.service';
import { SupervisionOrderDataService } from './supervision-order/supervision-order-data.service';
/** /**
* When not in production, endpoint responses can be mocked for testing purposes * When not in production, endpoint responses can be mocked for testing purposes
@@ -292,6 +293,7 @@ const PROVIDERS = [
OrcidAuthService, OrcidAuthService,
OrcidQueueDataService, OrcidQueueDataService,
OrcidHistoryDataService, OrcidHistoryDataService,
SupervisionOrderDataService
]; ];
/** /**

View File

@@ -8,6 +8,7 @@ export enum Context {
Search = 'search', Search = 'search',
Workflow = 'workflow', Workflow = 'workflow',
Workspace = 'workspace', Workspace = 'workspace',
SupervisedItems = 'otherworkspace',
AdminMenu = 'adminMenu', AdminMenu = 'adminMenu',
EntitySearchModalWithNameVariants = 'EntitySearchModalWithNameVariants', EntitySearchModalWithNameVariants = 'EntitySearchModalWithNameVariants',
EntitySearchModal = 'EntitySearchModal', EntitySearchModal = 'EntitySearchModal',

View File

@@ -14,6 +14,7 @@ import { ITEM } from '../../shared/item.resource-type';
import { excludeFromEquals } from '../../utilities/equals.decorators'; import { excludeFromEquals } from '../../utilities/equals.decorators';
import { WorkspaceitemSectionsObject } from './workspaceitem-sections.model'; import { WorkspaceitemSectionsObject } from './workspaceitem-sections.model';
import { CacheableObject } from '../../cache/cacheable-object.model'; import { CacheableObject } from '../../cache/cacheable-object.model';
import { SUPERVISION_ORDER } from '../../supervision-order/models/supervision-order.resource-type';
export interface SubmissionObjectError { export interface SubmissionObjectError {
message: string; message: string;
@@ -65,6 +66,7 @@ export abstract class SubmissionObject extends DSpaceObject implements Cacheable
item: HALLink; item: HALLink;
submissionDefinition: HALLink; submissionDefinition: HALLink;
submitter: HALLink; submitter: HALLink;
supervisionOrders: HALLink;
}; };
get self(): string { get self(): string {
@@ -93,4 +95,12 @@ export abstract class SubmissionObject extends DSpaceObject implements Cacheable
@link(EPERSON) @link(EPERSON)
submitter?: Observable<RemoteData<EPerson>> | EPerson; submitter?: Observable<RemoteData<EPerson>> | EPerson;
/**
* The submission supervision order
* Will be undefined unless the workspace item {@link HALLink} has been resolved.
*/
@link(SUPERVISION_ORDER)
/* This was changed from 'Observable<RemoteData<WorkspaceItem>> | WorkspaceItem' to 'any' to prevent issues in templates with async */
supervisionOrders?: any;
} }

View File

@@ -0,0 +1,44 @@
/**
* Enum representing the Action Type of a Resource Policy
*/
export enum ActionType {
/**
* Action of reading, viewing or downloading something
*/
READ = 'READ',
/**
* Action of modifying something
*/
WRITE = 'WRITE',
/**
* Action of deleting something
*/
DELETE = 'DELETE',
/**
* Action of adding something to a container
*/
ADD = 'ADD',
/**
* Action of removing something from a container
*/
REMOVE = 'REMOVE',
/**
* None Type of Supervision Order
*/
NONE = 'NONE',
/**
* Editor Type of Supervision Order
*/
EDITOR = 'EDITOR',
/**
* Observer Type of Supervision Order
*/
OBSERVER = 'OBSERVER',
}

View File

@@ -0,0 +1,74 @@
import { autoserialize, deserialize, deserializeAs } from 'cerialize';
import { link, typedObject } from '../../cache/builders/build-decorators';
import { IDToUUIDSerializer } from '../../cache/id-to-uuid-serializer';
import { HALLink } from '../../shared/hal-link.model';
import { SUPERVISION_ORDER } from './supervision-order.resource-type';
import { excludeFromEquals } from '../../utilities/equals.decorators';
import { ResourceType } from '../../shared/resource-type';
import { Observable } from 'rxjs';
import { RemoteData } from '../../data/remote-data';
import { GROUP } from '../../eperson/models/group.resource-type';
import { Group } from '../../eperson/models/group.model';
import { CacheableObject } from '../../cache/cacheable-object.model';
import { ITEM } from '../../shared/item.resource-type';
import { Item } from '../../shared/item.model';
/**
* Model class for a Supervision Order
*/
@typedObject
export class SupervisionOrder implements CacheableObject {
static type = SUPERVISION_ORDER;
/**
* The identifier for this Supervision Order
*/
@autoserialize
id: string;
/**
* The object type
*/
@excludeFromEquals
@autoserialize
type: ResourceType;
/**
* The object type
*/
@excludeFromEquals
@autoserialize
ordertype: string;
/**
* The universally unique identifier for this Supervision Order
* This UUID is generated client-side and isn't used by the backend.
* It is based on the ID, so it will be the same for each refresh.
*/
@deserializeAs(new IDToUUIDSerializer('supervision-order'), 'id')
uuid: string;
/**
* The {@link HALLink}s for this SupervisionOrder
*/
@deserialize
_links: {
item: HALLink,
group: HALLink,
self: HALLink,
};
/**
* The related supervision Item
* Will be undefined unless the item {@link HALLink} has been resolved.
*/
@link(ITEM)
item?: Observable<RemoteData<Item>>;
/**
* The group linked by this supervision order
* Will be undefined unless the version {@link HALLink} has been resolved.
*/
@link(GROUP)
group?: Observable<RemoteData<Group>>;
}

View File

@@ -0,0 +1,9 @@
import { ResourceType } from '../../shared/resource-type';
/**
* The resource type for SupervisionOrder
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const SUPERVISION_ORDER = new ResourceType('supervisionorder');

View File

@@ -0,0 +1,277 @@
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { of as observableOf } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../cache/object-cache.service';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { RequestService } from '../data/request.service';
import { SupervisionOrderDataService } from './supervision-order-data.service';
import { ActionType } from './models/action-type.model';
import { RequestParam } from '../cache/models/request-param.model';
import { PageInfo } from '../shared/page-info.model';
import { buildPaginatedList } from '../data/paginated-list.model';
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
import { RestResponse } from '../cache/response.models';
import { RequestEntry } from '../data/request-entry.model';
import { FindListOptions } from '../data/find-list-options.model';
import { GroupDataService } from '../eperson/group-data.service';
describe('SupervisionOrderService', () => {
let scheduler: TestScheduler;
let service: SupervisionOrderDataService;
let requestService: RequestService;
let rdbService: RemoteDataBuildService;
let objectCache: ObjectCacheService;
let halService: HALEndpointService;
let responseCacheEntry: RequestEntry;
let groupService: GroupDataService;
const supervisionOrder: any = {
id: '1',
name: null,
description: null,
action: ActionType.READ,
startDate: null,
endDate: null,
type: 'supervisionOrder',
uuid: 'supervision-order-1',
_links: {
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorder/1'
},
}
};
const anothersupervisionOrder: any = {
id: '2',
name: null,
description: null,
action: ActionType.WRITE,
startDate: null,
endDate: null,
type: 'supervisionOrder',
uuid: 'supervision-order-2',
_links: {
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorder/1'
},
}
};
const endpointURL = `https://rest.api/rest/api/supervisionorder`;
const requestURL = `https://rest.api/rest/api/supervisionorder/${supervisionOrder.id}`;
const requestUUID = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a';
const supervisionOrderId = '1';
const groupUUID = '8b39g7ya-5a4b-438b-9686-be1d5b4a1c5a';
const itemUUID = '8b39g7ya-5a4b-438b-851f-be1d5b4a1c5a';
const supervisionOrderType = 'NONE';
const pageInfo = new PageInfo();
const array = [supervisionOrder, anothersupervisionOrder];
const paginatedList = buildPaginatedList(pageInfo, array);
const supervisionOrderRD = createSuccessfulRemoteDataObject(supervisionOrder);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
const groupEndpoint = 'group_EP';
beforeEach(() => {
scheduler = getTestScheduler();
halService = jasmine.createSpyObj('halService', {
getEndpoint: cold('a', { a: endpointURL })
});
responseCacheEntry = new RequestEntry();
responseCacheEntry.request = { href: 'https://rest.api/' } as any;
responseCacheEntry.response = new RestResponse(true, 200, 'Success');
requestService = jasmine.createSpyObj('requestService', {
generateRequestId: requestUUID,
send: true,
removeByHrefSubstring: {},
getByHref: observableOf(responseCacheEntry),
getByUUID: observableOf(responseCacheEntry),
setStaleByHrefSubstring: {},
});
rdbService = jasmine.createSpyObj('rdbService', {
buildSingle: hot('a|', {
a: supervisionOrderRD
}),
buildList: hot('a|', {
a: paginatedListRD
}),
buildFromRequestUUID: hot('a|', {
a: supervisionOrderRD
}),
buildFromRequestUUIDAndAwait: hot('a|', {
a: supervisionOrderRD
})
});
groupService = jasmine.createSpyObj('groupService', {
getBrowseEndpoint: hot('a', {
a: groupEndpoint
}),
getIDHrefObs: cold('a', {
a: 'https://rest.api/rest/api/group/groups/' + groupUUID
}),
});
groupService = jasmine.createSpyObj('groupService', {
getIDHrefObs: cold('a', {
a: 'https://rest.api/rest/api/group/groups/' + groupUUID
}),
});
objectCache = {} as ObjectCacheService;
const notificationsService = {} as NotificationsService;
const comparator = {} as any;
service = new SupervisionOrderDataService(
requestService,
rdbService,
objectCache,
halService,
notificationsService,
comparator,
groupService,
);
spyOn(service, 'findById').and.callThrough();
spyOn(service, 'findByHref').and.callThrough();
spyOn(service, 'invalidateByHref').and.returnValue(observableOf(true));
spyOn((service as any).createData, 'create').and.callThrough();
spyOn((service as any).deleteData, 'delete').and.callThrough();
spyOn((service as any).patchData, 'update').and.callThrough();
spyOn((service as any).searchData, 'searchBy').and.callThrough();
spyOn((service as any).searchData, 'getSearchByHref').and.returnValue(observableOf(requestURL));
});
describe('create', () => {
it('should proxy the call to createData.create with group UUID', () => {
scheduler.schedule(() => service.create(supervisionOrder, itemUUID, groupUUID, supervisionOrderType));
const params = [
new RequestParam('uuid', itemUUID),
new RequestParam('group', groupUUID),
new RequestParam('type', supervisionOrderType),
];
scheduler.flush();
expect((service as any).createData.create).toHaveBeenCalledWith(supervisionOrder, ...params);
});
it('should proxy the call to createData.create with group UUID', () => {
scheduler.schedule(() => service.create(supervisionOrder, itemUUID, groupUUID, supervisionOrderType));
const params = [
new RequestParam('uuid', itemUUID),
new RequestParam('group', groupUUID),
new RequestParam('type', supervisionOrderType),
];
scheduler.flush();
expect((service as any).createData.create).toHaveBeenCalledWith(supervisionOrder, ...params);
});
it('should return a RemoteData<supervisionOrder> for the object with the given id', () => {
const result = service.create(supervisionOrder, itemUUID, groupUUID, supervisionOrderType);
const expected = cold('a|', {
a: supervisionOrderRD
});
expect(result).toBeObservable(expected);
});
});
describe('delete', () => {
it('should proxy the call to deleteData.delete', () => {
scheduler.schedule(() => service.delete(supervisionOrderId));
scheduler.flush();
expect((service as any).deleteData.delete).toHaveBeenCalledWith(supervisionOrderId);
});
});
describe('update', () => {
it('should proxy the call to updateData.update', () => {
scheduler.schedule(() => service.update(supervisionOrder));
scheduler.flush();
expect((service as any).patchData.update).toHaveBeenCalledWith(supervisionOrder);
});
});
describe('findById', () => {
it('should return a RemoteData<supervisionOrder> for the object with the given id', () => {
const result = service.findById(supervisionOrderId);
const expected = cold('a|', {
a: supervisionOrderRD
});
expect(result).toBeObservable(expected);
});
});
describe('findByHref', () => {
it('should return a RemoteData<supervisionOrder> for the object with the given URL', () => {
const result = service.findByHref(requestURL);
const expected = cold('a|', {
a: supervisionOrderRD
});
expect(result).toBeObservable(expected);
});
});
describe('searchByGroup', () => {
it('should proxy the call to searchData.searchBy', () => {
const options = new FindListOptions();
options.searchParams = [new RequestParam('uuid', groupUUID)];
scheduler.schedule(() => service.searchByGroup(groupUUID));
scheduler.flush();
expect((service as any).searchData.searchBy).toHaveBeenCalledWith((service as any).searchByGroupMethod, options, true, true);
});
it('should proxy the call to searchData.searchBy with additional search param', () => {
const options = new FindListOptions();
options.searchParams = [
new RequestParam('uuid', groupUUID),
new RequestParam('item', itemUUID),
];
scheduler.schedule(() => service.searchByGroup(groupUUID, itemUUID));
scheduler.flush();
expect((service as any).searchData.searchBy).toHaveBeenCalledWith((service as any).searchByGroupMethod, options, true, true);
});
it('should return a RemoteData<PaginatedList<supervisionOrder>) for the search', () => {
const result = service.searchByGroup(groupUUID);
const expected = cold('a|', {
a: paginatedListRD
});
expect(result).toBeObservable(expected);
});
});
describe('searchByItem', () => {
it('should proxy the call to searchData.searchBy', () => {
const options = new FindListOptions();
options.searchParams = [new RequestParam('uuid', itemUUID)];
scheduler.schedule(() => service.searchByItem(itemUUID));
scheduler.flush();
expect((service as any).searchData.searchBy).toHaveBeenCalledWith((service as any).searchByItemMethod, options, true, true);
});
it('should return a RemoteData<PaginatedList<supervisionOrder>) for the search', () => {
const result = service.searchByItem(itemUUID);
const expected = cold('a|', {
a: paginatedListRD
});
expect(result).toBeObservable(expected);
});
});
});

View File

@@ -0,0 +1,181 @@
import { Injectable } from '@angular/core';
import { HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
import { RequestService } from '../data/request.service';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { SupervisionOrder } from './models/supervision-order.model';
import { RemoteData } from '../data/remote-data';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../cache/object-cache.service';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { SUPERVISION_ORDER } from './models/supervision-order.resource-type';
import { DefaultChangeAnalyzer } from '../data/default-change-analyzer.service';
import { PaginatedList } from '../data/paginated-list.model';
import { RequestParam } from '../cache/models/request-param.model';
import { isNotEmpty } from '../../shared/empty.util';
import { first, map } from 'rxjs/operators';
import { NoContent } from '../shared/NoContent.model';
import { getFirstCompletedRemoteData } from '../shared/operators';
import { FindListOptions } from '../data/find-list-options.model';
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
import { PutRequest } from '../data/request.models';
import { GenericConstructor } from '../shared/generic-constructor';
import { ResponseParsingService } from '../data/parsing.service';
import { StatusCodeOnlyResponseParsingService } from '../data/status-code-only-response-parsing.service';
import { GroupDataService } from '../eperson/group-data.service';
import { IdentifiableDataService } from '../data/base/identifiable-data.service';
import { CreateDataImpl } from '../data/base/create-data';
import { SearchDataImpl } from '../data/base/search-data';
import { PatchDataImpl } from '../data/base/patch-data';
import { DeleteDataImpl } from '../data/base/delete-data';
import { dataService } from '../data/base/data-service.decorator';
/**
* A service responsible for fetching/sending data from/to the REST API on the supervisionorders endpoint
*/
@Injectable()
@dataService(SUPERVISION_ORDER)
export class SupervisionOrderDataService extends IdentifiableDataService<SupervisionOrder> {
protected searchByGroupMethod = 'group';
protected searchByItemMethod = 'byItem';
private createData: CreateDataImpl<SupervisionOrder>;
private searchData: SearchDataImpl<SupervisionOrder>;
private patchData: PatchDataImpl<SupervisionOrder>;
private deleteData: DeleteDataImpl<SupervisionOrder>;
constructor(
protected requestService: RequestService,
protected rdbService: RemoteDataBuildService,
protected objectCache: ObjectCacheService,
protected halService: HALEndpointService,
protected notificationsService: NotificationsService,
protected comparator: DefaultChangeAnalyzer<SupervisionOrder>,
protected groupService: GroupDataService,
) {
super('supervisionorders', requestService, rdbService, objectCache, halService);
this.createData = new CreateDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive);
this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
this.patchData = new PatchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, comparator, this.responseMsToLive, this.constructIdEndpoint);
this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint);
}
/**
* Create a new SupervisionOrder on the server, and store the response
* in the object cache
*
* @param {SupervisionOrder} supervisionOrder
* The supervision order to create
* @param {string} itemUUID
* The uuid of the item that will be grant of the permission.
* @param {string} groupUUID
* The uuid of the group that will be grant of the permission.
* @param {string} type
* The type of the supervision order that will be grant of the permission.
*/
create(supervisionOrder: SupervisionOrder, itemUUID: string, groupUUID: string, type: string): Observable<RemoteData<SupervisionOrder>> {
const params = [];
params.push(new RequestParam('uuid', itemUUID));
params.push(new RequestParam('group', groupUUID));
params.push(new RequestParam('type', type));
return this.createData.create(supervisionOrder, ...params);
}
/**
* Delete an existing SupervisionOrder on the server
*
* @param supervisionOrderID The supervision order's id to be removed
* @return an observable that emits true when the deletion was successful, false when it failed
*/
delete(supervisionOrderID: string): Observable<boolean> {
return this.deleteData.delete(supervisionOrderID).pipe(
getFirstCompletedRemoteData(),
map((response: RemoteData<NoContent>) => response.hasSucceeded),
);
}
/**
* Add a new patch to the object cache
* The patch is derived from the differences between the given object and its version in the object cache
* @param {SupervisionOrder} object The given object
*/
update(object: SupervisionOrder): Observable<RemoteData<SupervisionOrder>> {
return this.patchData.update(object);
}
/**
* Return the {@link SupervisionOrder} list for a {@link Group}
*
* @param UUID UUID of a given {@link Group}
* @param itemUUID Limit the returned policies to the specified DSO
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
* no valid cached version. Defaults to true
* @param reRequestOnStale Whether or not the request should automatically be re-
* requested after the response becomes stale
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
* {@link HALLink}s should be automatically resolved
*/
searchByGroup(UUID: string, itemUUID?: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<SupervisionOrder>[]): Observable<RemoteData<PaginatedList<SupervisionOrder>>> {
const options = new FindListOptions();
options.searchParams = [new RequestParam('uuid', UUID)];
if (isNotEmpty(itemUUID)) {
options.searchParams.push(new RequestParam('item', itemUUID));
}
return this.searchData.searchBy(this.searchByGroupMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
/**
* Return the {@link SupervisionOrder} list for a given DSO
*
* @param UUID UUID of a given DSO
* @param action Limit the returned policies to the specified {@link ActionType}
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
* no valid cached version. Defaults to true
* @param reRequestOnStale Whether or not the request should automatically be re-
* requested after the response becomes stale
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
* {@link HALLink}s should be automatically resolved
*/
searchByItem(UUID: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<SupervisionOrder>[]): Observable<RemoteData<PaginatedList<SupervisionOrder>>> {
const options = new FindListOptions();
options.searchParams = [new RequestParam('uuid', UUID)];
return this.searchData.searchBy(this.searchByItemMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
/**
* Update the target of the supervision order
* @param supervisionOrderId the ID of the supervision order
* @param supervisionOrderHref the link to the supervision order
* @param targetUUID the UUID of the target to which the permission is being granted
* @param targetType the type of the target (eperson or group) to which the permission is being granted
*/
updateTarget(supervisionOrderId: string, supervisionOrderHref: string, targetUUID: string, targetType: string): Observable<RemoteData<any>> {
const targetService = this.groupService;
const targetEndpoint$ = targetService.getIDHrefObs(targetUUID);
const options: HttpOptions = Object.create({});
let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'text/uri-list');
options.headers = headers;
const requestId = this.requestService.generateRequestId();
targetEndpoint$.pipe(
first(),
).subscribe((targetEndpoint) => {
const resourceEndpoint = supervisionOrderHref + '/' + targetType;
const request = new PutRequest(requestId, resourceEndpoint, targetEndpoint, options);
Object.assign(request, {
getResponseParser(): GenericConstructor<ResponseParsingService> {
return StatusCodeOnlyResponseParsingService;
}
});
this.requestService.send(request);
});
return this.rdbService.buildFromRequestUUIDAndAwait(requestId, () => this.invalidateByHref(supervisionOrderHref));
}
}

View File

@@ -10,6 +10,14 @@ import { TruncatableService } from '../../../../../shared/truncatable/truncatabl
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock'; import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock';
import { APP_CONFIG } from '../../../../../../config/app-config.interface'; import { APP_CONFIG } from '../../../../../../config/app-config.interface';
import { SupervisionOrderDataService } from '../../../../../core/supervision-order/supervision-order-data.service';
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { createSuccessfulRemoteDataObject } from '../../../../../shared/remote-data.utils';
import { PageInfo } from '../../../../../core/shared/page-info.model';
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
import { GroupMock } from '../../../../../shared/testing/group-mock';
import { hot } from 'jasmine-marbles';
let journalIssueListElementComponent: JournalIssueSearchResultListElementComponent; let journalIssueListElementComponent: JournalIssueSearchResultListElementComponent;
let fixture: ComponentFixture<JournalIssueSearchResultListElementComponent>; let fixture: ComponentFixture<JournalIssueSearchResultListElementComponent>;
@@ -70,12 +78,61 @@ const enviromentNoThumbs = {
} }
}; };
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
searchByItem: jasmine.createSpy('searchByItem'),
});
const supervisionOrder: any = {
id: '1',
type: 'supervisionOrder',
uuid: 'supervision-order-1',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const anothersupervisionOrder: any = {
id: '2',
type: 'supervisionOrder',
uuid: 'supervision-order-2',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const pageInfo = new PageInfo();
const array = [supervisionOrder, anothersupervisionOrder];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
describe('JournalIssueSearchResultListElementComponent', () => { describe('JournalIssueSearchResultListElementComponent', () => {
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe], declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{ provide: TruncatableService, useValue: {} }, { provide: TruncatableService, useValue: {} },
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{provide: NotificationsService, useValue: {}},
{provide: TranslateService, useValue: {}},
{ provide: DSONameService, useClass: DSONameServiceMock }, { provide: DSONameService, useClass: DSONameServiceMock },
{ provide: APP_CONFIG, useValue: environmentUseThumbs } { provide: APP_CONFIG, useValue: environmentUseThumbs }
], ],
@@ -87,6 +144,9 @@ describe('JournalIssueSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(JournalIssueSearchResultListElementComponent); fixture = TestBed.createComponent(JournalIssueSearchResultListElementComponent);
journalIssueListElementComponent = fixture.componentInstance; journalIssueListElementComponent = fixture.componentInstance;
@@ -164,6 +224,9 @@ describe('JournalIssueSearchResultListElementComponent', () => {
declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe], declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{provide: TruncatableService, useValue: {}}, {provide: TruncatableService, useValue: {}},
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{provide: NotificationsService, useValue: {}},
{provide: TranslateService, useValue: {}},
{provide: DSONameService, useClass: DSONameServiceMock}, {provide: DSONameService, useClass: DSONameServiceMock},
{ provide: APP_CONFIG, useValue: enviromentNoThumbs } { provide: APP_CONFIG, useValue: enviromentNoThumbs }
], ],
@@ -181,7 +244,9 @@ describe('JournalIssueSearchResultListElementComponent', () => {
describe('with environment.browseBy.showThumbnails set to false', () => { describe('with environment.browseBy.showThumbnails set to false', () => {
beforeEach(() => { beforeEach(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
journalIssueListElementComponent.object = mockItemWithMetadata; journalIssueListElementComponent.object = mockItemWithMetadata;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@@ -10,6 +10,14 @@ import { TruncatableService } from '../../../../../shared/truncatable/truncatabl
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock'; import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock';
import { APP_CONFIG } from '../../../../../../config/app-config.interface'; import { APP_CONFIG } from '../../../../../../config/app-config.interface';
import { SupervisionOrderDataService } from '../../../../../core/supervision-order/supervision-order-data.service';
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { createSuccessfulRemoteDataObject } from '../../../../../shared/remote-data.utils';
import { PageInfo } from '../../../../../core/shared/page-info.model';
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
import { GroupMock } from '../../../../../shared/testing/group-mock';
import { hot } from 'jasmine-marbles';
let journalVolumeListElementComponent: JournalVolumeSearchResultListElementComponent; let journalVolumeListElementComponent: JournalVolumeSearchResultListElementComponent;
let fixture: ComponentFixture<JournalVolumeSearchResultListElementComponent>; let fixture: ComponentFixture<JournalVolumeSearchResultListElementComponent>;
@@ -69,12 +77,61 @@ const enviromentNoThumbs = {
} }
}; };
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
searchByItem: jasmine.createSpy('searchByItem'),
});
const supervisionOrder: any = {
id: '1',
type: 'supervisionOrder',
uuid: 'supervision-order-1',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const anothersupervisionOrder: any = {
id: '2',
type: 'supervisionOrder',
uuid: 'supervision-order-2',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const pageInfo = new PageInfo();
const array = [supervisionOrder, anothersupervisionOrder];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
describe('JournalVolumeSearchResultListElementComponent', () => { describe('JournalVolumeSearchResultListElementComponent', () => {
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe], declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{ provide: TruncatableService, useValue: {} }, { provide: TruncatableService, useValue: {} },
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{ provide: NotificationsService, useValue: {}},
{ provide: TranslateService, useValue: {}},
{ provide: DSONameService, useClass: DSONameServiceMock }, { provide: DSONameService, useClass: DSONameServiceMock },
{ provide: APP_CONFIG, useValue: environmentUseThumbs } { provide: APP_CONFIG, useValue: environmentUseThumbs }
], ],
@@ -86,6 +143,9 @@ describe('JournalVolumeSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(JournalVolumeSearchResultListElementComponent); fixture = TestBed.createComponent(JournalVolumeSearchResultListElementComponent);
journalVolumeListElementComponent = fixture.componentInstance; journalVolumeListElementComponent = fixture.componentInstance;
@@ -162,6 +222,9 @@ describe('JournalVolumeSearchResultListElementComponent', () => {
declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe], declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{provide: TruncatableService, useValue: {}}, {provide: TruncatableService, useValue: {}},
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{provide: NotificationsService, useValue: {}},
{provide: TranslateService, useValue: {}},
{provide: DSONameService, useClass: DSONameServiceMock}, {provide: DSONameService, useClass: DSONameServiceMock},
{ provide: APP_CONFIG, useValue: enviromentNoThumbs } { provide: APP_CONFIG, useValue: enviromentNoThumbs }
], ],
@@ -173,6 +236,9 @@ describe('JournalVolumeSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(JournalVolumeSearchResultListElementComponent); fixture = TestBed.createComponent(JournalVolumeSearchResultListElementComponent);
journalVolumeListElementComponent = fixture.componentInstance; journalVolumeListElementComponent = fixture.componentInstance;
})); }));

View File

@@ -10,6 +10,14 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock'; import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock';
import { APP_CONFIG } from '../../../../../../config/app-config.interface'; import { APP_CONFIG } from '../../../../../../config/app-config.interface';
import { SupervisionOrderDataService } from '../../../../../core/supervision-order/supervision-order-data.service';
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { createSuccessfulRemoteDataObject } from '../../../../../shared/remote-data.utils';
import { PageInfo } from '../../../../../core/shared/page-info.model';
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
import { GroupMock } from '../../../../../shared/testing/group-mock';
import { hot } from 'jasmine-marbles';
let journalListElementComponent: JournalSearchResultListElementComponent; let journalListElementComponent: JournalSearchResultListElementComponent;
let fixture: ComponentFixture<JournalSearchResultListElementComponent>; let fixture: ComponentFixture<JournalSearchResultListElementComponent>;
@@ -65,12 +73,61 @@ const enviromentNoThumbs = {
} }
}; };
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
searchByItem: jasmine.createSpy('searchByItem'),
});
const supervisionOrder: any = {
id: '1',
type: 'supervisionOrder',
uuid: 'supervision-order-1',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const anothersupervisionOrder: any = {
id: '2',
type: 'supervisionOrder',
uuid: 'supervision-order-2',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const pageInfo = new PageInfo();
const array = [supervisionOrder, anothersupervisionOrder];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
describe('JournalSearchResultListElementComponent', () => { describe('JournalSearchResultListElementComponent', () => {
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [JournalSearchResultListElementComponent, TruncatePipe], declarations: [JournalSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{ provide: TruncatableService, useValue: {} }, { provide: TruncatableService, useValue: {} },
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{ provide: NotificationsService, useValue: {}},
{ provide: TranslateService, useValue: {}},
{ provide: DSONameService, useClass: DSONameServiceMock }, { provide: DSONameService, useClass: DSONameServiceMock },
{ provide: APP_CONFIG, useValue: environmentUseThumbs } { provide: APP_CONFIG, useValue: environmentUseThumbs }
], ],
@@ -82,6 +139,9 @@ describe('JournalSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(JournalSearchResultListElementComponent); fixture = TestBed.createComponent(JournalSearchResultListElementComponent);
journalListElementComponent = fixture.componentInstance; journalListElementComponent = fixture.componentInstance;
@@ -134,6 +194,9 @@ describe('JournalSearchResultListElementComponent', () => {
declarations: [JournalSearchResultListElementComponent, TruncatePipe], declarations: [JournalSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{provide: TruncatableService, useValue: {}}, {provide: TruncatableService, useValue: {}},
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{provide: NotificationsService, useValue: {}},
{provide: TranslateService, useValue: {}},
{provide: DSONameService, useClass: DSONameServiceMock}, {provide: DSONameService, useClass: DSONameServiceMock},
{ provide: APP_CONFIG, useValue: enviromentNoThumbs } { provide: APP_CONFIG, useValue: enviromentNoThumbs }
], ],
@@ -145,6 +208,9 @@ describe('JournalSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(JournalSearchResultListElementComponent); fixture = TestBed.createComponent(JournalSearchResultListElementComponent);
journalListElementComponent = fixture.componentInstance; journalListElementComponent = fixture.componentInstance;
})); }));

View File

@@ -12,6 +12,13 @@ import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service
import { APP_CONFIG } from '../../../../../../config/app-config.interface'; import { APP_CONFIG } from '../../../../../../config/app-config.interface';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateLoaderMock } from '../../../../../shared/mocks/translate-loader.mock'; import { TranslateLoaderMock } from '../../../../../shared/mocks/translate-loader.mock';
import { SupervisionOrderDataService } from '../../../../../core/supervision-order/supervision-order-data.service';
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject } from '../../../../../shared/remote-data.utils';
import { PageInfo } from '../../../../../core/shared/page-info.model';
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
import { GroupMock } from '../../../../../shared/testing/group-mock';
import { hot } from 'jasmine-marbles';
let orgUnitListElementComponent: OrgUnitSearchResultListElementComponent; let orgUnitListElementComponent: OrgUnitSearchResultListElementComponent;
let fixture: ComponentFixture<OrgUnitSearchResultListElementComponent>; let fixture: ComponentFixture<OrgUnitSearchResultListElementComponent>;
@@ -65,6 +72,52 @@ const enviromentNoThumbs = {
} }
}; };
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
searchByItem: jasmine.createSpy('searchByItem'),
});
const supervisionOrder: any = {
id: '1',
type: 'supervisionOrder',
uuid: 'supervision-order-1',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const anothersupervisionOrder: any = {
id: '2',
type: 'supervisionOrder',
uuid: 'supervision-order-2',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const pageInfo = new PageInfo();
const array = [supervisionOrder, anothersupervisionOrder];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
describe('OrgUnitSearchResultListElementComponent', () => { describe('OrgUnitSearchResultListElementComponent', () => {
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
@@ -78,6 +131,8 @@ describe('OrgUnitSearchResultListElementComponent', () => {
declarations: [ OrgUnitSearchResultListElementComponent , TruncatePipe], declarations: [ OrgUnitSearchResultListElementComponent , TruncatePipe],
providers: [ providers: [
{ provide: TruncatableService, useValue: {} }, { provide: TruncatableService, useValue: {} },
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{provide: NotificationsService, useValue: {}},
{ provide: DSONameService, useClass: DSONameServiceMock }, { provide: DSONameService, useClass: DSONameServiceMock },
{ provide: APP_CONFIG, useValue: environmentUseThumbs } { provide: APP_CONFIG, useValue: environmentUseThumbs }
], ],
@@ -89,6 +144,9 @@ describe('OrgUnitSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(OrgUnitSearchResultListElementComponent); fixture = TestBed.createComponent(OrgUnitSearchResultListElementComponent);
orgUnitListElementComponent = fixture.componentInstance; orgUnitListElementComponent = fixture.componentInstance;
@@ -148,6 +206,8 @@ describe('OrgUnitSearchResultListElementComponent', () => {
declarations: [OrgUnitSearchResultListElementComponent, TruncatePipe], declarations: [OrgUnitSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{provide: TruncatableService, useValue: {}}, {provide: TruncatableService, useValue: {}},
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{provide: NotificationsService, useValue: {}},
{provide: DSONameService, useClass: DSONameServiceMock}, {provide: DSONameService, useClass: DSONameServiceMock},
{ provide: APP_CONFIG, useValue: enviromentNoThumbs } { provide: APP_CONFIG, useValue: enviromentNoThumbs }
], ],
@@ -165,7 +225,9 @@ describe('OrgUnitSearchResultListElementComponent', () => {
describe('with environment.browseBy.showThumbnails set to false', () => { describe('with environment.browseBy.showThumbnails set to false', () => {
beforeEach(() => { beforeEach(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
orgUnitListElementComponent.object = mockItemWithMetadata; orgUnitListElementComponent.object = mockItemWithMetadata;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@@ -12,9 +12,19 @@ import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service
import { APP_CONFIG } from '../../../../../../config/app-config.interface'; import { APP_CONFIG } from '../../../../../../config/app-config.interface';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateLoaderMock } from '../../../../../shared/mocks/translate-loader.mock'; import { TranslateLoaderMock } from '../../../../../shared/mocks/translate-loader.mock';
import { SupervisionOrderDataService } from '../../../../../core/supervision-order/supervision-order-data.service';
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject } from '../../../../../shared/remote-data.utils';
import { hot } from 'jasmine-marbles';
import { PageInfo } from '../../../../../core/shared/page-info.model';
import { GroupMock } from '../../../../../shared/testing/group-mock';
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
let personListElementComponent: PersonSearchResultListElementComponent; let personListElementComponent: PersonSearchResultListElementComponent;
let fixture: ComponentFixture<PersonSearchResultListElementComponent>; let fixture: ComponentFixture<PersonSearchResultListElementComponent>;
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
searchByItem: jasmine.createSpy('searchByItem'),
});
const mockItemWithMetadata: ItemSearchResult = Object.assign( const mockItemWithMetadata: ItemSearchResult = Object.assign(
new ItemSearchResult(), new ItemSearchResult(),
@@ -65,6 +75,48 @@ const enviromentNoThumbs = {
} }
}; };
const supervisionOrder: any = {
id: '1',
type: 'supervisionOrder',
uuid: 'supervision-order-1',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const anothersupervisionOrder: any = {
id: '2',
type: 'supervisionOrder',
uuid: 'supervision-order-2',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const pageInfo = new PageInfo();
const array = [supervisionOrder, anothersupervisionOrder];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
describe('PersonSearchResultListElementComponent', () => { describe('PersonSearchResultListElementComponent', () => {
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
@@ -78,6 +130,8 @@ describe('PersonSearchResultListElementComponent', () => {
declarations: [PersonSearchResultListElementComponent, TruncatePipe], declarations: [PersonSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{ provide: TruncatableService, useValue: {} }, { provide: TruncatableService, useValue: {} },
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{ provide: NotificationsService, useValue: {} },
{ provide: DSONameService, useClass: DSONameServiceMock }, { provide: DSONameService, useClass: DSONameServiceMock },
{ provide: APP_CONFIG, useValue: environmentUseThumbs } { provide: APP_CONFIG, useValue: environmentUseThumbs }
], ],
@@ -89,6 +143,9 @@ describe('PersonSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(PersonSearchResultListElementComponent); fixture = TestBed.createComponent(PersonSearchResultListElementComponent);
personListElementComponent = fixture.componentInstance; personListElementComponent = fixture.componentInstance;
@@ -148,6 +205,8 @@ describe('PersonSearchResultListElementComponent', () => {
declarations: [PersonSearchResultListElementComponent, TruncatePipe], declarations: [PersonSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{provide: TruncatableService, useValue: {}}, {provide: TruncatableService, useValue: {}},
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService},
{provide: NotificationsService, useValue: {}},
{provide: DSONameService, useClass: DSONameServiceMock}, {provide: DSONameService, useClass: DSONameServiceMock},
{ provide: APP_CONFIG, useValue: enviromentNoThumbs } { provide: APP_CONFIG, useValue: enviromentNoThumbs }
], ],
@@ -165,7 +224,9 @@ describe('PersonSearchResultListElementComponent', () => {
describe('with environment.browseBy.showThumbnails set to false', () => { describe('with environment.browseBy.showThumbnails set to false', () => {
beforeEach(() => { beforeEach(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
personListElementComponent.object = mockItemWithMetadata; personListElementComponent.object = mockItemWithMetadata;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@@ -9,6 +9,10 @@ import {
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service'; import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
import { APP_CONFIG, AppConfig } from '../../../../../../config/app-config.interface'; import { APP_CONFIG, AppConfig } from '../../../../../../config/app-config.interface';
import { SupervisionOrderDataService } from '../../../../../core/supervision-order/supervision-order-data.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
@listableObjectComponent('PersonSearchResult', ViewMode.ListElement) @listableObjectComponent('PersonSearchResult', ViewMode.ListElement)
@Component({ @Component({
@@ -24,9 +28,13 @@ export class PersonSearchResultListElementComponent extends ItemSearchResultList
public constructor( public constructor(
protected truncatableService: TruncatableService, protected truncatableService: TruncatableService,
protected dsoNameService: DSONameService, protected dsoNameService: DSONameService,
@Inject(APP_CONFIG) protected appConfig: AppConfig @Inject(APP_CONFIG) protected appConfig: AppConfig,
protected supervisionOrderDataService: SupervisionOrderDataService,
protected modalService: NgbModal,
protected notificationsService: NotificationsService,
protected translateService: TranslateService,
) { ) {
super(truncatableService, dsoNameService, appConfig); super(truncatableService, dsoNameService, appConfig, supervisionOrderDataService, modalService, notificationsService, translateService);
} }
/** /**

View File

@@ -10,6 +10,14 @@ import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service
import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock'; import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { APP_CONFIG } from '../../../../../../config/app-config.interface'; import { APP_CONFIG } from '../../../../../../config/app-config.interface';
import { SupervisionOrderDataService } from '../../../../../core/supervision-order/supervision-order-data.service';
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { createSuccessfulRemoteDataObject } from '../../../../../shared/remote-data.utils';
import { PageInfo } from '../../../../../core/shared/page-info.model';
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
import { GroupMock } from '../../../../../shared/testing/group-mock';
import { hot } from 'jasmine-marbles';
let projectListElementComponent: ProjectSearchResultListElementComponent; let projectListElementComponent: ProjectSearchResultListElementComponent;
let fixture: ComponentFixture<ProjectSearchResultListElementComponent>; let fixture: ComponentFixture<ProjectSearchResultListElementComponent>;
@@ -64,12 +72,61 @@ const enviromentNoThumbs = {
} }
}; };
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
searchByItem: jasmine.createSpy('searchByItem'),
});
const supervisionOrder: any = {
id: '1',
type: 'supervisionOrder',
uuid: 'supervision-order-1',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const anothersupervisionOrder: any = {
id: '2',
type: 'supervisionOrder',
uuid: 'supervision-order-2',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const pageInfo = new PageInfo();
const array = [supervisionOrder, anothersupervisionOrder];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
describe('ProjectSearchResultListElementComponent', () => { describe('ProjectSearchResultListElementComponent', () => {
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ProjectSearchResultListElementComponent, TruncatePipe], declarations: [ProjectSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{ provide: TruncatableService, useValue: {} }, { provide: TruncatableService, useValue: {} },
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{ provide: NotificationsService, useValue: {}},
{provide: TranslateService, useValue: {}},
{ provide: DSONameService, useClass: DSONameServiceMock }, { provide: DSONameService, useClass: DSONameServiceMock },
{ provide: APP_CONFIG, useValue: environmentUseThumbs } { provide: APP_CONFIG, useValue: environmentUseThumbs }
], ],
@@ -81,6 +138,9 @@ describe('ProjectSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(ProjectSearchResultListElementComponent); fixture = TestBed.createComponent(ProjectSearchResultListElementComponent);
projectListElementComponent = fixture.componentInstance; projectListElementComponent = fixture.componentInstance;
@@ -133,6 +193,9 @@ describe('ProjectSearchResultListElementComponent', () => {
declarations: [ProjectSearchResultListElementComponent, TruncatePipe], declarations: [ProjectSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{provide: TruncatableService, useValue: {}}, {provide: TruncatableService, useValue: {}},
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{provide: NotificationsService, useValue: {}},
{provide: TranslateService, useValue: {}},
{provide: DSONameService, useClass: DSONameServiceMock}, {provide: DSONameService, useClass: DSONameServiceMock},
{ provide: APP_CONFIG, useValue: enviromentNoThumbs } { provide: APP_CONFIG, useValue: enviromentNoThumbs }
@@ -151,7 +214,9 @@ describe('ProjectSearchResultListElementComponent', () => {
describe('with environment.browseBy.showThumbnails set to false', () => { describe('with environment.browseBy.showThumbnails set to false', () => {
beforeEach(() => { beforeEach(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
projectListElementComponent.object = mockItemWithMetadata; projectListElementComponent.object = mockItemWithMetadata;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@@ -1,4 +1,5 @@
export enum MyDSpaceConfigurationValueType { export enum MyDSpaceConfigurationValueType {
Workspace = 'workspace', Workspace = 'workspace',
SupervisedItems = 'otherworkspace',
Workflow = 'workflow' Workflow = 'workflow'
} }

View File

@@ -184,7 +184,8 @@ describe('MyDSpaceConfigurationService', () => {
expect(list$).toBeObservable(cold('(b|)', { expect(list$).toBeObservable(cold('(b|)', {
b: [ b: [
MyDSpaceConfigurationValueType.Workspace MyDSpaceConfigurationValueType.Workspace,
MyDSpaceConfigurationValueType.SupervisedItems
] ]
})); }));
}); });
@@ -227,6 +228,7 @@ describe('MyDSpaceConfigurationService', () => {
expect(list$).toBeObservable(cold('(b|)', { expect(list$).toBeObservable(cold('(b|)', {
b: [ b: [
MyDSpaceConfigurationValueType.Workspace, MyDSpaceConfigurationValueType.Workspace,
MyDSpaceConfigurationValueType.SupervisedItems,
MyDSpaceConfigurationValueType.Workflow MyDSpaceConfigurationValueType.Workflow
] ]
})); }));

View File

@@ -20,6 +20,7 @@ import { Context } from '../core/shared/context.model';
export const MyDSpaceConfigurationToContextMap = new Map([ export const MyDSpaceConfigurationToContextMap = new Map([
[MyDSpaceConfigurationValueType.Workspace, Context.Workspace], [MyDSpaceConfigurationValueType.Workspace, Context.Workspace],
[MyDSpaceConfigurationValueType.SupervisedItems, Context.SupervisedItems],
[MyDSpaceConfigurationValueType.Workflow, Context.Workflow] [MyDSpaceConfigurationValueType.Workflow, Context.Workflow]
]); ]);
@@ -107,6 +108,7 @@ export class MyDSpaceConfigurationService extends SearchConfigurationService {
const availableConf: MyDSpaceConfigurationValueType[] = []; const availableConf: MyDSpaceConfigurationValueType[] = [];
if (isSubmitter) { if (isSubmitter) {
availableConf.push(MyDSpaceConfigurationValueType.Workspace); availableConf.push(MyDSpaceConfigurationValueType.Workspace);
availableConf.push(MyDSpaceConfigurationValueType.SupervisedItems);
} }
if (isController || isAdmin) { if (isController || isAdmin) {
availableConf.push(MyDSpaceConfigurationValueType.Workflow); availableConf.push(MyDSpaceConfigurationValueType.Workflow);

View File

@@ -0,0 +1,40 @@
<div>
<div class="modal-header">{{'supervision-group-selector.header' | translate}}
<button type="button" class="close" (click)="close()" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="control-group col-sm-12">
<label for="supervisionOrder">{{'supervision-group-selector.select.type-of-order.label' | translate}}</label>
<select name="supervisionOrder" id="supervisionOrder" class="form-control"
[(ngModel)]="selectedOrderType"
attr.aria-label="{{'supervision-group-selector.select.type-of-order.label' | translate}}">
<option value="NONE">{{'supervision-group-selector.select.type-of-order.option.none' | translate}}</option>
<option value="EDITOR">{{'supervision-group-selector.select.type-of-order.option.editor' | translate}}</option>
<option value="OBSERVER">{{'supervision-group-selector.select.type-of-order.option.observer' | translate}}</option>
</select>
<ds-error *ngIf="isSubmitted && (!selectedOrderType || selectedOrderType === '')"
message="{{'supervision-group-selector.select.type-of-order.error' | translate}}"></ds-error>
</div>
</div>
<div class="row">
<div class="control-group col-sm-12">
<label for="supervisionGroup">{{'supervision-group-selector.select.group.label' | translate}}</label>
<ng-container class="mb-3">
<input id="supervisionGroup" class="form-control" type="text" [value]="selectedGroup ? dsoNameService.getName(selectedGroup) : ''" disabled>
<ds-error *ngIf="isSubmitted && !selectedGroup" message="{{'supervision-group-selector.select.group.error' | translate}}"></ds-error>
</ng-container>
<ds-eperson-group-list [isListOfEPerson]="false"
(select)="updateGroupObjectSelected($event)"></ds-eperson-group-list>
</div>
</div>
<div class="d-flex flex-row-reverse m-2">
<button class="btn btn-primary save"
(click)="save()">
<i class="fas fa-save"></i> {{"supervision-group-selector.button.save" | translate}}
</button>
</div>
</div>
</div>

View File

@@ -0,0 +1,70 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { SupervisionGroupSelectorComponent } from './supervision-group-selector.component';
import { SupervisionOrderDataService } from '../../../../core/supervision-order/supervision-order-data.service';
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { Group } from '../../../../core/eperson/models/group.model';
import { SupervisionOrder } from '../../../../core/supervision-order/models/supervision-order.model';
import { of } from 'rxjs';
describe('SupervisionGroupSelectorComponent', () => {
let component: SupervisionGroupSelectorComponent;
let fixture: ComponentFixture<SupervisionGroupSelectorComponent>;
let debugElement: DebugElement;
const modalStub = jasmine.createSpyObj('modalStub', ['close']);
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
create: of(new SupervisionOrder())
});
const selectedOrderType = 'NONE';
const itemUUID = 'itemUUID1234';
const selectedGroup = new Group();
selectedGroup.uuid = 'GroupUUID1234';
const supervisionDataObject = new SupervisionOrder();
supervisionDataObject.ordertype = selectedOrderType;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()],
declarations: [SupervisionGroupSelectorComponent],
providers: [
{ provide: NgbActiveModal, useValue: modalStub },
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{ provide: NotificationsService, useValue: {} },
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
}));
beforeEach(waitForAsync(() => {
fixture = TestBed.createComponent(SupervisionGroupSelectorComponent);
component = fixture.componentInstance;
}));
beforeEach(() => {
component.itemUUID = itemUUID;
component.selectedGroup = selectedGroup;
component.selectedOrderType = selectedOrderType;
debugElement = fixture.debugElement;
fixture.detectChanges();
});
it('should create component', () => {
expect(component).toBeTruthy();
});
it('should call create for supervision order', () => {
component.save();
fixture.detectChanges();
expect(supervisionOrderDataService.create).toHaveBeenCalledWith(supervisionDataObject, itemUUID, selectedGroup.uuid, selectedOrderType);
});
});

View File

@@ -0,0 +1,90 @@
import { Component } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { getFirstCompletedRemoteData } from 'src/app/core/shared/operators';
import { NotificationsService } from 'src/app/shared/notifications/notifications.service';
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
import { Group } from '../../../../core/eperson/models/group.model';
import { SupervisionOrder } from '../../../../core/supervision-order/models/supervision-order.model';
import { SupervisionOrderDataService } from '../../../../core/supervision-order/supervision-order-data.service';
/**
* Component to wrap a dropdown - for type of order -
* and a list of groups
* inside a modal
* Used to create a new supervision order
*/
@Component({
selector: 'ds-supervision-group-selector',
styleUrls: ['./supervision-group-selector.component.scss'],
templateUrl: './supervision-group-selector.component.html',
})
export class SupervisionGroupSelectorComponent {
/**
* The item to perform the actions on
*/
itemUUID: string;
/**
* The selected supervision order type
*/
selectedOrderType: string;
/**
* selected group for supervision
*/
selectedGroup: Group;
/**
* boolean flag for the validations
*/
isSubmitted = false;
constructor(
public dsoNameService: DSONameService,
private activeModal: NgbActiveModal,
private supervisionOrderDataService: SupervisionOrderDataService,
protected notificationsService: NotificationsService,
protected translateService: TranslateService,
) { }
/**
* Close the modal
*/
close() {
this.activeModal.close();
}
/**
* Assign the value of group on select
*/
updateGroupObjectSelected(object) {
this.selectedGroup = object;
}
/**
* Save the supervision order
*/
save() {
this.isSubmitted = true;
if (this.selectedOrderType && this.selectedGroup) {
let supervisionDataObject = new SupervisionOrder();
supervisionDataObject.ordertype = this.selectedOrderType;
this.supervisionOrderDataService.create(supervisionDataObject, this.itemUUID, this.selectedGroup.uuid, this.selectedOrderType).pipe(
getFirstCompletedRemoteData(),
).subscribe(rd => {
if (rd.state === 'Success') {
this.notificationsService.success(this.translateService.get('supervision-group-selector.notification.create.success.title', { name: this.selectedGroup.name }));
} else {
this.notificationsService.error(
this.translateService.get('supervision-group-selector.notification.create.failure.title'),
rd.errorMessage);
}
});
this.close();
}
}
}

View File

@@ -6,21 +6,21 @@ import { TranslateModule } from '@ngx-translate/core';
import { cold } from 'jasmine-marbles'; import { cold } from 'jasmine-marbles';
import uniqueId from 'lodash/uniqueId'; import uniqueId from 'lodash/uniqueId';
import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; import { createSuccessfulRemoteDataObject } from '../../remote-data.utils';
import { createTestComponent } from '../../../testing/utils.test'; import { createTestComponent } from '../../testing/utils.test';
import { EPersonDataService } from '../../../../core/eperson/eperson-data.service'; import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
import { GroupDataService } from '../../../../core/eperson/group-data.service'; import { GroupDataService } from '../../../core/eperson/group-data.service';
import { RequestService } from '../../../../core/data/request.service'; import { RequestService } from '../../../core/data/request.service';
import { getMockRequestService } from '../../../mocks/request.service.mock'; import { getMockRequestService } from '../../mocks/request.service.mock';
import { EpersonGroupListComponent, SearchEvent } from './eperson-group-list.component'; import { EpersonGroupListComponent, SearchEvent } from './eperson-group-list.component';
import { EPersonMock } from '../../../testing/eperson.mock'; import { EPersonMock } from '../../testing/eperson.mock';
import { GroupMock } from '../../../testing/group-mock'; import { GroupMock } from '../../testing/group-mock';
import { PaginationComponentOptions } from '../../../pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model';
import { buildPaginatedList } from '../../../../core/data/paginated-list.model'; import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { PageInfo } from '../../../../core/shared/page-info.model'; import { PageInfo } from '../../../core/shared/page-info.model';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { PaginationService } from '../../../../core/pagination/pagination.service'; import { PaginationService } from '../../../core/pagination/pagination.service';
import { PaginationServiceStub } from '../../../testing/pagination-service.stub'; import { PaginationServiceStub } from '../../testing/pagination-service.stub';
describe('EpersonGroupListComponent test suite', () => { describe('EpersonGroupListComponent test suite', () => {
let comp: EpersonGroupListComponent; let comp: EpersonGroupListComponent;

View File

@@ -4,22 +4,22 @@ import { BehaviorSubject, Observable, Subscription } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import uniqueId from 'lodash/uniqueId'; import uniqueId from 'lodash/uniqueId';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../../core/data/paginated-list.model'; import { PaginatedList } from '../../../core/data/paginated-list.model';
import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model';
import { PaginationComponentOptions } from '../../../pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model';
import { hasValue, isNotEmpty } from '../../../empty.util'; import { hasValue, isNotEmpty } from '../../empty.util';
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service'; import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
import { EPERSON } from '../../../../core/eperson/models/eperson.resource-type'; import { EPERSON } from '../../../core/eperson/models/eperson.resource-type';
import { GROUP } from '../../../../core/eperson/models/group.resource-type'; import { GROUP } from '../../../core/eperson/models/group.resource-type';
import { ResourceType } from '../../../../core/shared/resource-type'; import { ResourceType } from '../../../core/shared/resource-type';
import { EPersonDataService } from '../../../../core/eperson/eperson-data.service'; import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
import { GroupDataService } from '../../../../core/eperson/group-data.service'; import { GroupDataService } from '../../../core/eperson/group-data.service';
import { fadeInOut } from '../../../animations/fade'; import { fadeInOut } from '../../animations/fade';
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators'; import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
import { PaginationService } from '../../../../core/pagination/pagination.service'; import { PaginationService } from '../../../core/pagination/pagination.service';
import { FindListOptions } from '../../../../core/data/find-list-options.model'; import { FindListOptions } from '../../../core/data/find-list-options.model';
import { getDataServiceFor } from '../../../../core/data/base/data-service.decorator'; import { getDataServiceFor } from '../../../core/data/base/data-service.decorator';
export interface SearchEvent { export interface SearchEvent {
scope: string; scope: string;

View File

@@ -4,7 +4,7 @@ import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { createTestComponent } from '../../../../testing/utils.test'; import { createTestComponent } from '../../../testing/utils.test';
import { EpersonSearchBoxComponent } from './eperson-search-box.component'; import { EpersonSearchBoxComponent } from './eperson-search-box.component';
import { SearchEvent } from '../eperson-group-list.component'; import { SearchEvent } from '../eperson-group-list.component';

View File

@@ -4,7 +4,7 @@ import { FormBuilder } from '@angular/forms';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { SearchEvent } from '../eperson-group-list.component'; import { SearchEvent } from '../eperson-group-list.component';
import { isNotNull } from '../../../../empty.util'; import { isNotNull } from '../../../empty.util';
/** /**
* A component used to show a search box for epersons. * A component used to show a search box for epersons.

View File

@@ -4,7 +4,7 @@ import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { createTestComponent } from '../../../../testing/utils.test'; import { createTestComponent } from '../../../testing/utils.test';
import { GroupSearchBoxComponent } from './group-search-box.component'; import { GroupSearchBoxComponent } from './group-search-box.component';
import { SearchEvent } from '../eperson-group-list.component'; import { SearchEvent } from '../eperson-group-list.component';

View File

@@ -4,7 +4,7 @@ import { FormBuilder } from '@angular/forms';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { SearchEvent } from '../eperson-group-list.component'; import { SearchEvent } from '../eperson-group-list.component';
import { isNotNull } from '../../../../empty.util'; import { isNotNull } from '../../../empty.util';
/** /**
* A component used to show a search box for groups. * A component used to show a search box for groups.

View File

@@ -41,6 +41,19 @@
[innerHTML]="firstMetadataValue('dc.description.abstract')"></span> [innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
</ds-truncatable-part> </ds-truncatable-part>
</div> </div>
<ng-container *ngVar="(supervisionOrder$ | async) as supervisionOrders">
<div class="item-list-supervision row" *ngIf="supervisionOrders?.length > 0">
<div class="col-md-3">
<span>{{'item.search.result.list.element.supervised-by' | translate}} </span>
</div>
<div class="col-md-9">
<span class="badge badge-primary d-table mt-1" *ngFor="let supervisionOrder of supervisionOrders">
{{supervisionOrder.group._name}}
<a [ngbTooltip]="'Remove supervision group'" (click)="deleteSupervisionOrder(supervisionOrder)">X</a>
</span>
</div>
</div>
</ng-container>
</ds-truncatable> </ds-truncatable>
</div> </div>
</div> </div>

View File

@@ -1 +1,7 @@
@import '../../../../../../../styles/variables'; @import '../../../../../../../styles/variables';
.item-list-supervision {
a {
cursor: pointer;
}
}

View File

@@ -10,6 +10,14 @@ import { ItemSearchResult } from '../../../../../object-collection/shared/item-s
import { DSONameService } from '../../../../../../core/breadcrumbs/dso-name.service'; import { DSONameService } from '../../../../../../core/breadcrumbs/dso-name.service';
import { DSONameServiceMock, UNDEFINED_NAME } from '../../../../../mocks/dso-name.service.mock'; import { DSONameServiceMock, UNDEFINED_NAME } from '../../../../../mocks/dso-name.service.mock';
import { APP_CONFIG } from '../../../../../../../config/app-config.interface'; import { APP_CONFIG } from '../../../../../../../config/app-config.interface';
import { SupervisionOrderDataService } from '../../../../../../core/supervision-order/supervision-order-data.service';
import { NotificationsService } from '../../../../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { createSuccessfulRemoteDataObject } from '../../../../../../shared/remote-data.utils';
import { PageInfo } from '../../../../../../core/shared/page-info.model';
import { buildPaginatedList } from '../../../../../../core/data/paginated-list.model';
import { GroupMock } from '../../../../../../shared/testing/group-mock';
import { hot } from 'jasmine-marbles';
let publicationListElementComponent: ItemSearchResultListElementComponent; let publicationListElementComponent: ItemSearchResultListElementComponent;
let fixture: ComponentFixture<ItemSearchResultListElementComponent>; let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
@@ -72,12 +80,61 @@ const enviromentNoThumbs = {
} }
}; };
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
searchByItem: jasmine.createSpy('searchByItem'),
});
const supervisionOrder: any = {
id: '1',
type: 'supervisionOrder',
uuid: 'supervision-order-1',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const anothersupervisionOrder: any = {
id: '2',
type: 'supervisionOrder',
uuid: 'supervision-order-2',
_links: {
item: {
href: 'https://rest.api/rest/api/eperson'
},
group: {
href: 'https://rest.api/rest/api/group'
},
self: {
href: 'https://rest.api/rest/api/supervisionorders/1'
},
},
item: observableOf(createSuccessfulRemoteDataObject({})),
group: observableOf(createSuccessfulRemoteDataObject(GroupMock))
};
const pageInfo = new PageInfo();
const array = [supervisionOrder, anothersupervisionOrder];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
describe('ItemSearchResultListElementComponent', () => { describe('ItemSearchResultListElementComponent', () => {
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ItemSearchResultListElementComponent, TruncatePipe], declarations: [ItemSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{ provide: TruncatableService, useValue: {} }, { provide: TruncatableService, useValue: {} },
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{ provide: NotificationsService, useValue: {}},
{ provide: TranslateService, useValue: {}},
{ provide: DSONameService, useClass: DSONameServiceMock }, { provide: DSONameService, useClass: DSONameServiceMock },
{ provide: APP_CONFIG, useValue: environmentUseThumbs } { provide: APP_CONFIG, useValue: environmentUseThumbs }
], ],
@@ -89,6 +146,9 @@ describe('ItemSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(ItemSearchResultListElementComponent); fixture = TestBed.createComponent(ItemSearchResultListElementComponent);
publicationListElementComponent = fixture.componentInstance; publicationListElementComponent = fixture.componentInstance;
@@ -225,6 +285,9 @@ describe('ItemSearchResultListElementComponent', () => {
declarations: [ItemSearchResultListElementComponent, TruncatePipe], declarations: [ItemSearchResultListElementComponent, TruncatePipe],
providers: [ providers: [
{provide: TruncatableService, useValue: {}}, {provide: TruncatableService, useValue: {}},
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
{provide: NotificationsService, useValue: {}},
{provide: TranslateService, useValue: {}},
{provide: DSONameService, useClass: DSONameServiceMock}, {provide: DSONameService, useClass: DSONameServiceMock},
{ provide: APP_CONFIG, useValue: enviromentNoThumbs } { provide: APP_CONFIG, useValue: enviromentNoThumbs }
], ],
@@ -236,6 +299,9 @@ describe('ItemSearchResultListElementComponent', () => {
})); }));
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', {
a: paginatedListRD
}));
fixture = TestBed.createComponent(ItemSearchResultListElementComponent); fixture = TestBed.createComponent(ItemSearchResultListElementComponent);
publicationListElementComponent = fixture.componentInstance; publicationListElementComponent = fixture.componentInstance;
})); }));

View File

@@ -1,10 +1,24 @@
import { Component } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { listableObjectComponent } from '../../../../../object-collection/shared/listable-object/listable-object.decorator'; import { listableObjectComponent } from '../../../../../object-collection/shared/listable-object/listable-object.decorator';
import { ViewMode } from '../../../../../../core/shared/view-mode.model'; import { ViewMode } from '../../../../../../core/shared/view-mode.model';
import { ItemSearchResult } from '../../../../../object-collection/shared/item-search-result.model'; import { ItemSearchResult } from '../../../../../object-collection/shared/item-search-result.model';
import { SearchResultListElementComponent } from '../../../search-result-list-element.component'; import { SearchResultListElementComponent } from '../../../search-result-list-element.component';
import { Item } from '../../../../../../core/shared/item.model'; import { Item } from '../../../../../../core/shared/item.model';
import { getItemPageRoute } from '../../../../../../item-page/item-page-routing-paths'; import { getItemPageRoute } from '../../../../../../item-page/item-page-routing-paths';
import { SupervisionOrderDataService } from '../../../../../../core/supervision-order/supervision-order-data.service';
import { TruncatableService } from '../../../../../../shared/truncatable/truncatable.service';
import { DSONameService } from '../../../../../../core/breadcrumbs/dso-name.service';
import { AppConfig, APP_CONFIG } from '../../../../../../../config/app-config.interface';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { combineLatest, map, Observable, switchMap, take } from 'rxjs';
import { ConfirmationModalComponent } from '../../../../../../shared/confirmation-modal/confirmation-modal.component';
import { hasValue } from '../../../../../../shared/empty.util';
import { NotificationsService } from '../../../../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { followLink } from '../../../../../../shared/utils/follow-link-config.model';
import { getAllSucceededRemoteListPayload, getFirstSucceededRemoteDataPayload } from '../../../../../../core/shared/operators';
import { SupervisionOrder } from '../../../../../../core/supervision-order/models/supervision-order.model';
import { Group } from '../../../../../../core/eperson/models/group.model';
@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement) @listableObjectComponent('PublicationSearchResult', ViewMode.ListElement)
@listableObjectComponent(ItemSearchResult, ViewMode.ListElement) @listableObjectComponent(ItemSearchResult, ViewMode.ListElement)
@@ -17,6 +31,8 @@ import { getItemPageRoute } from '../../../../../../item-page/item-page-routing-
* The component for displaying a list element for an item search result of the type Publication * The component for displaying a list element for an item search result of the type Publication
*/ */
export class ItemSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> { export class ItemSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
messagePrefix = 'item.search.result';
/** /**
* Route to the item's page * Route to the item's page
*/ */
@@ -27,9 +43,67 @@ export class ItemSearchResultListElementComponent extends SearchResultListElemen
*/ */
showThumbnails: boolean; showThumbnails: boolean;
/**
* List of the supervision orders combined with the group
*/
supervisionOrder$: Observable<{ supervisionOrder: SupervisionOrder; group: Group; }[]>;
constructor(
protected truncatableService: TruncatableService,
protected dsoNameService: DSONameService,
@Inject(APP_CONFIG) protected appConfig: AppConfig,
protected supervisionOrderDataService: SupervisionOrderDataService,
protected modalService: NgbModal,
protected notificationsService: NotificationsService,
protected translateService: TranslateService,
) { super(truncatableService, dsoNameService, appConfig); }
ngOnInit(): void { ngOnInit(): void {
super.ngOnInit(); super.ngOnInit();
this.showThumbnails = this.appConfig.browseBy.showThumbnails; this.showThumbnails = this.appConfig.browseBy.showThumbnails;
this.itemPageRoute = getItemPageRoute(this.dso); this.itemPageRoute = getItemPageRoute(this.dso);
this.supervisionOrder$ = this.supervisionOrderDataService.searchByItem(this.dso.uuid, null, null, followLink('group')).pipe(
getAllSucceededRemoteListPayload(),
switchMap((supervisionOrders: SupervisionOrder[]) => {
const supervisionOrdersArray = supervisionOrders.map((supervisionOrder: SupervisionOrder) => {
return supervisionOrder.group.pipe(
getFirstSucceededRemoteDataPayload(),
map((group: Group) => ({ supervisionOrder, group }))
);
});
return combineLatest(supervisionOrdersArray);
})
);
}
/**
* Deletes the Group from the Repository. The Group will be the only that this form is showing.
* It'll either show a success or error message depending on whether the delete was successful or not.
*/
deleteSupervisionOrder(supervisionOrder) {
const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = supervisionOrder.group;
modalRef.componentInstance.headerLabel = this.messagePrefix + '.delete-supervision.modal.header';
modalRef.componentInstance.infoLabel = this.messagePrefix + '.delete-supervision.modal.info';
modalRef.componentInstance.cancelLabel = this.messagePrefix + '.delete-supervision.modal.cancel';
modalRef.componentInstance.confirmLabel = this.messagePrefix + '.delete-supervision.modal.confirm';
modalRef.componentInstance.brandColor = 'danger';
modalRef.componentInstance.confirmIcon = 'fas fa-trash';
modalRef.componentInstance.response.pipe(take(1)).subscribe((confirm: boolean) => {
if (confirm) {
if (hasValue(supervisionOrder.supervisionOrder.id)) {
this.supervisionOrderDataService.delete(supervisionOrder.supervisionOrder.id)
.subscribe((rd: boolean) => {
if (rd) {
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.deleted.success', { name: supervisionOrder.group._name }));
} else {
this.notificationsService.error(
this.translateService.get(this.messagePrefix + '.notification.deleted.failure.title', { name: supervisionOrder.group._name }),
this.translateService.get(this.messagePrefix + '.notification.deleted.failure.content'));
}
});
}
}
});
} }
} }

View File

@@ -24,7 +24,7 @@ import { ResourcePolicyEvent, ResourcePolicyFormComponent } from './resource-pol
import { FormService } from '../../form/form.service'; import { FormService } from '../../form/form.service';
import { getMockFormService } from '../../mocks/form-service.mock'; import { getMockFormService } from '../../mocks/form-service.mock';
import { FormBuilderService } from '../../form/builder/form-builder.service'; import { FormBuilderService } from '../../form/builder/form-builder.service';
import { EpersonGroupListComponent } from './eperson-group-list/eperson-group-list.component'; import { EpersonGroupListComponent } from '../../form/eperson-group-list/eperson-group-list.component';
import { FormComponent } from '../../form/form.component'; import { FormComponent } from '../../form/form.component';
import { stringToNgbDateStruct, dateToISOFormat } from '../../date.util'; import { stringToNgbDateStruct, dateToISOFormat } from '../../date.util';
import { ResourcePolicy } from '../../../core/resource-policy/models/resource-policy.model'; import { ResourcePolicy } from '../../../core/resource-policy/models/resource-policy.model';

View File

@@ -10,9 +10,6 @@ import { ResourcePolicyCreateComponent } from './create/resource-policy-create.c
import { FormModule } from '../form/form.module'; import { FormModule } from '../form/form.module';
import { ResourcePolicyResolver } from './resolvers/resource-policy.resolver'; import { ResourcePolicyResolver } from './resolvers/resource-policy.resolver';
import { ResourcePolicyTargetResolver } from './resolvers/resource-policy-target.resolver'; import { ResourcePolicyTargetResolver } from './resolvers/resource-policy-target.resolver';
import { EpersonGroupListComponent } from './form/eperson-group-list/eperson-group-list.component';
import { GroupSearchBoxComponent } from './form/eperson-group-list/group-search-box/group-search-box.component';
import { EpersonSearchBoxComponent } from './form/eperson-group-list/eperson-search-box/eperson-search-box.component';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { SharedModule } from '../shared.module'; import { SharedModule } from '../shared.module';
import { ResourcePolicyEntryComponent } from './entry/resource-policy-entry.component'; import { ResourcePolicyEntryComponent } from './entry/resource-policy-entry.component';
@@ -23,9 +20,6 @@ const COMPONENTS = [
ResourcePolicyFormComponent, ResourcePolicyFormComponent,
ResourcePolicyEditComponent, ResourcePolicyEditComponent,
ResourcePolicyCreateComponent, ResourcePolicyCreateComponent,
EpersonGroupListComponent,
EpersonSearchBoxComponent,
GroupSearchBoxComponent
]; ];
const PROVIDERS = [ const PROVIDERS = [

View File

@@ -34,6 +34,7 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { SubmissionObject } from '../../core/submission/models/submission-object.model'; import { SubmissionObject } from '../../core/submission/models/submission-object.model';
import { SearchFilterConfig } from './models/search-filter-config.model'; import { SearchFilterConfig } from './models/search-filter-config.model';
import { WorkspaceItem } from '../..//core/submission/models/workspaceitem.model';
@Component({ @Component({
selector: 'ds-search', selector: 'ds-search',
@@ -405,8 +406,9 @@ export class SearchComponent implements OnInit {
true, true,
followLink<Item>('thumbnail', { isOptional: true }), followLink<Item>('thumbnail', { isOptional: true }),
followLink<SubmissionObject>('item', { isOptional: true }, followLink<Item>('thumbnail', { isOptional: true })) as any, followLink<SubmissionObject>('item', { isOptional: true }, followLink<Item>('thumbnail', { isOptional: true })) as any,
followLink<Item>('accessStatus', { isOptional: true, shouldEmbed: environment.item.showAccessStatuses }) followLink<WorkspaceItem>('supervisionOrders', { isOptional: true }) as any,
).pipe(getFirstCompletedRemoteData()) followLink<Item>('accessStatus', { isOptional: true, shouldEmbed: environment.item.showAccessStatuses }),
).pipe(getFirstCompletedRemoteData())
.subscribe((results: RemoteData<SearchObjects<DSpaceObject>>) => { .subscribe((results: RemoteData<SearchObjects<DSpaceObject>>) => {
if (results.hasSucceeded) { if (results.hasSucceeded) {
if (this.trackStatistics) { if (this.trackStatistics) {

View File

@@ -315,6 +315,10 @@ import { MenuModule } from './menu/menu.module';
import { import {
ListableNotificationObjectComponent ListableNotificationObjectComponent
} from './object-list/listable-notification-object/listable-notification-object.component'; } from './object-list/listable-notification-object/listable-notification-object.component';
import { SupervisionGroupSelectorComponent } from './dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component';
import { EpersonGroupListComponent } from './form/eperson-group-list/eperson-group-list.component';
import { EpersonSearchBoxComponent } from './form/eperson-group-list/eperson-search-box/eperson-search-box.component';
import { GroupSearchBoxComponent } from './form/eperson-group-list/group-search-box/group-search-box.component';
const MODULES = [ const MODULES = [
CommonModule, CommonModule,
@@ -436,6 +440,10 @@ const COMPONENTS = [
ItemPageTitleFieldComponent, ItemPageTitleFieldComponent,
ThemedSearchNavbarComponent, ThemedSearchNavbarComponent,
ListableNotificationObjectComponent, ListableNotificationObjectComponent,
EpersonGroupListComponent,
EpersonSearchBoxComponent,
GroupSearchBoxComponent,
SupervisionGroupSelectorComponent
]; ];
const ENTRY_COMPONENTS = [ const ENTRY_COMPONENTS = [
@@ -498,6 +506,10 @@ const ENTRY_COMPONENTS = [
CommunitySidebarSearchListElementComponent, CommunitySidebarSearchListElementComponent,
ScopeSelectorModalComponent, ScopeSelectorModalComponent,
ListableNotificationObjectComponent, ListableNotificationObjectComponent,
EpersonGroupListComponent,
EpersonSearchBoxComponent,
GroupSearchBoxComponent,
SupervisionGroupSelectorComponent
]; ];
const SHARED_ITEM_PAGE_COMPONENTS = [ const SHARED_ITEM_PAGE_COMPONENTS = [

View File

@@ -536,10 +536,16 @@
"admin.workflow.item.workflow": "Workflow", "admin.workflow.item.workflow": "Workflow",
"admin.workflow.item.workspace": "Workspace",
"admin.workflow.item.delete": "Delete", "admin.workflow.item.delete": "Delete",
"admin.workflow.item.send-back": "Send back", "admin.workflow.item.send-back": "Send back",
"admin.workflow.item.policies": "Policies",
"admin.workflow.item.supervision": "Supervision",
"admin.metadata-import.breadcrumbs": "Import Metadata", "admin.metadata-import.breadcrumbs": "Import Metadata",
@@ -1418,6 +1424,28 @@
"dso-selector.results-could-not-be-retrieved": "Something went wrong, please refresh again ↻", "dso-selector.results-could-not-be-retrieved": "Something went wrong, please refresh again ↻",
"supervision-group-selector.header": "Supervision Group Selector",
"supervision-group-selector.select.type-of-order.label": "Select a type of Order",
"supervision-group-selector.select.type-of-order.option.none": "NONE",
"supervision-group-selector.select.type-of-order.option.editor": "EDITOR",
"supervision-group-selector.select.type-of-order.option.observer": "OBSERVER",
"supervision-group-selector.select.group.label": "Select a Group",
"supervision-group-selector.button.save": "Save",
"supervision-group-selector.select.type-of-order.error": "Please select a type of order",
"supervision-group-selector.select.group.error": "Please select a group",
"supervision-group-selector.notification.create.success.title": "Successfully created supervision order for group {{ name }}",
"supervision-group-selector.notification.create.failure.title": "Error",
"confirmation-modal.export-metadata.header": "Export metadata for {{ dsoName }}", "confirmation-modal.export-metadata.header": "Export metadata for {{ dsoName }}",
"confirmation-modal.export-metadata.info": "Are you sure you want to export metadata for {{ dsoName }}", "confirmation-modal.export-metadata.info": "Are you sure you want to export metadata for {{ dsoName }}",
@@ -2222,6 +2250,22 @@
"item.truncatable-part.show-less": "Collapse", "item.truncatable-part.show-less": "Collapse",
"item.search.result.delete-supervision.modal.header": "Delete Supervision Order",
"item.search.result.delete-supervision.modal.info": "Are you sure you want to delete Supervision Order",
"item.search.result.delete-supervision.modal.cancel": "Cancel",
"item.search.result.delete-supervision.modal.confirm": "Delete",
"item.search.result.notification.deleted.success": "Successfully deleted supervision order \"{{name}}\"",
"item.search.result.notification.deleted.failure.title": "Failed to delete supervision order \"{{name}}\"",
"item.search.result.notification.deleted.failure.content": "Failed to delete supervision order",
"item.search.result.list.element.supervised-by": "Supervised by:",
"item.page.abstract": "Abstract", "item.page.abstract": "Abstract",
@@ -2851,6 +2895,8 @@
"mydspace.show.workspace": "Your Submissions", "mydspace.show.workspace": "Your Submissions",
"mydspace.show.otherworkspace": "Supervised items",
"mydspace.status.archived": "Archived", "mydspace.status.archived": "Archived",
"mydspace.status.validation": "Validation", "mydspace.status.validation": "Validation",
@@ -3640,6 +3686,12 @@
"search.filters.filter.submitter.label": "Search submitter", "search.filters.filter.submitter.label": "Search submitter",
"search.filters.filter.supervisedBy.head": "Supervised By",
"search.filters.filter.supervisedBy.placeholder": "Supervised By",
"search.filters.filter.supervisedBy.label": "Search Supervised By",
"search.filters.entityType.JournalIssue": "Journal Issue", "search.filters.entityType.JournalIssue": "Journal Issue",
@@ -4534,12 +4586,16 @@
"otherworkspace.search.results.head": "Supervised Items",
"workspace.search.results.head": "Your submissions", "workspace.search.results.head": "Your submissions",
"workflowAdmin.search.results.head": "Administer Workflow", "workflowAdmin.search.results.head": "Administer Workflow",
"workflow.search.results.head": "Workflow tasks", "workflow.search.results.head": "Workflow tasks",
"supervision.search.results.head": "Supervision tasks",
"workflow-item.edit.breadcrumbs": "Edit workflowitem", "workflow-item.edit.breadcrumbs": "Edit workflowitem",