Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data@TAMU Issue #100: Move dataset name customizations to themes and isolate to dataset #107

Open
wants to merge 10 commits into
base: tamu-rdc-dspace-7_x-sprint5-staging
Choose a base branch
from
28 changes: 5 additions & 23 deletions src/app/core/breadcrumbs/dso-name.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export class DSONameService {
},
Default: (dso: DSpaceObject): string => {
// If object doesn't have dc.title metadata use name property
// TAMU Customization - only added two or conditions up to dc.title.dataset after the || is core code.
return dso.firstMetadataValue('dc.title.project') || dso.firstMetadataValue('dc.title.dataset') || dso.firstMetadataValue('dc.title') || dso.name || this.translateService.instant('dso.name.untitled');
return dso.firstMetadataValue('dc.title') || dso.name || this.translateService.instant('dso.name.untitled');
}
};

Expand Down Expand Up @@ -96,8 +95,7 @@ export class DSONameService {
const types = dso.getRenderTypes();
const entityType = types
.filter((type) => typeof type === 'string')
// TAMU Customization - added 'Dataset' after 'Person'
.find((type: string) => (['Person', 'Dataset']).includes(type)) as string;
.find((type: string) => (['Person', 'OrgUnit']).includes(type)) as string;
if (entityType === 'Person') {
const familyName = this.firstMetadataValue(object, dso, 'person.familyName');
const givenName = this.firstMetadataValue(object, dso, 'person.givenName');
Expand All @@ -107,26 +105,10 @@ export class DSONameService {
return familyName || givenName;
}
return `${familyName}, ${givenName}`;
// TAMU Customization - switched the entity type to look for DATASET instead of orgUnit
} else if (entityType === 'Dataset') {
// return this.firstMetadataValue(object, dso, 'organization.legalName') || this.translateService.instant('dso.name.untitled'); <- the core code
// TAMU Customization - Item list view to show Dimension tile and Project long Title. It will default to one or the other if only one exists.
const datasetTitle = dso.firstMetadataValue('dc.title.dataset');
const projectTitle = dso.firstMetadataValue('dc.title.project');

if (datasetTitle && projectTitle) {
return `${datasetTitle}: Supplement to ${projectTitle}`;
} else if (datasetTitle) {
return datasetTitle;
} else if (projectTitle) {
return projectTitle;
} else {
return this.translateService.instant('dso.name.untitled');
}
// END TAMU Customization - Item list view to show Dimension tile and Project long Title. It will default to one or the other if only one exists.
} else if (entityType === 'OrgUnit') {
return this.firstMetadataValue(object, dso, 'organization.legalName') || this.translateService.instant('dso.name.untitled');
}
// TAMU Customization - only added two || conditions up to dc.title.dataset after the || is core code.(dso.name and || this.translateService.instant('dso.name.untitled') )
return this.firstMetadataValue(object, dso, 'dc.title.project') || dso.firstMetadataValue('dc.title.dataset') || dso.firstMetadataValue('dc.title') || dso.name || this.translateService.instant('dso.name.untitled');
return this.firstMetadataValue(object, dso, 'dc.title') || dso.name || this.translateService.instant('dso.name.untitled');
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
<!-- // Core code block- Left intact on purpose -->
<!-- <h1 class="item-page-title-field">
<div *ngIf="item.firstMetadataValue('dspace.entity.type') as type" class="d-inline">
{{ type.toLowerCase() + '.page.titleprefix' | translate }}
</div>
<span class="dont-break-out">{{ dsoNameService.getName(item) }}</span>
</h1> -->
<!-- END of core code block -->

<!-- TAMU Customization -title display on Dataset entities for simple item view -->
<h1 class="item-page-title-field">
<div *ngIf="item.firstMetadataValue('dspace.entity.type') as type" class="d-inline">
{{ type.toLowerCase() + '.page.titleprefix' | translate }}
</div>
<span>
<ng-container *ngIf="item.firstMetadataValue('dc.title.dataset') as dataset">
{{ dataset }}
<ng-container *ngIf="item.firstMetadataValue('dc.title.project') as project">
: Supplement to {{ project }}
</ng-container>
</ng-container>
<ng-container *ngIf="!item.firstMetadataValue('dc.title.dataset') && item.firstMetadataValue('dc.title.project')">
{{ item.firstMetadataValue('dc.title.project') }}
</ng-container>
<ng-container *ngIf="!item.firstMetadataValue('dc.title.dataset') && !item.firstMetadataValue('dc.title.project')">
{{ item.firstMetadataValue('dspace.entity.type') }}
</ng-container>
</span>
<span class="dont-break-out">{{ dsoNameService.getName(item) }}</span>
</h1>
<!-- END TAMU Customization -title display on Dataset entities for simple item view -->
55 changes: 55 additions & 0 deletions src/themes/rdc/app/core/breadcrumbs/rdc-dso-name.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Injectable } from '@angular/core';
import { DSpaceObject } from '../../../../../app/core/shared/dspace-object.model';

