diff --git a/src/app/admin/admin-workflow-page/admin-workflow-page.component.html b/src/app/admin/admin-workflow-page/admin-workflow-page.component.html index 404af131d1..d12cefb331 100644 --- a/src/app/admin/admin-workflow-page/admin-workflow-page.component.html +++ b/src/app/admin/admin-workflow-page/admin-workflow-page.component.html @@ -1 +1 @@ - + diff --git a/src/app/admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/workflow-item/workflow-item-search-result-admin-workflow-list-element.component.html b/src/app/admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/workflow-item/workflow-item-search-result-admin-workflow-list-element.component.html index 192cc751f2..77ece5254d 100644 --- a/src/app/admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/workflow-item/workflow-item-search-result-admin-workflow-list-element.component.html +++ b/src/app/admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/workflow-item/workflow-item-search-result-admin-workflow-list-element.component.html @@ -1,6 +1,9 @@ -
+
{{ "admin.workflow.item.workflow" | translate }}
+
+ {{ "admin.workflow.item.workspace" | translate }} +
{{"admin.workflow.item.send-back" | translate}} + + {{'admin.workflow.item.policies' | translate}} + + + {{'admin.workflow.item.supervision' | translate}} +
diff --git a/src/app/admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.spec.ts b/src/app/admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.spec.ts index 75e0e2e7a8..9b2bffffef 100644 --- a/src/app/admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.spec.ts +++ b/src/app/admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.spec.ts @@ -11,17 +11,25 @@ import { getWorkflowItemDeleteRoute, getWorkflowItemSendBackRoute } 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', () => { let component: WorkflowItemAdminWorkflowActionsComponent; let fixture: ComponentFixture; let id; let wfi; + let item = new Item(); + item.uuid = 'itemUUID1111'; + const rd = new RemoteData(undefined, undefined, undefined, RequestEntryState.Success, undefined, item, 200); function init() { id = '780b2588-bda5-4112-a1cd-0b15000a5339'; wfi = new WorkflowItem(); wfi.id = id; + wfi.item = of(rd); } beforeEach(waitForAsync(() => { @@ -59,4 +67,11 @@ describe('WorkflowItemAdminWorkflowActionsComponent', () => { const link = a.nativeElement.href; 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()); + }); + }); diff --git a/src/app/admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.ts b/src/app/admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.ts index 32725a0e7a..924f24e738 100644 --- a/src/app/admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.ts +++ b/src/app/admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.ts @@ -1,4 +1,9 @@ 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 { getWorkflowItemSendBackRoute, @@ -25,6 +30,10 @@ export class WorkflowItemAdminWorkflowActionsComponent { */ @Input() public small: boolean; + constructor( + private modalService: NgbModal + ) { } + /** * Returns the path to the delete page of this workflow item */ @@ -39,4 +48,28 @@ export class WorkflowItemAdminWorkflowActionsComponent { getSendBackRoute(): string { return getWorkflowItemSendBackRoute(this.wfi.id); } + + /** + * Returns the path to the to administrative edit page policies tab + */ + getPoliciesRoute(): Observable { + 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; + }); + } } diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index ede23ba43b..845bab2ea8 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -170,6 +170,7 @@ import { OrcidHistory } from './orcid/model/orcid-history.model'; import { OrcidAuthService } from './orcid/orcid-auth.service'; import { VocabularyDataService } from './submission/vocabularies/vocabulary.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 @@ -292,6 +293,7 @@ const PROVIDERS = [ OrcidAuthService, OrcidQueueDataService, OrcidHistoryDataService, + SupervisionOrderDataService ]; /** diff --git a/src/app/core/shared/context.model.ts b/src/app/core/shared/context.model.ts index 126896e3e1..0f1130ebda 100644 --- a/src/app/core/shared/context.model.ts +++ b/src/app/core/shared/context.model.ts @@ -8,6 +8,7 @@ export enum Context { Search = 'search', Workflow = 'workflow', Workspace = 'workspace', + SupervisedItems = 'otherworkspace', AdminMenu = 'adminMenu', EntitySearchModalWithNameVariants = 'EntitySearchModalWithNameVariants', EntitySearchModal = 'EntitySearchModal', diff --git a/src/app/core/submission/models/submission-object.model.ts b/src/app/core/submission/models/submission-object.model.ts index 3d7c0a3678..3d373d2522 100644 --- a/src/app/core/submission/models/submission-object.model.ts +++ b/src/app/core/submission/models/submission-object.model.ts @@ -14,6 +14,7 @@ import { ITEM } from '../../shared/item.resource-type'; import { excludeFromEquals } from '../../utilities/equals.decorators'; import { WorkspaceitemSectionsObject } from './workspaceitem-sections.model'; import { CacheableObject } from '../../cache/cacheable-object.model'; +import { SUPERVISION_ORDER } from '../../supervision-order/models/supervision-order.resource-type'; export interface SubmissionObjectError { message: string; @@ -65,6 +66,7 @@ export abstract class SubmissionObject extends DSpaceObject implements Cacheable item: HALLink; submissionDefinition: HALLink; submitter: HALLink; + supervisionOrders: HALLink; }; get self(): string { @@ -93,4 +95,12 @@ export abstract class SubmissionObject extends DSpaceObject implements Cacheable @link(EPERSON) submitter?: Observable> | 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> | WorkspaceItem' to 'any' to prevent issues in templates with async */ + supervisionOrders?: any; + } diff --git a/src/app/core/supervision-order/models/action-type.model.ts b/src/app/core/supervision-order/models/action-type.model.ts new file mode 100644 index 0000000000..0e55689069 --- /dev/null +++ b/src/app/core/supervision-order/models/action-type.model.ts @@ -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', +} diff --git a/src/app/core/supervision-order/models/supervision-order.model.ts b/src/app/core/supervision-order/models/supervision-order.model.ts new file mode 100644 index 0000000000..e881c06d1b --- /dev/null +++ b/src/app/core/supervision-order/models/supervision-order.model.ts @@ -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>; + + /** + * The group linked by this supervision order + * Will be undefined unless the version {@link HALLink} has been resolved. + */ + @link(GROUP) + group?: Observable>; +} diff --git a/src/app/core/supervision-order/models/supervision-order.resource-type.ts b/src/app/core/supervision-order/models/supervision-order.resource-type.ts new file mode 100644 index 0000000000..994c93ab74 --- /dev/null +++ b/src/app/core/supervision-order/models/supervision-order.resource-type.ts @@ -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'); diff --git a/src/app/core/supervision-order/supervision-order-data.service.spec.ts b/src/app/core/supervision-order/supervision-order-data.service.spec.ts new file mode 100644 index 0000000000..b12817fa1a --- /dev/null +++ b/src/app/core/supervision-order/supervision-order-data.service.spec.ts @@ -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 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 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 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) 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) for the search', () => { + const result = service.searchByItem(itemUUID); + const expected = cold('a|', { + a: paginatedListRD + }); + expect(result).toBeObservable(expected); + }); + }); + +}); diff --git a/src/app/core/supervision-order/supervision-order-data.service.ts b/src/app/core/supervision-order/supervision-order-data.service.ts new file mode 100644 index 0000000000..fed0c57b09 --- /dev/null +++ b/src/app/core/supervision-order/supervision-order-data.service.ts @@ -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 { + protected searchByGroupMethod = 'group'; + protected searchByItemMethod = 'byItem'; + + private createData: CreateDataImpl; + private searchData: SearchDataImpl; + private patchData: PatchDataImpl; + private deleteData: DeleteDataImpl; + + constructor( + protected requestService: RequestService, + protected rdbService: RemoteDataBuildService, + protected objectCache: ObjectCacheService, + protected halService: HALEndpointService, + protected notificationsService: NotificationsService, + protected comparator: DefaultChangeAnalyzer, + 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> { + 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 { + return this.deleteData.delete(supervisionOrderID).pipe( + getFirstCompletedRemoteData(), + map((response: RemoteData) => 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> { + 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[]): Observable>> { + 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[]): Observable>> { + 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> { + 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 { + return StatusCodeOnlyResponseParsingService; + } + }); + this.requestService.send(request); + }); + + return this.rdbService.buildFromRequestUUIDAndAwait(requestId, () => this.invalidateByHref(supervisionOrderHref)); + } + +} diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts index 178ed86c40..be110db101 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-issue/journal-issue-search-result-list-element.component.spec.ts @@ -10,6 +10,14 @@ import { TruncatableService } from '../../../../../shared/truncatable/truncatabl import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock'; 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 fixture: ComponentFixture; @@ -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', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: {} }, + { provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + {provide: NotificationsService, useValue: {}}, + {provide: TranslateService, useValue: {}}, { provide: DSONameService, useClass: DSONameServiceMock }, { provide: APP_CONFIG, useValue: environmentUseThumbs } ], @@ -87,6 +144,9 @@ describe('JournalIssueSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(JournalIssueSearchResultListElementComponent); journalIssueListElementComponent = fixture.componentInstance; @@ -164,6 +224,9 @@ describe('JournalIssueSearchResultListElementComponent', () => { declarations: [JournalIssueSearchResultListElementComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, + {provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + {provide: NotificationsService, useValue: {}}, + {provide: TranslateService, useValue: {}}, {provide: DSONameService, useClass: DSONameServiceMock}, { provide: APP_CONFIG, useValue: enviromentNoThumbs } ], @@ -181,7 +244,9 @@ describe('JournalIssueSearchResultListElementComponent', () => { describe('with environment.browseBy.showThumbnails set to false', () => { beforeEach(() => { - + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); journalIssueListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts index 71fa83a3b1..76d516e76e 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal-volume/journal-volume-search-result-list-element.component.spec.ts @@ -10,6 +10,14 @@ import { TruncatableService } from '../../../../../shared/truncatable/truncatabl import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock'; 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 fixture: ComponentFixture; @@ -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', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: {} }, + { provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + { provide: NotificationsService, useValue: {}}, + { provide: TranslateService, useValue: {}}, { provide: DSONameService, useClass: DSONameServiceMock }, { provide: APP_CONFIG, useValue: environmentUseThumbs } ], @@ -86,6 +143,9 @@ describe('JournalVolumeSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(JournalVolumeSearchResultListElementComponent); journalVolumeListElementComponent = fixture.componentInstance; @@ -162,6 +222,9 @@ describe('JournalVolumeSearchResultListElementComponent', () => { declarations: [JournalVolumeSearchResultListElementComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, + {provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + {provide: NotificationsService, useValue: {}}, + {provide: TranslateService, useValue: {}}, {provide: DSONameService, useClass: DSONameServiceMock}, { provide: APP_CONFIG, useValue: enviromentNoThumbs } ], @@ -173,6 +236,9 @@ describe('JournalVolumeSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(JournalVolumeSearchResultListElementComponent); journalVolumeListElementComponent = fixture.componentInstance; })); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts index 07970d7128..55f0875731 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/search-result-list-elements/journal/journal-search-result-list-element.component.spec.ts @@ -10,6 +10,14 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock'; 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 fixture: ComponentFixture; @@ -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', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [JournalSearchResultListElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: {} }, + { provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + { provide: NotificationsService, useValue: {}}, + { provide: TranslateService, useValue: {}}, { provide: DSONameService, useClass: DSONameServiceMock }, { provide: APP_CONFIG, useValue: environmentUseThumbs } ], @@ -82,6 +139,9 @@ describe('JournalSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(JournalSearchResultListElementComponent); journalListElementComponent = fixture.componentInstance; @@ -134,6 +194,9 @@ describe('JournalSearchResultListElementComponent', () => { declarations: [JournalSearchResultListElementComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, + {provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + {provide: NotificationsService, useValue: {}}, + {provide: TranslateService, useValue: {}}, {provide: DSONameService, useClass: DSONameServiceMock}, { provide: APP_CONFIG, useValue: enviromentNoThumbs } ], @@ -145,6 +208,9 @@ describe('JournalSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(JournalSearchResultListElementComponent); journalListElementComponent = fixture.componentInstance; })); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.spec.ts index 9609a9582a..b8f30fe66e 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/org-unit/org-unit-search-result-list-element.component.spec.ts @@ -12,6 +12,13 @@ import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service import { APP_CONFIG } from '../../../../../../config/app-config.interface'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; 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 fixture: ComponentFixture; @@ -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', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ @@ -78,6 +131,8 @@ describe('OrgUnitSearchResultListElementComponent', () => { declarations: [ OrgUnitSearchResultListElementComponent , TruncatePipe], providers: [ { provide: TruncatableService, useValue: {} }, + {provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + {provide: NotificationsService, useValue: {}}, { provide: DSONameService, useClass: DSONameServiceMock }, { provide: APP_CONFIG, useValue: environmentUseThumbs } ], @@ -89,6 +144,9 @@ describe('OrgUnitSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(OrgUnitSearchResultListElementComponent); orgUnitListElementComponent = fixture.componentInstance; @@ -148,6 +206,8 @@ describe('OrgUnitSearchResultListElementComponent', () => { declarations: [OrgUnitSearchResultListElementComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, + {provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + {provide: NotificationsService, useValue: {}}, {provide: DSONameService, useClass: DSONameServiceMock}, { provide: APP_CONFIG, useValue: enviromentNoThumbs } ], @@ -165,7 +225,9 @@ describe('OrgUnitSearchResultListElementComponent', () => { describe('with environment.browseBy.showThumbnails set to false', () => { beforeEach(() => { - + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); orgUnitListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts index 31018520f6..3f4cc1d294 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.spec.ts @@ -12,9 +12,19 @@ import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service import { APP_CONFIG } from '../../../../../../config/app-config.interface'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; 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 fixture: ComponentFixture; +const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', { + searchByItem: jasmine.createSpy('searchByItem'), +}); const mockItemWithMetadata: ItemSearchResult = Object.assign( 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', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ @@ -78,6 +130,8 @@ describe('PersonSearchResultListElementComponent', () => { declarations: [PersonSearchResultListElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: {} }, + { provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + { provide: NotificationsService, useValue: {} }, { provide: DSONameService, useClass: DSONameServiceMock }, { provide: APP_CONFIG, useValue: environmentUseThumbs } ], @@ -89,6 +143,9 @@ describe('PersonSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(PersonSearchResultListElementComponent); personListElementComponent = fixture.componentInstance; @@ -148,6 +205,8 @@ describe('PersonSearchResultListElementComponent', () => { declarations: [PersonSearchResultListElementComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, + {provide: SupervisionOrderDataService, useValue: supervisionOrderDataService}, + {provide: NotificationsService, useValue: {}}, {provide: DSONameService, useClass: DSONameServiceMock}, { provide: APP_CONFIG, useValue: enviromentNoThumbs } ], @@ -165,7 +224,9 @@ describe('PersonSearchResultListElementComponent', () => { describe('with environment.browseBy.showThumbnails set to false', () => { beforeEach(() => { - + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); personListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts index 217d7baef9..6f78c709ba 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/person/person-search-result-list-element.component.ts @@ -9,6 +9,10 @@ import { import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service'; import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service'; 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) @Component({ @@ -24,9 +28,13 @@ export class PersonSearchResultListElementComponent extends ItemSearchResultList public constructor( protected truncatableService: TruncatableService, 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); } /** diff --git a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts index 0cb3e63e87..f3ef14e4f6 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/search-result-list-elements/project/project-search-result-list-element.component.spec.ts @@ -10,6 +10,14 @@ import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service import { DSONameServiceMock } from '../../../../../shared/mocks/dso-name.service.mock'; import { By } from '@angular/platform-browser'; 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 fixture: ComponentFixture; @@ -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', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ProjectSearchResultListElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: {} }, + { provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + { provide: NotificationsService, useValue: {}}, + {provide: TranslateService, useValue: {}}, { provide: DSONameService, useClass: DSONameServiceMock }, { provide: APP_CONFIG, useValue: environmentUseThumbs } ], @@ -81,6 +138,9 @@ describe('ProjectSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(ProjectSearchResultListElementComponent); projectListElementComponent = fixture.componentInstance; @@ -133,6 +193,9 @@ describe('ProjectSearchResultListElementComponent', () => { declarations: [ProjectSearchResultListElementComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, + {provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + {provide: NotificationsService, useValue: {}}, + {provide: TranslateService, useValue: {}}, {provide: DSONameService, useClass: DSONameServiceMock}, { provide: APP_CONFIG, useValue: enviromentNoThumbs } @@ -151,7 +214,9 @@ describe('ProjectSearchResultListElementComponent', () => { describe('with environment.browseBy.showThumbnails set to false', () => { beforeEach(() => { - + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); projectListElementComponent.object = mockItemWithMetadata; fixture.detectChanges(); }); diff --git a/src/app/my-dspace-page/my-dspace-configuration-value-type.ts b/src/app/my-dspace-page/my-dspace-configuration-value-type.ts index baf2f0b920..52e6b01c11 100644 --- a/src/app/my-dspace-page/my-dspace-configuration-value-type.ts +++ b/src/app/my-dspace-page/my-dspace-configuration-value-type.ts @@ -1,4 +1,5 @@ export enum MyDSpaceConfigurationValueType { Workspace = 'workspace', + SupervisedItems = 'otherworkspace', Workflow = 'workflow' } diff --git a/src/app/my-dspace-page/my-dspace-configuration.service.spec.ts b/src/app/my-dspace-page/my-dspace-configuration.service.spec.ts index 669a97764a..34bfd946b6 100644 --- a/src/app/my-dspace-page/my-dspace-configuration.service.spec.ts +++ b/src/app/my-dspace-page/my-dspace-configuration.service.spec.ts @@ -184,7 +184,8 @@ describe('MyDSpaceConfigurationService', () => { expect(list$).toBeObservable(cold('(b|)', { b: [ - MyDSpaceConfigurationValueType.Workspace + MyDSpaceConfigurationValueType.Workspace, + MyDSpaceConfigurationValueType.SupervisedItems ] })); }); @@ -227,6 +228,7 @@ describe('MyDSpaceConfigurationService', () => { expect(list$).toBeObservable(cold('(b|)', { b: [ MyDSpaceConfigurationValueType.Workspace, + MyDSpaceConfigurationValueType.SupervisedItems, MyDSpaceConfigurationValueType.Workflow ] })); diff --git a/src/app/my-dspace-page/my-dspace-configuration.service.ts b/src/app/my-dspace-page/my-dspace-configuration.service.ts index dec8658910..86bbf0050c 100644 --- a/src/app/my-dspace-page/my-dspace-configuration.service.ts +++ b/src/app/my-dspace-page/my-dspace-configuration.service.ts @@ -20,6 +20,7 @@ import { Context } from '../core/shared/context.model'; export const MyDSpaceConfigurationToContextMap = new Map([ [MyDSpaceConfigurationValueType.Workspace, Context.Workspace], + [MyDSpaceConfigurationValueType.SupervisedItems, Context.SupervisedItems], [MyDSpaceConfigurationValueType.Workflow, Context.Workflow] ]); @@ -107,6 +108,7 @@ export class MyDSpaceConfigurationService extends SearchConfigurationService { const availableConf: MyDSpaceConfigurationValueType[] = []; if (isSubmitter) { availableConf.push(MyDSpaceConfigurationValueType.Workspace); + availableConf.push(MyDSpaceConfigurationValueType.SupervisedItems); } if (isController || isAdmin) { availableConf.push(MyDSpaceConfigurationValueType.Workflow); diff --git a/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.html new file mode 100644 index 0000000000..f6a5c339ce --- /dev/null +++ b/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.html @@ -0,0 +1,40 @@ +
+ + +
\ No newline at end of file diff --git a/src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.scss b/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.scss similarity index 100% rename from src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.scss rename to src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.scss diff --git a/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.spec.ts new file mode 100644 index 0000000000..b5e62ef8ac --- /dev/null +++ b/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.spec.ts @@ -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; + 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); + }); + +}); diff --git a/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.ts new file mode 100644 index 0000000000..c69c5d5177 --- /dev/null +++ b/src/app/shared/dso-selector/modal-wrappers/supervision-group-selector/supervision-group-selector.component.ts @@ -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(); + } + } + +} diff --git a/src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.html b/src/app/shared/form/eperson-group-list/eperson-group-list.component.html similarity index 100% rename from src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.html rename to src/app/shared/form/eperson-group-list/eperson-group-list.component.html diff --git a/src/app/shared/form/eperson-group-list/eperson-group-list.component.scss b/src/app/shared/form/eperson-group-list/eperson-group-list.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.spec.ts b/src/app/shared/form/eperson-group-list/eperson-group-list.component.spec.ts similarity index 88% rename from src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.spec.ts rename to src/app/shared/form/eperson-group-list/eperson-group-list.component.spec.ts index cec67e721c..399080c0ef 100644 --- a/src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.spec.ts +++ b/src/app/shared/form/eperson-group-list/eperson-group-list.component.spec.ts @@ -6,21 +6,21 @@ import { TranslateModule } from '@ngx-translate/core'; import { cold } from 'jasmine-marbles'; import uniqueId from 'lodash/uniqueId'; -import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; -import { createTestComponent } from '../../../testing/utils.test'; -import { EPersonDataService } from '../../../../core/eperson/eperson-data.service'; -import { GroupDataService } from '../../../../core/eperson/group-data.service'; -import { RequestService } from '../../../../core/data/request.service'; -import { getMockRequestService } from '../../../mocks/request.service.mock'; +import { createSuccessfulRemoteDataObject } from '../../remote-data.utils'; +import { createTestComponent } from '../../testing/utils.test'; +import { EPersonDataService } from '../../../core/eperson/eperson-data.service'; +import { GroupDataService } from '../../../core/eperson/group-data.service'; +import { RequestService } from '../../../core/data/request.service'; +import { getMockRequestService } from '../../mocks/request.service.mock'; import { EpersonGroupListComponent, SearchEvent } from './eperson-group-list.component'; -import { EPersonMock } from '../../../testing/eperson.mock'; -import { GroupMock } from '../../../testing/group-mock'; -import { PaginationComponentOptions } from '../../../pagination/pagination-component-options.model'; -import { buildPaginatedList } from '../../../../core/data/paginated-list.model'; -import { PageInfo } from '../../../../core/shared/page-info.model'; +import { EPersonMock } from '../../testing/eperson.mock'; +import { GroupMock } from '../../testing/group-mock'; +import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model'; +import { buildPaginatedList } from '../../../core/data/paginated-list.model'; +import { PageInfo } from '../../../core/shared/page-info.model'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { PaginationService } from '../../../../core/pagination/pagination.service'; -import { PaginationServiceStub } from '../../../testing/pagination-service.stub'; +import { PaginationService } from '../../../core/pagination/pagination.service'; +import { PaginationServiceStub } from '../../testing/pagination-service.stub'; describe('EpersonGroupListComponent test suite', () => { let comp: EpersonGroupListComponent; diff --git a/src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.ts b/src/app/shared/form/eperson-group-list/eperson-group-list.component.ts similarity index 81% rename from src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.ts rename to src/app/shared/form/eperson-group-list/eperson-group-list.component.ts index b859184845..e2b56859dc 100644 --- a/src/app/shared/resource-policies/form/eperson-group-list/eperson-group-list.component.ts +++ b/src/app/shared/form/eperson-group-list/eperson-group-list.component.ts @@ -4,22 +4,22 @@ import { BehaviorSubject, Observable, Subscription } from 'rxjs'; import { map } from 'rxjs/operators'; import uniqueId from 'lodash/uniqueId'; -import { RemoteData } from '../../../../core/data/remote-data'; -import { PaginatedList } from '../../../../core/data/paginated-list.model'; -import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; -import { PaginationComponentOptions } from '../../../pagination/pagination-component-options.model'; -import { hasValue, isNotEmpty } from '../../../empty.util'; -import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service'; -import { EPERSON } from '../../../../core/eperson/models/eperson.resource-type'; -import { GROUP } from '../../../../core/eperson/models/group.resource-type'; -import { ResourceType } from '../../../../core/shared/resource-type'; -import { EPersonDataService } from '../../../../core/eperson/eperson-data.service'; -import { GroupDataService } from '../../../../core/eperson/group-data.service'; -import { fadeInOut } from '../../../animations/fade'; -import { getFirstCompletedRemoteData } from '../../../../core/shared/operators'; -import { PaginationService } from '../../../../core/pagination/pagination.service'; -import { FindListOptions } from '../../../../core/data/find-list-options.model'; -import { getDataServiceFor } from '../../../../core/data/base/data-service.decorator'; +import { RemoteData } from '../../../core/data/remote-data'; +import { PaginatedList } from '../../../core/data/paginated-list.model'; +import { DSpaceObject } from '../../../core/shared/dspace-object.model'; +import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model'; +import { hasValue, isNotEmpty } from '../../empty.util'; +import { DSONameService } from '../../../core/breadcrumbs/dso-name.service'; +import { EPERSON } from '../../../core/eperson/models/eperson.resource-type'; +import { GROUP } from '../../../core/eperson/models/group.resource-type'; +import { ResourceType } from '../../../core/shared/resource-type'; +import { EPersonDataService } from '../../../core/eperson/eperson-data.service'; +import { GroupDataService } from '../../../core/eperson/group-data.service'; +import { fadeInOut } from '../../animations/fade'; +import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; +import { PaginationService } from '../../../core/pagination/pagination.service'; +import { FindListOptions } from '../../../core/data/find-list-options.model'; +import { getDataServiceFor } from '../../../core/data/base/data-service.decorator'; export interface SearchEvent { scope: string; diff --git a/src/app/shared/resource-policies/form/eperson-group-list/eperson-search-box/eperson-search-box.component.html b/src/app/shared/form/eperson-group-list/eperson-search-box/eperson-search-box.component.html similarity index 100% rename from src/app/shared/resource-policies/form/eperson-group-list/eperson-search-box/eperson-search-box.component.html rename to src/app/shared/form/eperson-group-list/eperson-search-box/eperson-search-box.component.html diff --git a/src/app/shared/resource-policies/form/eperson-group-list/eperson-search-box/eperson-search-box.component.spec.ts b/src/app/shared/form/eperson-group-list/eperson-search-box/eperson-search-box.component.spec.ts similarity index 97% rename from src/app/shared/resource-policies/form/eperson-group-list/eperson-search-box/eperson-search-box.component.spec.ts rename to src/app/shared/form/eperson-group-list/eperson-search-box/eperson-search-box.component.spec.ts index 311d911b26..db16af5edf 100644 --- a/src/app/shared/resource-policies/form/eperson-group-list/eperson-search-box/eperson-search-box.component.spec.ts +++ b/src/app/shared/form/eperson-group-list/eperson-search-box/eperson-search-box.component.spec.ts @@ -4,7 +4,7 @@ import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms'; 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 { SearchEvent } from '../eperson-group-list.component'; diff --git a/src/app/shared/resource-policies/form/eperson-group-list/eperson-search-box/eperson-search-box.component.ts b/src/app/shared/form/eperson-group-list/eperson-search-box/eperson-search-box.component.ts similarity index 96% rename from src/app/shared/resource-policies/form/eperson-group-list/eperson-search-box/eperson-search-box.component.ts rename to src/app/shared/form/eperson-group-list/eperson-search-box/eperson-search-box.component.ts index 11c3dcd102..6ae3200d0b 100644 --- a/src/app/shared/resource-policies/form/eperson-group-list/eperson-search-box/eperson-search-box.component.ts +++ b/src/app/shared/form/eperson-group-list/eperson-search-box/eperson-search-box.component.ts @@ -4,7 +4,7 @@ import { FormBuilder } from '@angular/forms'; import { Subscription } from 'rxjs'; 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. diff --git a/src/app/shared/resource-policies/form/eperson-group-list/group-search-box/group-search-box.component.html b/src/app/shared/form/eperson-group-list/group-search-box/group-search-box.component.html similarity index 100% rename from src/app/shared/resource-policies/form/eperson-group-list/group-search-box/group-search-box.component.html rename to src/app/shared/form/eperson-group-list/group-search-box/group-search-box.component.html diff --git a/src/app/shared/resource-policies/form/eperson-group-list/group-search-box/group-search-box.component.spec.ts b/src/app/shared/form/eperson-group-list/group-search-box/group-search-box.component.spec.ts similarity index 97% rename from src/app/shared/resource-policies/form/eperson-group-list/group-search-box/group-search-box.component.spec.ts rename to src/app/shared/form/eperson-group-list/group-search-box/group-search-box.component.spec.ts index dc39e30d3b..17e96fc71c 100644 --- a/src/app/shared/resource-policies/form/eperson-group-list/group-search-box/group-search-box.component.spec.ts +++ b/src/app/shared/form/eperson-group-list/group-search-box/group-search-box.component.spec.ts @@ -4,7 +4,7 @@ import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms'; 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 { SearchEvent } from '../eperson-group-list.component'; diff --git a/src/app/shared/resource-policies/form/eperson-group-list/group-search-box/group-search-box.component.ts b/src/app/shared/form/eperson-group-list/group-search-box/group-search-box.component.ts similarity index 96% rename from src/app/shared/resource-policies/form/eperson-group-list/group-search-box/group-search-box.component.ts rename to src/app/shared/form/eperson-group-list/group-search-box/group-search-box.component.ts index baef19f14a..ad181bdb64 100644 --- a/src/app/shared/resource-policies/form/eperson-group-list/group-search-box/group-search-box.component.ts +++ b/src/app/shared/form/eperson-group-list/group-search-box/group-search-box.component.ts @@ -4,7 +4,7 @@ import { FormBuilder } from '@angular/forms'; import { Subscription } from 'rxjs'; 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. diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html index 6b2951495d..64108681f6 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html @@ -41,6 +41,19 @@ [innerHTML]="firstMetadataValue('dc.description.abstract')"> + +
+
+ {{'item.search.result.list.element.supervised-by' | translate}} +
+
+ + {{supervisionOrder.group._name}} + X + +
+
+
diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.scss b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.scss index 5e4536cf95..0d93ec744b 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.scss +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.scss @@ -1 +1,7 @@ @import '../../../../../../../styles/variables'; + +.item-list-supervision { + a { + cursor: pointer; + } +} \ No newline at end of file diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts index d1e6c27ba4..887ecb30a0 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.spec.ts @@ -10,6 +10,14 @@ import { ItemSearchResult } from '../../../../../object-collection/shared/item-s import { DSONameService } from '../../../../../../core/breadcrumbs/dso-name.service'; import { DSONameServiceMock, UNDEFINED_NAME } from '../../../../../mocks/dso-name.service.mock'; 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 fixture: ComponentFixture; @@ -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', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ItemSearchResultListElementComponent, TruncatePipe], providers: [ { provide: TruncatableService, useValue: {} }, + { provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + { provide: NotificationsService, useValue: {}}, + { provide: TranslateService, useValue: {}}, { provide: DSONameService, useClass: DSONameServiceMock }, { provide: APP_CONFIG, useValue: environmentUseThumbs } ], @@ -89,6 +146,9 @@ describe('ItemSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(ItemSearchResultListElementComponent); publicationListElementComponent = fixture.componentInstance; @@ -225,6 +285,9 @@ describe('ItemSearchResultListElementComponent', () => { declarations: [ItemSearchResultListElementComponent, TruncatePipe], providers: [ {provide: TruncatableService, useValue: {}}, + {provide: SupervisionOrderDataService, useValue: supervisionOrderDataService }, + {provide: NotificationsService, useValue: {}}, + {provide: TranslateService, useValue: {}}, {provide: DSONameService, useClass: DSONameServiceMock}, { provide: APP_CONFIG, useValue: enviromentNoThumbs } ], @@ -236,6 +299,9 @@ describe('ItemSearchResultListElementComponent', () => { })); beforeEach(waitForAsync(() => { + supervisionOrderDataService.searchByItem.and.returnValue(hot('a|', { + a: paginatedListRD + })); fixture = TestBed.createComponent(ItemSearchResultListElementComponent); publicationListElementComponent = fixture.componentInstance; })); diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.ts index f84ae642ad..b1b5b0d1a7 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.ts @@ -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 { ViewMode } from '../../../../../../core/shared/view-mode.model'; import { ItemSearchResult } from '../../../../../object-collection/shared/item-search-result.model'; import { SearchResultListElementComponent } from '../../../search-result-list-element.component'; import { Item } from '../../../../../../core/shared/item.model'; 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(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 */ export class ItemSearchResultListElementComponent extends SearchResultListElementComponent { + messagePrefix = 'item.search.result'; + /** * Route to the item's page */ @@ -27,9 +43,67 @@ export class ItemSearchResultListElementComponent extends SearchResultListElemen */ 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 { super.ngOnInit(); this.showThumbnails = this.appConfig.browseBy.showThumbnails; 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')); + } + }); + } + } + }); } } diff --git a/src/app/shared/resource-policies/form/resource-policy-form.component.spec.ts b/src/app/shared/resource-policies/form/resource-policy-form.component.spec.ts index e555522c79..1a84270f1b 100644 --- a/src/app/shared/resource-policies/form/resource-policy-form.component.spec.ts +++ b/src/app/shared/resource-policies/form/resource-policy-form.component.spec.ts @@ -24,7 +24,7 @@ import { ResourcePolicyEvent, ResourcePolicyFormComponent } from './resource-pol import { FormService } from '../../form/form.service'; import { getMockFormService } from '../../mocks/form-service.mock'; 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 { stringToNgbDateStruct, dateToISOFormat } from '../../date.util'; import { ResourcePolicy } from '../../../core/resource-policy/models/resource-policy.model'; diff --git a/src/app/shared/resource-policies/resource-policies.module.ts b/src/app/shared/resource-policies/resource-policies.module.ts index a7dc19b83e..8a7f6dca79 100644 --- a/src/app/shared/resource-policies/resource-policies.module.ts +++ b/src/app/shared/resource-policies/resource-policies.module.ts @@ -10,9 +10,6 @@ import { ResourcePolicyCreateComponent } from './create/resource-policy-create.c import { FormModule } from '../form/form.module'; import { ResourcePolicyResolver } from './resolvers/resource-policy.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 { SharedModule } from '../shared.module'; import { ResourcePolicyEntryComponent } from './entry/resource-policy-entry.component'; @@ -23,9 +20,6 @@ const COMPONENTS = [ ResourcePolicyFormComponent, ResourcePolicyEditComponent, ResourcePolicyCreateComponent, - EpersonGroupListComponent, - EpersonSearchBoxComponent, - GroupSearchBoxComponent ]; const PROVIDERS = [ diff --git a/src/app/shared/search/search.component.ts b/src/app/shared/search/search.component.ts index c094e37ef2..e9a72ae338 100644 --- a/src/app/shared/search/search.component.ts +++ b/src/app/shared/search/search.component.ts @@ -34,6 +34,7 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme import { environment } from 'src/environments/environment'; import { SubmissionObject } from '../../core/submission/models/submission-object.model'; import { SearchFilterConfig } from './models/search-filter-config.model'; +import { WorkspaceItem } from '../..//core/submission/models/workspaceitem.model'; @Component({ selector: 'ds-search', @@ -405,8 +406,9 @@ export class SearchComponent implements OnInit { true, followLink('thumbnail', { isOptional: true }), followLink('item', { isOptional: true }, followLink('thumbnail', { isOptional: true })) as any, - followLink('accessStatus', { isOptional: true, shouldEmbed: environment.item.showAccessStatuses }) - ).pipe(getFirstCompletedRemoteData()) + followLink('supervisionOrders', { isOptional: true }) as any, + followLink('accessStatus', { isOptional: true, shouldEmbed: environment.item.showAccessStatuses }), + ).pipe(getFirstCompletedRemoteData()) .subscribe((results: RemoteData>) => { if (results.hasSucceeded) { if (this.trackStatistics) { diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 13fdd3e12c..bd87b35c82 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -315,6 +315,10 @@ import { MenuModule } from './menu/menu.module'; import { ListableNotificationObjectComponent } 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 = [ CommonModule, @@ -436,6 +440,10 @@ const COMPONENTS = [ ItemPageTitleFieldComponent, ThemedSearchNavbarComponent, ListableNotificationObjectComponent, + EpersonGroupListComponent, + EpersonSearchBoxComponent, + GroupSearchBoxComponent, + SupervisionGroupSelectorComponent ]; const ENTRY_COMPONENTS = [ @@ -498,6 +506,10 @@ const ENTRY_COMPONENTS = [ CommunitySidebarSearchListElementComponent, ScopeSelectorModalComponent, ListableNotificationObjectComponent, + EpersonGroupListComponent, + EpersonSearchBoxComponent, + GroupSearchBoxComponent, + SupervisionGroupSelectorComponent ]; const SHARED_ITEM_PAGE_COMPONENTS = [ diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index d043d61ae5..26f9983c17 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -536,10 +536,16 @@ "admin.workflow.item.workflow": "Workflow", + "admin.workflow.item.workspace": "Workspace", + "admin.workflow.item.delete": "Delete", "admin.workflow.item.send-back": "Send back", + "admin.workflow.item.policies": "Policies", + + "admin.workflow.item.supervision": "Supervision", + "admin.metadata-import.breadcrumbs": "Import Metadata", @@ -1418,6 +1424,28 @@ "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.info": "Are you sure you want to export metadata for {{ dsoName }}", @@ -2222,6 +2250,22 @@ "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", @@ -2851,6 +2895,8 @@ "mydspace.show.workspace": "Your Submissions", + "mydspace.show.otherworkspace": "Supervised items", + "mydspace.status.archived": "Archived", "mydspace.status.validation": "Validation", @@ -3640,6 +3686,12 @@ "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", @@ -4534,12 +4586,16 @@ + "otherworkspace.search.results.head": "Supervised Items", + "workspace.search.results.head": "Your submissions", "workflowAdmin.search.results.head": "Administer Workflow", "workflow.search.results.head": "Workflow tasks", + "supervision.search.results.head": "Supervision tasks", + "workflow-item.edit.breadcrumbs": "Edit workflowitem",