diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.html b/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.html index ba376d2f64e..0fd99735946 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.html +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.html @@ -10,6 +10,10 @@

+
+ {{ 'mydspace.results.in-workflow-for' | translate }} + {{ getDateForArchivedItem(item.firstMetadataValue('dspace.workflow.startDateTime'), item.firstMetadataValue('dc.date.accessioned')) }} +
diff --git a/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts b/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts index 363741d75b6..78e2c20e095 100644 --- a/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts +++ b/src/app/shared/object-list/my-dspace-result-list-element/item-list-preview/item-list-preview.component.ts @@ -10,6 +10,7 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo import { DuplicateMatchMetadataDetailConfig } from '../../../../submission/sections/detect-duplicate/models/duplicate-detail-metadata.model'; +import { parseISO, differenceInDays, differenceInMilliseconds } from "date-fns"; import { environment } from '../../../../../environments/environment'; /** @@ -83,6 +84,15 @@ export class ItemListPreviewComponent implements OnInit { ) { } + getDateForArchivedItem(itemStartDate: string, dateAccessioned: string) { + const itemStartDateConverted: Date = parseISO(itemStartDate); + const dateAccessionedConverted: Date = parseISO(dateAccessioned); + const days: number = Math.floor(differenceInDays(dateAccessionedConverted, itemStartDateConverted)); + const remainingMilliseconds: number = differenceInMilliseconds(dateAccessionedConverted, itemStartDateConverted) - days * 24 * 60 * 60 * 1000; + const hours: number = Math.floor(remainingMilliseconds / (60 * 60 * 1000)); + return `${days} d ${hours} h`; + } + ngOnInit(): void { this.showThumbnails = this.showThumbnails ?? this.appConfig.browseBy.showThumbnails; this.dsoTitle = this.dsoNameService.getHitHighlights(this.object, this.item); 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 14bb8603451..990166ab51a 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 @@ -26,6 +26,10 @@ [innerHTML]="dsoTitle"> +
+ {{ 'mydspace.results.in-workflow-since' | translate }} + {{ getDateForItem(dso.firstMetadataValue('dspace.workflow.startDateTime')) }} +
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 99b064efaa5..93fb74ca0c1 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 @@ -16,6 +16,7 @@ import { DSONameService } from '../../../../../../core/breadcrumbs/dso-name.serv import { APP_CONFIG, AppConfig } from '../../../../../../../config/app-config.interface'; import { getFirstSucceededRemoteListPayload } from '../../../../../../core/shared/operators'; import { map } from 'rxjs/operators'; +import {differenceInDays, differenceInMilliseconds, parseISO} from 'date-fns'; @listableObjectComponent('PublicationSearchResult', ViewMode.ListElement) @listableObjectComponent(ItemSearchResult, ViewMode.ListElement) @@ -86,6 +87,14 @@ export class ItemSearchResultListElementComponent extends SearchResultListElemen } } + getDateForItem(itemStartDate: string) { + const itemStartDateConverted: Date = parseISO(itemStartDate); + const days: number = Math.floor(differenceInDays(Date.now(), itemStartDateConverted)); + const remainingMilliseconds: number = differenceInMilliseconds(Date.now(), itemStartDateConverted) - days * 24 * 60 * 60 * 1000; + const hours: number = Math.floor(remainingMilliseconds / (60 * 60 * 1000)); + return `${days} d ${hours} h`; + } + /** * Prompt user for consents settings */ diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 324ea338a6f..79f3f73c328 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -4106,6 +4106,10 @@ "mydspace.results.is-correction": "Is a request of correction", + "mydspace.results.in-workflow-since": "In workflow since:", + + "mydspace.results.in-workflow-for": "In workflow for:", + "mydspace.search-form.placeholder": "Search in mydspace...", "mydspace.show.workflow": "Workflow tasks",