import { TranslateService } from '@ngx-translate/core';
import {
DSONameService
} from '../../../../../app/core/breadcrumbs/dso-name.service';
import { isNotEmpty } from '../../../../../app/shared/empty.util';

@Injectable()
export class RdcDSONameService extends DSONameService {

readonly translate: TranslateService;

constructor(translateService: TranslateService) {
super(translateService);
this.translate = translateService;
}

getName(dso: DSpaceObject | undefined): string {
if (this.isDataset(dso)) {
const dataset = dso.firstMetadataValue('dc.title');
const project = dso.firstMetadataValue('dc.title.project');

if (isNotEmpty(dataset) && isNotEmpty(project)) {
return this.translate.instant('dataset.supplement.to', {
dataset, project
});
} else if (isNotEmpty(dataset)) {
return dataset;
}
}

return super.getName(dso);
}

getHitHighlights(object: any, dso: DSpaceObject): string {
if (this.isDataset(dso)) {
const dataset = dso.firstMetadataValue('dc.title');

if (isNotEmpty(dataset)) {
return dataset;
}
}

return super.getHitHighlights(object, dso);
}

private isDataset(dso: DSpaceObject): boolean {
return dso?.getRenderTypes()
.filter((type) => typeof type === 'string')
.some((type: string) => 'Dataset' === type);
}

}
4 changes: 3 additions & 1 deletion src/themes/rdc/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@

"dataset.page.id": "ID",

"dataset.page.titleprefix": "Dataset: ",
"dataset.page.titleprefix": "",

"dataset.search.results.head": "Dataset Search Results",

"dataset.supplement.to": "{{ dataset }}: Supplement to {{ project }}",

"dataset-relationships.search.results.head": "Dataset Search Results",

"researchproject.listelement.badge": "Research Project",
Expand Down
5 changes: 4 additions & 1 deletion src/themes/rdc/eager-theme.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { DSONameService } from '../../app/core/breadcrumbs/dso-name.service';
import { ItemPageModule } from '../../app/item-page/item-page.module';
import { ItemSharedModule } from '../../app/item-page/item-shared.module';
import { NavbarModule } from '../../app/navbar/navbar.module';
Expand All @@ -8,6 +9,7 @@ import { SharedBrowseByModule } from '../../app/shared/browse-by/shared-browse-b
import { DsoPageModule } from '../../app/shared/dso-page/dso-page.module';
import { ResultsBackButtonModule } from '../../app/shared/results-back-button/results-back-button.module';
import { SharedModule } from '../../app/shared/shared.module';
import { RdcDSONameService } from './app/core/breadcrumbs/rdc-dso-name.service';
import { UntypedItemComponent } from './app/item-page/simple/item-types/untyped-item/untyped-item.component';

/**
Expand Down Expand Up @@ -36,7 +38,8 @@ const DECLARATIONS = [
],
declarations: DECLARATIONS,
providers: [
...ENTRY_COMPONENTS.map((component) => ({ provide: component }))
...ENTRY_COMPONENTS.map((component) => ({ provide: component })),
{ provide: DSONameService, useClass: RdcDSONameService }
],
})
/**
Expand Down