Skip to content

Commit

Permalink
Merge pull request DSpace#2061 from CrisGuzmanS/collection-in-workflo…
Browse files Browse the repository at this point in the history
…w-tasks

Collection in workflow tasks
  • Loading branch information
tdonohue authored Feb 13, 2023
2 parents bd428d7 + c74ef49 commit 6cb6737
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/app/my-dspace-page/my-dspace-search.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ClaimedApprovedSearchResultListElementComponent } from '../shared/objec
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';
import { ItemSubmitterComponent } from '../shared/object-collection/shared/mydspace-item-submitter/item-submitter.component';
import { ItemCollectionComponent } from '../shared/object-collection/shared/mydspace-item-collection/item-collection.component';
import { ItemDetailPreviewComponent } from '../shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview.component';
import { ItemDetailPreviewFieldComponent } from '../shared/object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component';
import { ItemListPreviewComponent } from '../shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component';
Expand Down Expand Up @@ -46,6 +47,7 @@ const ENTRY_COMPONENTS = [
const DECLARATIONS = [
...ENTRY_COMPONENTS,
ItemSubmitterComponent,
ItemCollectionComponent,
ItemDetailPreviewComponent,
ItemDetailPreviewFieldComponent,
ItemListPreviewComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="mt-2 mb-2" *ngIf="(collection$ | async)">
<span class="text-muted">{{'collection.listelement.badge' | translate}}:
<a [routerLink]="['/collections', (collection$ | async)?.id]">
{{(collection$ | async)?.name}}
</a>
</span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Component, Input, OnInit } from '@angular/core';

import { EMPTY, Observable } from 'rxjs';
import { map, mergeMap } from 'rxjs/operators';

import { RemoteData } from '../../../../core/data/remote-data';
import { isNotEmpty } from '../../../empty.util';
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
import { Collection } from '../../../../core/shared/collection.model';
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
import { LinkService } from '../../../../core/cache/builders/link.service';
import { followLink } from '../../../utils/follow-link-config.model';

/**
* This component represents a badge with collection information.
*/
@Component({
selector: 'ds-item-collection',
styleUrls: ['./item-collection.component.scss'],
templateUrl: './item-collection.component.html'
})
export class ItemCollectionComponent implements OnInit {

/**
* The target object
*/
@Input() object: any;

/**
* The collection object
*/
collection$: Observable<Collection>;

public constructor(protected linkService: LinkService) {

}

/**
* Initialize collection object
*/
ngOnInit() {

this.linkService.resolveLinks(this.object, followLink('workflowitem', {
isOptional: true
},
followLink('collection',{})
));
this.collection$ = (this.object.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
getFirstCompletedRemoteData(),
mergeMap((rd: RemoteData<WorkflowItem>) => {
if (rd.hasSucceeded && isNotEmpty(rd.payload)) {
return (rd.payload.collection as Observable<RemoteData<Collection>>).pipe(
getFirstCompletedRemoteData(),
map((rds: RemoteData<Collection>) => {
if (rds.hasSucceeded && isNotEmpty(rds.payload)) {
return rds.payload;
} else {
return null;
}
})
);
} else {
return EMPTY;
}
}));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="mt-2 mb-2" *ngIf="(submitter$ | async)">
<span class="text-muted">{{'submission.workflow.tasks.generic.submitter' | translate}} : <span class="badge badge-info">{{(submitter$ | async)?.name}}</span></span>
<span class="text-muted">{{'submission.workflow.tasks.generic.submitter' | translate}}: <span class="badge badge-info">{{(submitter$ | async)?.name}}</span></span>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ds-themed-item-list-preview [item]="item$.value"
[object]="object"
[showSubmitter]="showSubmitter"
[workflowItem]="workflowitem$.value"
[status]="status"></ds-themed-item-list-preview>

<div class="row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,36 @@
<ds-truncatable [id]="item.id">
<h3 [innerHTML]="dsoTitle" [ngClass]="{'lead': true,'text-muted': !item.firstMetadataValue('dc.title')}"></h3>
<div>
<span class="text-muted">
<ds-truncatable-part [id]="item.id" [minLines]="1">
(<span *ngIf="item.hasMetadata('dc.publisher')" class="item-list-publisher"
[innerHTML]="item.firstMetadataValue('dc.publisher') + ', '"></span>
<span class="item-list-date"
<span class="text-muted">
<ds-truncatable-part [id]="item.id" [minLines]="1">
(<span *ngIf="item.hasMetadata('dc.publisher')" class="item-list-publisher"
[innerHTML]="item.firstMetadataValue('dc.publisher') + ', '"></span>
<span class="item-list-date"
[innerHTML]="item.firstMetadataValue('dc.date.issued') || ('mydspace.results.no-date' | translate)"></span>)
<span *ngIf="item.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);"
<span *ngIf="item.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);"
class="item-list-authors">
<span
*ngIf="item.allMetadataValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']).length === 0">{{'mydspace.results.no-authors' | translate}}</span>
<span
*ngFor="let author of item.allMetadataValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']); let last=last;">
<span [innerHTML]="author"><span [innerHTML]="author"></span></span>
<span *ngIf="!last">; </span>
<span
*ngIf="item.allMetadataValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']).length === 0">{{'mydspace.results.no-authors'
| translate}}</span>
<span
*ngFor="let author of item.allMetadataValues(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']); let last=last;">
<span [innerHTML]="author"><span [innerHTML]="author"></span></span>
<span *ngIf="!last">; </span>
</span>
</span>
</span>

</ds-truncatable-part>
</span>
</ds-truncatable-part>
</span>

<ds-truncatable-part [id]="item.id" [minLines]="1" class="item-list-abstract">
<span [ngClass]="{'text-muted': !item.firstMetadataValue('dc.description.abstract')}"
<span [ngClass]="{'text-muted': !item.firstMetadataValue('dc.description.abstract')}"
[innerHTML]="(item.firstMetadataValue('dc.description.abstract')) || ('mydspace.results.no-abstract' | translate)"></span>
</ds-truncatable-part>

</div>
</ds-truncatable>
<ds-item-submitter *ngIf="showSubmitter" [object]="object.indexableObject"></ds-item-submitter>
<ds-item-collection [object]="object.indexableObject"></ds-item-collection>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { SearchResult } from '../../../search/models/search-result.model';
import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interface';
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
import { WorkflowItem } from 'src/app/core/submission/models/workflowitem.model';

/**
* This component show metadata for the given item object in the list view.
Expand Down Expand Up @@ -40,6 +41,11 @@ export class ItemListPreviewComponent implements OnInit {
*/
@Input() showSubmitter = false;

/**
* Represents the workflow of the item
*/
@Input() workflowItem: WorkflowItem;

/**
* Display thumbnails if required by configuration
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { Component, Input } from '@angular/core';
import { ChangeDetectorRef, Component, ComponentFactoryResolver, Input } from '@angular/core';
import { ThemedComponent } from '../../../theme-support/themed.component';
import { ItemListPreviewComponent } from './item-list-preview.component';
import { Item } from '../../../../core/shared/item.model';
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
import { SearchResult } from '../../../search/models/search-result.model';
import { WorkflowItem } from 'src/app/core/submission/models/workflowitem.model';
import { ThemeService } from 'src/app/shared/theme-support/theme.service';

/**
* Themed wrapper for ItemListPreviewComponent
*/
@Component({
selector: 'ds-themed-item-list-preview',
styleUrls: [],
templateUrl: '../../../theme-support/themed.component.html',
templateUrl: '../../../theme-support/themed.component.html'
})
export class ThemedItemListPreviewComponent extends ThemedComponent<ItemListPreviewComponent> {
protected inAndOutputNames: (keyof ItemListPreviewComponent & keyof this)[] = ['item', 'object', 'status', 'showSubmitter'];
protected inAndOutputNames: (keyof ItemListPreviewComponent & keyof this)[] = ['item', 'object', 'status', 'showSubmitter', 'workflowItem'];

@Input() item: Item;

Expand All @@ -24,6 +26,19 @@ export class ThemedItemListPreviewComponent extends ThemedComponent<ItemListPrev

@Input() showSubmitter = false;

@Input() workflowItem: WorkflowItem;

constructor(
protected resolver: ComponentFactoryResolver,
protected cdr: ChangeDetectorRef,
protected themeService: ThemeService,
) {
super(resolver, cdr, themeService);
}

ngOnInit() {
super.ngOnInit();
}

protected getComponentName(): string {
return 'ItemListPreviewComponent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ds-themed-item-list-preview [item]="item$.value"
[object]="object"
[showSubmitter]="showSubmitter"
[workflowItem]="workflowitem$.value"
[status]="status"></ds-themed-item-list-preview>
<div class="row">
<div [ngClass]="showThumbnails ? 'offset-3 offset-md-2 pl-3' : ''">
Expand Down

0 comments on commit 6cb6737

Please sign in to comment.