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

DSpace#1306 - Implementation that makes it possible to customize thum… #2783

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export const collectionFormModels: DynamicFormControlModel[] = [
name: 'dc.description.abstract',
spellCheck: environment.form.spellCheck,
}),
new DynamicTextAreaModel({
id: 'thumbnail',
name: 'dc.description.thumbnail',
Copy link
Member

@tdonohue tdonohue Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanGastardelli : This dc.description.thumbnail field isn't a valid Qualified Dublin Core field, so I would not recommend adding it. Additionally, this is metadata about the Bitstream (logo), but you appear to be storing this metadata on the Collection.

It's not a great idea to store this on the Collection, as it means that this dc.description.thumbnail field would be shared as Collection description metadata whenever someone accesses the Collection from the REST API (or other machine interfaces like OAI-PMH).

Ideally, it'd be better to store this metadata as simply dc.description (which already exists) on the Bitstream object itself. That'd be much clearer & cleaner than creating a new metadata field to store the information on the Collection.

If it's not possible or easy to store this metadata on the Bitstream itself, then we could consider keeping this metadata on the Collection, but store it in a "hidden" field like dspace.thumbnail.description. This would be better than creating an invalid dc.description field. But, this new field would need to be created though in the dspace/config/registries/dspace-types.xml on the backend.

spellCheck: environment.form.spellCheck,
}),
new DynamicTextAreaModel({
id: 'rights',
name: 'dc.rights',
Expand Down
9 changes: 4 additions & 5 deletions src/app/collection-page/collection-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
<ds-comcol-page-header
[name]="dsoNameService.getName(collection)">
</ds-comcol-page-header>
<!-- Collection logo -->
<ds-comcol-page-logo *ngIf="logoRD$"
[logo]="(logoRD$ | async)?.payload"
[alternateText]="'Collection Logo'">
<!-- Collection logo with custom description -->
<ds-comcol-page-logo *ngIf="logoRD$ && collection.descriptionThumbnail"
[logo]="(logoRD$ | async)?.payload"
[alternateText]="collection.descriptionThumbnail">
</ds-comcol-page-logo>

<!-- Handle -->
<ds-themed-comcol-page-handle
[content]="collection.handle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ export class CommunityFormComponent extends ComColFormComponent<Community> imple
name: 'dc.description.abstract',
spellCheck: environment.form.spellCheck,
}),
new DynamicTextAreaModel({
id: 'thumbnail',
name: 'dc.description.thumbnail',
spellCheck: environment.form.spellCheck,
}),
new DynamicTextAreaModel({
id: 'rights',
name: 'dc.rights',
Expand Down
7 changes: 5 additions & 2 deletions src/app/community-page/community-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
<header class="comcol-header mr-auto">
<!-- Community name -->
<ds-comcol-page-header [name]="dsoNameService.getName(communityPayload)"></ds-comcol-page-header>
<!-- Community logo -->
<ds-comcol-page-logo *ngIf="logoRD$" [logo]="(logoRD$ | async)?.payload" [alternateText]="'Community Logo'">
<!-- Community logo with custom description -->
<ds-comcol-page-logo *ngIf="logoRD$ && communityPayload.descriptionThumbnail" [logo]="(logoRD$ | async)?.payload" [alternateText]="communityPayload.descriptionThumbnail">
</ds-comcol-page-logo>
<!-- Community logo with simple description -->
<ds-comcol-page-logo *ngIf="logoRD$ && !communityPayload.descriptionThumbnail" [logo]="(logoRD$ | async)?.payload" [alternateText]="'Community Logo'">
</ds-comcol-page-logo>
<!-- Handle -->
<ds-themed-comcol-page-handle [content]="communityPayload.handle" [title]="'community.page.handle'">
Expand Down
8 changes: 8 additions & 0 deletions src/app/core/shared/collection.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ export class Collection extends DSpaceObject implements ChildHALResource, Handle
return this.firstMetadataValue('dc.description');
}

/**
* The thumbail description of this Collection
* Corresponds to the metadata field dc.description.thumbnail
*/
get descriptionThumbnail(): string {
return this.firstMetadataValue('dc.description.thumbnail');
}

/**
* The short description: HTML
* Corresponds to the metadata field dc.description.abstract
Expand Down
8 changes: 8 additions & 0 deletions src/app/core/shared/community.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ export class Community extends DSpaceObject implements ChildHALResource, HandleO
return this.firstMetadataValue('dc.description');
}

/**
* The thumbail description of this Community
* Corresponds to the metadata field dc.description.thumbnail
*/
get descriptionThumbnail(): string {
return this.firstMetadataValue('dc.description.thumbnail');
}

/**
* The short description: HTML
* Corresponds to the metadata field dc.description.abstract
Expand Down
4 changes: 3 additions & 1 deletion src/app/thumbnail/thumbnail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
</div>
<ng-container *ngVar="(src$ | async) as src">
<!-- don't use *ngIf="!isLoading" so the thumbnail can load in while the animation is playing -->
<img *ngIf="src !== null" class="thumbnail-content img-fluid" [ngClass]="{'d-none': isLoading}"
<img *ngIf="src !== null && customDescription !== undefined" class="thumbnail-content img-fluid" [ngClass]="{'d-none': isLoading}"
[src]="src | dsSafeUrl" [alt]="customDescription" (error)="errorHandler()" (load)="successHandler()">
<img *ngIf="src !== null && customDescription == undefined" class="thumbnail-content img-fluid" [ngClass]="{'d-none': isLoading}"
[src]="src | dsSafeUrl" [alt]="alt | translate" (error)="errorHandler()" (load)="successHandler()">
<div *ngIf="src === null && !isLoading" class="thumbnail-content outer">
<div class="inner">
Expand Down
23 changes: 21 additions & 2 deletions src/app/thumbnail/thumbnail.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { Component, Input, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { Bitstream } from '../core/shared/bitstream.model';
import { hasNoValue, hasValue } from '../shared/empty.util';
import { RemoteData } from '../core/data/remote-data';
Expand All @@ -19,18 +19,28 @@ import { FileService } from '../core/shared/file.service';
styleUrls: ['./thumbnail.component.scss'],
templateUrl: './thumbnail.component.html',
})
export class ThumbnailComponent implements OnChanges {
export class ThumbnailComponent implements OnInit, OnChanges {
/**
* The thumbnail Bitstream
*/
@Input() thumbnail: Bitstream | RemoteData<Bitstream>;

/**
* Variable that listens to the thumbnail value
*/
listenThumbnail: any;

/**
* The default image, used if the thumbnail isn't set or can't be downloaded.
* If defaultImage is null, a HTML placeholder is used instead.
*/
@Input() defaultImage? = null;

/**
* Custom thumbnail description for alt text
*/
customDescription: string;

/**
* The src attribute used in the template to render the image.
*/
Expand Down Expand Up @@ -66,6 +76,15 @@ export class ThumbnailComponent implements OnChanges {
) {
}

/**
* Getting the description from the thumbnail file
* when rendering the screen.
*/
ngOnInit(): void{
this.listenThumbnail = this.thumbnail;
this.customDescription = this.listenThumbnail.payload.metadata['dc.description'][0].value;
}

/**
* Resolve the thumbnail.
* Use a default image if no actual image is available.
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 @@ -5300,4 +5300,8 @@

"vocabulary-treeview.search.form.add": "Add",

"community.form.thumbnail": "Thumbnail Description",

"collection.form.thumbnail": "Thumbnail Description",

}
4 changes: 4 additions & 0 deletions src/assets/i18n/es.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7825,6 +7825,10 @@
// "access-control-option-end-date-note": "Select the date until which the related access condition is applied",
"access-control-option-end-date-note": "Escoja la fecha hasta la cuál se aplicarán las condiciones de acceso especificadas",

// "community.form.thumbnail": "Thumbnail Description",
"community.form.thumbnail": "Descripción del logotipo",

// "collection.form.thumbnail": "Thumbnail Description",
"collection.form.thumbnail": "Descripción del logotipo",

}
7 changes: 7 additions & 0 deletions src/assets/i18n/pt-BR.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7850,4 +7850,11 @@

// "access-control-option-end-date-note": "Select the date until which the related access condition is applied", (Auto-Translated)
"access-control-option-end-date-note": "Selecione a data até a qual a condição de acesso relacionada é aplicada",

// "community.form.thumbnail": "Thumbnail Description",
"community.form.thumbnail": "Descrição do logotipo",

// "collection.form.thumbnail": "Thumbnail Description",
"collection.form.thumbnail": "Descrição do logotipo",

}
5 changes: 5 additions & 0 deletions src/assets/i18n/pt-PT.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7821,4 +7821,9 @@
// "item.preview.dc.identifier.eisbn": "EISBN",
"item.preview.dc.identifier.eisbn": "EISBN",

// "community.form.thumbnail": "Thumbnail Description",
"community.form.thumbnail": "Descrição do logotipo",

// "collection.form.thumbnail": "Thumbnail Description",
"collection.form.thumbnail": "Descrição do logotipo",
}
Loading