mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
69115: MyDSpace ClaimedTask proper link resolving
This commit is contained in:
@@ -29,6 +29,8 @@ import { ViewMode } from '../core/shared/view-mode.model';
|
|||||||
import { MyDSpaceRequest } from '../core/data/request.models';
|
import { MyDSpaceRequest } from '../core/data/request.models';
|
||||||
import { SearchResult } from '../shared/search/search-result.model';
|
import { SearchResult } from '../shared/search/search-result.model';
|
||||||
import { Context } from '../core/shared/context.model';
|
import { Context } from '../core/shared/context.model';
|
||||||
|
import { followLink } from '../shared/utils/follow-link-config.model';
|
||||||
|
import { ClaimedTask } from '../core/tasks/models/claimed-task-object.model';
|
||||||
|
|
||||||
export const MYDSPACE_ROUTE = '/mydspace';
|
export const MYDSPACE_ROUTE = '/mydspace';
|
||||||
export const SEARCH_CONFIG_SERVICE: InjectionToken<SearchConfigurationService> = new InjectionToken<SearchConfigurationService>('searchConfigurationService');
|
export const SEARCH_CONFIG_SERVICE: InjectionToken<SearchConfigurationService> = new InjectionToken<SearchConfigurationService>('searchConfigurationService');
|
||||||
@@ -126,7 +128,10 @@ export class MyDSpacePageComponent implements OnInit {
|
|||||||
this.searchOptions$ = this.searchConfigService.paginatedSearchOptions;
|
this.searchOptions$ = this.searchConfigService.paginatedSearchOptions;
|
||||||
this.sub = this.searchOptions$.pipe(
|
this.sub = this.searchOptions$.pipe(
|
||||||
tap(() => this.resultsRD$.next(null)),
|
tap(() => this.resultsRD$.next(null)),
|
||||||
switchMap((options: PaginatedSearchOptions) => this.service.search(options).pipe(getSucceededRemoteData())))
|
switchMap((options: PaginatedSearchOptions) =>
|
||||||
|
this.service.search<ClaimedTask>(options, undefined,
|
||||||
|
followLink('workflowitem', undefined, followLink('item'), followLink('submitter')),
|
||||||
|
followLink('owner')).pipe(getSucceededRemoteData())))
|
||||||
.subscribe((results) => {
|
.subscribe((results) => {
|
||||||
this.resultsRD$.next(results);
|
this.resultsRD$.next(results);
|
||||||
});
|
});
|
||||||
|
@@ -18,6 +18,8 @@ import { RemoteData } from '../data/remote-data';
|
|||||||
import { PaginatedList } from '../data/paginated-list';
|
import { PaginatedList } from '../data/paginated-list';
|
||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service';
|
import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service';
|
||||||
|
import { dataService } from '../cache/builders/build-decorators';
|
||||||
|
import { GROUP } from './models/group.resource-type';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides methods to retrieve eperson group resources.
|
* Provides methods to retrieve eperson group resources.
|
||||||
@@ -25,6 +27,7 @@ import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service';
|
|||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
|
@dataService(GROUP)
|
||||||
export class GroupDataService extends DataService<Group> {
|
export class GroupDataService extends DataService<Group> {
|
||||||
protected linkPath = 'groups';
|
protected linkPath = 'groups';
|
||||||
protected browseEndpoint = '';
|
protected browseEndpoint = '';
|
||||||
|
@@ -2,7 +2,7 @@ import { combineLatest as observableCombineLatest, Observable, of as observableO
|
|||||||
import { Injectable, OnDestroy } from '@angular/core';
|
import { Injectable, OnDestroy } from '@angular/core';
|
||||||
import { NavigationExtras, Router } from '@angular/router';
|
import { NavigationExtras, Router } from '@angular/router';
|
||||||
import { first, map, switchMap, tap } from 'rxjs/operators';
|
import { first, map, switchMap, tap } from 'rxjs/operators';
|
||||||
import { followLink } from '../../../shared/utils/follow-link-config.model';
|
import { followLink, FollowLinkConfig } from '../../../shared/utils/follow-link-config.model';
|
||||||
import { LinkService } from '../../cache/builders/link.service';
|
import { LinkService } from '../../cache/builders/link.service';
|
||||||
import { FacetConfigSuccessResponse, FacetValueSuccessResponse, SearchSuccessResponse } from '../../cache/response.models';
|
import { FacetConfigSuccessResponse, FacetValueSuccessResponse, SearchSuccessResponse } from '../../cache/response.models';
|
||||||
import { PaginatedList } from '../../data/paginated-list';
|
import { PaginatedList } from '../../data/paginated-list';
|
||||||
@@ -107,10 +107,11 @@ export class SearchService implements OnDestroy {
|
|||||||
* Method to retrieve a paginated list of search results from the server
|
* Method to retrieve a paginated list of search results from the server
|
||||||
* @param {PaginatedSearchOptions} searchOptions The configuration necessary to perform this search
|
* @param {PaginatedSearchOptions} searchOptions The configuration necessary to perform this search
|
||||||
* @param responseMsToLive The amount of milliseconds for the response to live in cache
|
* @param responseMsToLive The amount of milliseconds for the response to live in cache
|
||||||
|
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||||
* @returns {Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>} Emits a paginated list with all search results found
|
* @returns {Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>} Emits a paginated list with all search results found
|
||||||
*/
|
*/
|
||||||
search(searchOptions?: PaginatedSearchOptions, responseMsToLive?: number): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
search<T extends DSpaceObject>(searchOptions?: PaginatedSearchOptions, responseMsToLive?: number, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
||||||
return this.getPaginatedResults(this.searchEntries(searchOptions));
|
return this.getPaginatedResults<T>(this.searchEntries(searchOptions), ...linksToFollow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,9 +152,10 @@ export class SearchService implements OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* Method to convert the parsed responses into a paginated list of search results
|
* Method to convert the parsed responses into a paginated list of search results
|
||||||
* @param searchEntries: The request entries from the search method
|
* @param searchEntries: The request entries from the search method
|
||||||
|
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||||
* @returns {Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>} Emits a paginated list with all search results found
|
* @returns {Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>} Emits a paginated list with all search results found
|
||||||
*/
|
*/
|
||||||
getPaginatedResults(searchEntries: Observable<{ searchOptions: PaginatedSearchOptions, requestEntry: RequestEntry }>): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
getPaginatedResults<T extends DSpaceObject>(searchEntries: Observable<{ searchOptions: PaginatedSearchOptions, requestEntry: RequestEntry }>, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> {
|
||||||
const requestEntryObs: Observable<RequestEntry> = searchEntries.pipe(
|
const requestEntryObs: Observable<RequestEntry> = searchEntries.pipe(
|
||||||
map((entry) => entry.requestEntry),
|
map((entry) => entry.requestEntry),
|
||||||
);
|
);
|
||||||
@@ -174,7 +176,7 @@ export class SearchService implements OnDestroy {
|
|||||||
}),
|
}),
|
||||||
// Send a request for each item to ensure fresh cache
|
// Send a request for each item to ensure fresh cache
|
||||||
tap((reqs: RestRequest[]) => reqs.forEach((req: RestRequest) => this.requestService.configure(req))),
|
tap((reqs: RestRequest[]) => reqs.forEach((req: RestRequest) => this.requestService.configure(req))),
|
||||||
map((reqs: RestRequest[]) => reqs.map((req: RestRequest) => this.rdb.buildSingle(req.href))),
|
map((reqs: RestRequest[]) => reqs.map((req: RestRequest) => this.rdb.buildSingle(req.href, ...linksToFollow))),
|
||||||
switchMap((input: Array<Observable<RemoteData<DSpaceObject>>>) => this.rdb.aggregate(input)),
|
switchMap((input: Array<Observable<RemoteData<DSpaceObject>>>) => this.rdb.aggregate(input)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { inheritSerialization } from 'cerialize';
|
import { inheritSerialization } from 'cerialize';
|
||||||
import { typedObject } from '../../cache/builders/build-decorators';
|
import { inheritLinkAnnotations, typedObject } from '../../cache/builders/build-decorators';
|
||||||
import { DSpaceObject } from '../../shared/dspace-object.model';
|
|
||||||
import { CLAIMED_TASK } from './claimed-task-object.resource-type';
|
import { CLAIMED_TASK } from './claimed-task-object.resource-type';
|
||||||
import { TaskObject } from './task-object.model';
|
import { TaskObject } from './task-object.model';
|
||||||
|
|
||||||
@@ -8,7 +7,8 @@ import { TaskObject } from './task-object.model';
|
|||||||
* A model class for a ClaimedTask.
|
* A model class for a ClaimedTask.
|
||||||
*/
|
*/
|
||||||
@typedObject
|
@typedObject
|
||||||
@inheritSerialization(DSpaceObject)
|
@inheritSerialization(TaskObject)
|
||||||
|
@inheritLinkAnnotations(TaskObject)
|
||||||
export class ClaimedTask extends TaskObject {
|
export class ClaimedTask extends TaskObject {
|
||||||
static type = CLAIMED_TASK;
|
static type = CLAIMED_TASK;
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import { DSpaceObject } from '../../shared/dspace-object.model';
|
|||||||
import { HALLink } from '../../shared/hal-link.model';
|
import { HALLink } from '../../shared/hal-link.model';
|
||||||
import { WorkflowItem } from '../../submission/models/workflowitem.model';
|
import { WorkflowItem } from '../../submission/models/workflowitem.model';
|
||||||
import { TASK_OBJECT } from './task-object.resource-type';
|
import { TASK_OBJECT } from './task-object.resource-type';
|
||||||
|
import { WORKFLOWITEM } from '../../eperson/models/workflowitem.resource-type';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract model class for a TaskObject.
|
* An abstract model class for a TaskObject.
|
||||||
@@ -45,7 +46,7 @@ export class TaskObject extends DSpaceObject implements CacheableObject {
|
|||||||
@deserialize
|
@deserialize
|
||||||
_links: {
|
_links: {
|
||||||
self: HALLink;
|
self: HALLink;
|
||||||
eperson: HALLink;
|
owner: HALLink;
|
||||||
group: HALLink;
|
group: HALLink;
|
||||||
workflowitem: HALLink;
|
workflowitem: HALLink;
|
||||||
};
|
};
|
||||||
@@ -54,7 +55,7 @@ export class TaskObject extends DSpaceObject implements CacheableObject {
|
|||||||
* The EPerson for this task
|
* The EPerson for this task
|
||||||
* Will be undefined unless the eperson {@link HALLink} has been resolved.
|
* Will be undefined unless the eperson {@link HALLink} has been resolved.
|
||||||
*/
|
*/
|
||||||
@link(EPERSON)
|
@link(EPERSON, false, 'owner')
|
||||||
eperson?: Observable<RemoteData<EPerson>>;
|
eperson?: Observable<RemoteData<EPerson>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,7 +69,7 @@ export class TaskObject extends DSpaceObject implements CacheableObject {
|
|||||||
* The WorkflowItem for this task
|
* The WorkflowItem for this task
|
||||||
* Will be undefined unless the workflowitem {@link HALLink} has been resolved.
|
* Will be undefined unless the workflowitem {@link HALLink} has been resolved.
|
||||||
*/
|
*/
|
||||||
@link(WorkflowItem.type)
|
@link(WORKFLOWITEM)
|
||||||
workflowitem?: Observable<RemoteData<WorkflowItem>> | WorkflowItem;
|
workflowitem?: Observable<RemoteData<WorkflowItem>> | WorkflowItem;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -27,12 +27,12 @@ describe('OrgUnitItemMetadataListElementComponent', () => {
|
|||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(OrgUnitItemMetadataListElementComponent);
|
fixture = TestBed.createComponent(OrgUnitItemMetadataListElementComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
comp.metadataRepresentation = mockItemMetadataRepresentation;
|
comp.metadataRepresentation = mockItemMetadataRepresentation;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should show the name of the organisation as a link', () => {
|
it('should show the name of the organisation as a link', () => {
|
||||||
const linkText = fixture.debugElement.query(By.css('a')).nativeElement.textContent;
|
const linkText = fixture.debugElement.query(By.css('a')).nativeElement.textContent;
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
<ds-item-list-preview *ngIf="workflowitem"
|
<ng-container *ngVar="(workflowitemRD$ | async)?.payload as workflowitem">
|
||||||
[item]="(workflowitem.item | async)?.payload"
|
<ds-item-list-preview *ngIf="workflowitem"
|
||||||
[object]="object"
|
[item]="(workflowitem?.item | async)?.payload"
|
||||||
[showSubmitter]="showSubmitter"
|
[object]="object"
|
||||||
[status]="status"></ds-item-list-preview>
|
[showSubmitter]="showSubmitter"
|
||||||
|
[status]="status"></ds-item-list-preview>
|
||||||
|
|
||||||
<ds-claimed-task-actions *ngIf="workflowitem" [object]="dso"></ds-claimed-task-actions>
|
<ds-claimed-task-actions *ngIf="workflowitem" [object]="dso"></ds-claimed-task-actions>
|
||||||
|
</ng-container>
|
||||||
|
@@ -12,6 +12,7 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo
|
|||||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||||
import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model';
|
import { ClaimedTaskSearchResult } from '../../../object-collection/shared/claimed-task-search-result.model';
|
||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||||
|
import { VarDirective } from '../../../utils/var.directive';
|
||||||
|
|
||||||
let component: ClaimedSearchResultListElementComponent;
|
let component: ClaimedSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<ClaimedSearchResultListElementComponent>;
|
let fixture: ComponentFixture<ClaimedSearchResultListElementComponent>;
|
||||||
@@ -59,7 +60,7 @@ describe('ClaimedSearchResultListElementComponent', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [NoopAnimationsModule],
|
imports: [NoopAnimationsModule],
|
||||||
declarations: [ClaimedSearchResultListElementComponent],
|
declarations: [ClaimedSearchResultListElementComponent, VarDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: {} },
|
{ provide: TruncatableService, useValue: {} },
|
||||||
],
|
],
|
||||||
@@ -79,8 +80,11 @@ describe('ClaimedSearchResultListElementComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init item properly', () => {
|
it('should init item properly', (done) => {
|
||||||
expect(component.workflowitem).toEqual(workflowitem);
|
component.workflowitemRD$.subscribe((workflowitemRD) => {
|
||||||
|
expect(workflowitemRD.payload).toEqual(workflowitem);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have properly status', () => {
|
it('should have properly status', () => {
|
||||||
|
@@ -2,11 +2,9 @@ import { Component } from '@angular/core';
|
|||||||
import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common';
|
import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common';
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { find } from 'rxjs/operators';
|
|
||||||
|
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
import { isNotUndefined } from '../../../empty.util';
|
|
||||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||||
import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model';
|
import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model';
|
||||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||||
@@ -40,24 +38,13 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle
|
|||||||
/**
|
/**
|
||||||
* The workflowitem object that belonging to the result object
|
* The workflowitem object that belonging to the result object
|
||||||
*/
|
*/
|
||||||
public workflowitem: WorkflowItem;
|
public workflowitemRD$: Observable<RemoteData<WorkflowItem>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize all instance variables
|
* Initialize all instance variables
|
||||||
*/
|
*/
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.initWorkflowItem(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>);
|
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve workflowitem from result object
|
|
||||||
*/
|
|
||||||
initWorkflowItem(wfi$: Observable<RemoteData<WorkflowItem>>) {
|
|
||||||
wfi$.pipe(
|
|
||||||
find((rd: RemoteData<WorkflowItem>) => (rd.hasSucceeded && isNotUndefined(rd.payload)))
|
|
||||||
).subscribe((rd: RemoteData<WorkflowItem>) => {
|
|
||||||
this.workflowitem = rd.payload;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user