mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
94060: MyDSpace Workflow/Workspace item display as correct entity types
This commit is contained in:
@@ -16,6 +16,7 @@ import { WorkflowItemSearchResultListElementComponent } from '../shared/object-l
|
||||
import { PoolSearchResultDetailElementComponent } from '../shared/object-detail/my-dspace-result-detail-element/pool-search-result/pool-search-result-detail-element.component';
|
||||
import { ClaimedApprovedSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-approved-search-result/claimed-approved-search-result-list-element.component';
|
||||
import { ClaimedDeclinedSearchResultListElementComponent } from '../shared/object-list/my-dspace-result-list-element/claimed-search-result/claimed-declined-search-result/claimed-declined-search-result-list-element.component';
|
||||
import { ResearchEntitiesModule } from '../entity-groups/research-entities/research-entities.module';
|
||||
|
||||
const ENTRY_COMPONENTS = [
|
||||
// put only entry components that use custom decorator
|
||||
@@ -38,6 +39,7 @@ const ENTRY_COMPONENTS = [
|
||||
CommonModule,
|
||||
SharedModule,
|
||||
MyDspacePageRoutingModule,
|
||||
ResearchEntitiesModule.withEntryComponents()
|
||||
],
|
||||
declarations: [
|
||||
...ENTRY_COMPONENTS
|
||||
|
@@ -1,11 +1,10 @@
|
||||
<ng-container *ngIf="item$ | async">
|
||||
<ds-item-list-preview
|
||||
[item]="item$ | async"
|
||||
[object]="object"
|
||||
[status]="status"></ds-item-list-preview>
|
||||
|
||||
<ng-container *ngIf="derivedSearchResult$ | async">
|
||||
<ds-mydspace-item-status [status]="status"></ds-mydspace-item-status>
|
||||
<ds-listable-object-component-loader
|
||||
[viewMode]="ViewModes.ListElement"
|
||||
[object]="derivedSearchResult$ | async" [linkType]="LinkTypes.None"></ds-listable-object-component-loader>
|
||||
<ds-workflowitem-actions [object]="dso" (processCompleted)="reloadedObject.emit($event.reloadedObject)"></ds-workflowitem-actions>
|
||||
</ng-container>
|
||||
<ds-loading
|
||||
*ngIf="!(item$ | async)"
|
||||
*ngIf="!(derivedSearchResult$ | async)"
|
||||
[showMessage]="false"></ds-loading>
|
||||
|
@@ -83,14 +83,15 @@ describe('WorkflowItemSearchResultListElementComponent', () => {
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
component.dso = mockResultObject.indexableObject;
|
||||
component.object = mockResultObject;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should init item properly', (done) => {
|
||||
component.item$.pipe(take(1)).subscribe((i) => {
|
||||
it('should init derivedSearchResult$ properly', (done) => {
|
||||
component.derivedSearchResult$.pipe(take(1)).subscribe((i) => {
|
||||
expect(linkService.resolveLink).toHaveBeenCalled();
|
||||
expect(i).toBe(item);
|
||||
expect(i.indexableObject).toBe(item);
|
||||
expect(i.hitHighlights).toBe(mockResultObject.hitHighlights);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -1,14 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { find, map } from 'rxjs/operators';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { isNotUndefined } from '../../../empty.util';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model';
|
||||
@@ -16,6 +14,9 @@ import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { followLink } from '../../../utils/follow-link-config.model';
|
||||
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
|
||||
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
||||
import { getFirstSucceededRemoteDataPayload } from '../../../../core/shared/operators';
|
||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
||||
|
||||
/**
|
||||
* This component renders workflowitem object for the search result in the list view.
|
||||
@@ -28,11 +29,14 @@ import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
||||
|
||||
@listableObjectComponent(WorkflowItemSearchResult, ViewMode.ListElement)
|
||||
export class WorkflowItemSearchResultListElementComponent extends SearchResultListElementComponent<WorkflowItemSearchResult, WorkflowItem> {
|
||||
LinkTypes = CollectionElementLinkType;
|
||||
|
||||
ViewModes = ViewMode;
|
||||
|
||||
/**
|
||||
* The item object that belonging to the result object
|
||||
* The item search result derived from the WorkspaceItemSearchResult
|
||||
*/
|
||||
public item$: Observable<Item>;
|
||||
derivedSearchResult$: Observable<ItemSearchResult>;
|
||||
|
||||
/**
|
||||
* Represent item's status
|
||||
@@ -52,18 +56,18 @@ export class WorkflowItemSearchResultListElementComponent extends SearchResultLi
|
||||
*/
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.linkService.resolveLink(this.dso, followLink('item'));
|
||||
this.initItem(this.dso.item as Observable<RemoteData<Item>> );
|
||||
this.deriveSearchResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve item from result object
|
||||
*/
|
||||
initItem(item$: Observable<RemoteData<Item>>) {
|
||||
this.item$ = item$.pipe(
|
||||
find((rd: RemoteData<Item>) => rd.hasSucceeded && isNotUndefined(rd.payload)),
|
||||
map((rd: RemoteData<Item>) => rd.payload)
|
||||
);
|
||||
private deriveSearchResult() {
|
||||
this.linkService.resolveLink(this.object.indexableObject, followLink('item'));
|
||||
this.derivedSearchResult$ = this.object.indexableObject.item.pipe(
|
||||
getFirstSucceededRemoteDataPayload(),
|
||||
map((item: Item) => {
|
||||
const result = new ItemSearchResult();
|
||||
result.indexableObject = item;
|
||||
result.hitHighlights = this.object.hitHighlights;
|
||||
return result;
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,10 @@
|
||||
<ng-container *ngIf="item$ | async">
|
||||
<ds-item-list-preview
|
||||
[item]="item$ | async"
|
||||
[object]="object"
|
||||
[status]="status"></ds-item-list-preview>
|
||||
|
||||
<ng-container *ngIf="derivedSearchResult$ | async">
|
||||
<ds-mydspace-item-status [status]="status"></ds-mydspace-item-status>
|
||||
<ds-listable-object-component-loader
|
||||
[viewMode]="ViewModes.ListElement"
|
||||
[object]="derivedSearchResult$ | async" [linkType]="LinkTypes.None"></ds-listable-object-component-loader>
|
||||
<ds-workspaceitem-actions [object]="dso" (processCompleted)="reloadedObject.emit($event.reloadedObject)"></ds-workspaceitem-actions>
|
||||
</ng-container>
|
||||
<ds-loading
|
||||
*ngIf="!(item$ | async)"
|
||||
*ngIf="!(derivedSearchResult$ | async)"
|
||||
[showMessage]="false"></ds-loading>
|
||||
|
@@ -82,14 +82,15 @@ describe('WorkspaceItemSearchResultListElementComponent', () => {
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
component.dso = mockResultObject.indexableObject;
|
||||
component.object = mockResultObject;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should init item properly', (done) => {
|
||||
component.item$.pipe(take(1)).subscribe((i) => {
|
||||
it('should init derivedSearchResult$ properly', (done) => {
|
||||
component.derivedSearchResult$.pipe(take(1)).subscribe((i) => {
|
||||
expect(linkService.resolveLink).toHaveBeenCalled();
|
||||
expect(i).toBe(item);
|
||||
expect(i.indexableObject).toBe(item);
|
||||
expect(i.hitHighlights).toBe(mockResultObject.hitHighlights);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -1,21 +1,22 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { find, map } from 'rxjs/operators';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model';
|
||||
import { isNotUndefined } from '../../../empty.util';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { WorkspaceItemSearchResult } from '../../../object-collection/shared/workspace-item-search-result.model';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { followLink } from '../../../utils/follow-link-config.model';
|
||||
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
|
||||
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { getFirstSucceededRemoteDataPayload } from '../../../../core/shared/operators';
|
||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
||||
import { followLink } from '../../../utils/follow-link-config.model';
|
||||
|
||||
/**
|
||||
* This component renders workspaceitem object for the search result in the list view.
|
||||
@@ -28,11 +29,14 @@ import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
||||
|
||||
@listableObjectComponent(WorkspaceItemSearchResult, ViewMode.ListElement)
|
||||
export class WorkspaceItemSearchResultListElementComponent extends SearchResultListElementComponent<WorkspaceItemSearchResult, WorkspaceItem> {
|
||||
LinkTypes = CollectionElementLinkType;
|
||||
|
||||
ViewModes = ViewMode;
|
||||
|
||||
/**
|
||||
* The item object that belonging to the result object
|
||||
* The item search result derived from the WorkspaceItemSearchResult
|
||||
*/
|
||||
item$: Observable<Item>;
|
||||
derivedSearchResult$: Observable<ItemSearchResult>;
|
||||
|
||||
/**
|
||||
* Represent item's status
|
||||
@@ -52,17 +56,18 @@ export class WorkspaceItemSearchResultListElementComponent extends SearchResultL
|
||||
*/
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.linkService.resolveLink(this.dso, followLink('item'));
|
||||
this.initItem(this.dso.item as Observable<RemoteData<Item>>);
|
||||
this.deriveSearchResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve item from result object
|
||||
*/
|
||||
initItem(item$: Observable<RemoteData<Item>>) {
|
||||
this.item$ = item$.pipe(
|
||||
find((rd: RemoteData<Item>) => rd.hasSucceeded && isNotUndefined(rd.payload)),
|
||||
map((rd: RemoteData<Item>) => rd.payload)
|
||||
);
|
||||
private deriveSearchResult() {
|
||||
this.linkService.resolveLink(this.object.indexableObject, followLink('item'));
|
||||
this.derivedSearchResult$ = this.object.indexableObject.item.pipe(
|
||||
getFirstSucceededRemoteDataPayload(),
|
||||
map((item: Item) => {
|
||||
const result = new ItemSearchResult();
|
||||
result.indexableObject = item;
|
||||
result.hitHighlights = this.object.hitHighlights;
|
||||
return result;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user