Skip to content

Commit

Permalink
Merged in task/dspace-cris-2023_02_x/DSC-1883-AddStartDateTime (pull …
Browse files Browse the repository at this point in the history
…request DSpace#2345)

DSC-1883: Add the startDateTime metadata to the dspace schema

Approved-by: Daniele Ninfo
  • Loading branch information
Micheleboychuk authored and danieleninfo committed Nov 18, 2024
2 parents 644e20c + 11ec203 commit 001de85
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
</div>
<ds-truncatable [id]="item.id">
<h3 [innerHTML]="dsoTitle" [ngClass]="{'lead': true,'text-muted': !item.firstMetadataValue('dc.title')}"></h3>
<div *ngIf="item.hasMetadata('dspace.workflow.startDateTime') && item.hasMetadata('dc.date.accessioned')">
{{ 'mydspace.results.in-workflow-for' | translate }}
{{ getDateForArchivedItem(item.firstMetadataValue('dspace.workflow.startDateTime'), item.firstMetadataValue('dc.date.accessioned')) }}
</div>
<div>
<span class="text-muted">
<ds-truncatable-part [id]="item.id" [minLines]="1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
[innerHTML]="dsoTitle"></a>
<span *ngIf="linkType == linkTypes.None" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></span>
<div *ngIf="dso.hasMetadata('dspace.workflow.startDateTime')">
{{ 'mydspace.results.in-workflow-since' | translate }}
{{ getDateForItem(dso.firstMetadataValue('dspace.workflow.startDateTime')) }}
</div>
<span class="text-muted">
<ds-truncatable-part [id]="dso.id" [minLines]="1">
<ng-container *ngIf="dso.firstMetadataValue('dc.publisher') || dso.firstMetadataValue('dc.date.issued')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TruncatableService } from '../../../../../truncatable/truncatable.servi
import { DSONameService } from '../../../../../../core/breadcrumbs/dso-name.service';
import { APP_CONFIG, AppConfig } from '../../../../../../../config/app-config.interface';
import { getFirstSucceededRemoteListPayload } from '../../../../../../core/shared/operators';
import { differenceInDays, differenceInMilliseconds, parseISO} from 'date-fns';
import { filter, map } from 'rxjs/operators';
import { isNotEmpty } from '../../../../../empty.util';

Expand Down Expand Up @@ -89,6 +90,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
*/
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4180,6 +4180,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",
Expand Down

0 comments on commit 001de85

Please sign in to comment.