Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
07d489b
Allow input of alternative text for collection and community logos/th…
DanGastardelli Oct 4, 2024
cc74739
Checking for thumbnail with valid value
DanGastardelli Oct 4, 2024
3fe8375
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Oct 10, 2024
0ab24be
Fixed merge done in git
DanGastardelli Oct 10, 2024
296d4fb
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Nov 5, 2024
909aa99
Space correction
DanGastardelli Nov 5, 2024
cb75276
Space correction
DanGastardelli Nov 5, 2024
c78b775
Space correction
DanGastardelli Nov 8, 2024
5affeb1
Merge branch 'UpdatingAlternativeTextInThumbnails' of https://github.…
DanGastardelli Nov 8, 2024
a90c02c
Space correction
DanGastardelli Nov 8, 2024
b140ca0
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Dec 19, 2024
0254f3d
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Jan 9, 2025
3ed8b29
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Jan 14, 2025
cc0bbc8
Update es.json5
DanGastardelli Jan 14, 2025
daa04ca
Update es.json5
DanGastardelli Jan 14, 2025
2e58674
Update es.json5
DanGastardelli Jan 14, 2025
837d5c0
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Jan 29, 2025
3c9002b
Update es.json5
DanGastardelli Jan 29, 2025
041a243
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Feb 19, 2025
d7716ac
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Mar 11, 2025
a1e206a
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Mar 17, 2025
b364abc
Update pt-PT.json5
DanGastardelli Mar 17, 2025
800349e
Update thumbnail.component.html
DanGastardelli Mar 17, 2025
5b94a64
Merge branch 'main' into UpdatingAlternativeTextInThumbnails
DanGastardelli Aug 25, 2025
94547fb
Update pt-PT.json5
DanGastardelli Aug 25, 2025
32f95b3
Updating 'thumbnail.component.html'
DanGastardelli Aug 25, 2025
8bd7a43
Update thumbnail.component.html
DanGastardelli Aug 25, 2025
a32bd05
Update thumbnail.component.html
DanGastardelli Aug 25, 2025
e41f1ac
Test setup for implementing custom thumbnail alt text
DanGastardelli Aug 25, 2025
b60f9ea
Update 'thumbnail.component.spec.ts'
DanGastardelli Aug 25, 2025
e8d71ae
Code simplification and preventative adjustments
DanGastardelli Jan 16, 2026
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 @@ -54,4 +54,9 @@ export const collectionFormModels: DynamicFormControlModel[] = [
name: 'dc.rights.license',
spellCheck: environment.form.spellCheck,
}),
new DynamicTextAreaModel({
id: 'thumbnail',
name: 'dspace.thumbnail.description',
spellCheck: environment.form.spellCheck,
}),
];
11 changes: 9 additions & 2 deletions src/app/collection-page/collection-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@
<ds-comcol-page-header
[name]="dsoNameService.getName(collection)">
</ds-comcol-page-header>
<!-- Collection logo -->
@if (logoRD$) {
<!-- Collection logo with custom description -->
@if (logoRD$ && collection.descriptionThumbnail) {
<ds-comcol-page-logo
[logo]="(logoRD$ | async)?.payload"
[alternateText]="collection.descriptionThumbnail">
</ds-comcol-page-logo>
Comment on lines +15 to +19
Copy link
Member

Choose a reason for hiding this comment

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

This can be optimized the same way you did for the thumbnail component, by conditionally setting the value of alternateText

}
<!-- Collection logo with simple description -->
@if (logoRD$ && !collection.descriptionThumbnail) {
<ds-comcol-page-logo
[logo]="(logoRD$ | async)?.payload"
[alternateText]="'collection.logo' | translate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export class CommunityFormComponent extends ComColFormComponent<Community> imple
name: 'dc.description.tableofcontents',
spellCheck: environment.form.spellCheck,
}),
new DynamicTextAreaModel({
id: 'thumbnail',
name: 'dspace.thumbnail.description',
spellCheck: environment.form.spellCheck,
}),
];

public constructor(protected formService: DynamicFormService,
Expand Down
9 changes: 7 additions & 2 deletions src/app/community-page/community-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
<header class="comcol-header me-auto">
<!-- Community name -->
<ds-comcol-page-header [name]="dsoNameService.getName(communityPayload)"></ds-comcol-page-header>
<!-- Community logo -->
@if (logoRD$) {
<!-- Community logo with custom description -->
@if (logoRD$ && communityPayload.descriptionThumbnail) {
<ds-comcol-page-logo [logo]="(logoRD$ | async)?.payload" [alternateText]="communityPayload.descriptionThumbnail">
</ds-comcol-page-logo>
}
<!-- Community logo with simple description -->
@if (logoRD$ && !communityPayload.descriptionThumbnail) {
Comment on lines +10 to +16
Copy link
Member

Choose a reason for hiding this comment

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

Same here

<ds-comcol-page-logo [logo]="(logoRD$ | async)?.payload" [alternateText]="'community.logo' | translate">
</ds-comcol-page-logo>
}
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 @@ -130,6 +130,14 @@ export class Collection extends DSpaceObject implements ChildHALResource, Handle
return this.firstMetadataValue('dc.description.tableofcontents');
}

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

Choose a reason for hiding this comment

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

It was suggested in today's meeting that the more appropriate place to store the "alt" text for a Bitstream would be on the Bitstream object itself in the dc.description field. This has two main benefits:

  • It would avoid needing to create a new metadata field on the backend.
  • It'd also be better to store this information on the Bitstream as the "alt" text is a description of the Bitstream, and not something that belongs to the Collection. That way, if the Bitstream logo changes, then the old "alt" text goes away and new text comes with the new Bitstream.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @tdonohue's comment here

}

getParentLinkKey(): keyof this['_links'] {
return 'parentCommunity';
}
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 @@ -111,6 +111,14 @@ export class Community extends DSpaceObject implements ChildHALResource, HandleO
return this.firstMetadataValue('dc.description.tableofcontents');
}

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

getParentLinkKey(): keyof this['_links'] {
return 'parentCommunity';
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/thumbnail/thumbnail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
</div>
}
<!-- don't use *ngIf="!isLoading" so the thumbnail can load in while the animation is playing -->
@if (src() !== null) {
@if (src()) {
<img class="thumbnail-content img-fluid"
[class.d-none]="isLoading()"
[src]="src() | dsSafeUrl"
[alt]="alt | translate"
[alt]="customDescription ? customDescription : alt | translate"
(error)="errorHandler()"
(load)="successHandler()"/>
}
@if (src() === null && isLoading() === false) {
@if (!src() && isLoading() === false) {
<div class="thumbnail-content outer">
<div class="inner">
<div class="thumbnail-placeholder centered">
Expand Down
22 changes: 16 additions & 6 deletions src/app/thumbnail/thumbnail.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,14 @@ describe('ThumbnailComponent', () => {
});

it('should set isLoading$ to false once an image is successfully loaded', () => {
comp.customDescription = undefined;
comp.setSrc('http://bit.stream');
fixture.debugElement.query(By.css('img.thumbnail-content')).triggerEventHandler('load', new Event('load'));

fixture.detectChanges();
const img = fixture.debugElement.query(By.css('img.thumbnail-content'));
expect(img).toBeTruthy();

img.triggerEventHandler('load', new Event('load'));
expect(comp.isLoading()).toBeFalse();
});

Expand Down Expand Up @@ -165,7 +171,11 @@ describe('ThumbnailComponent', () => {
beforeEach(() => {
// disconnect error handler to be sure it's only called once
const img = fixture.debugElement.query(By.css('img.thumbnail-content'));
img.nativeNode.onerror = null;
if (img) {
img.triggerEventHandler('error', new Event('error'));
} else {
comp.errorHandler();
}

comp.ngOnChanges({});
setSrcSpy = spyOn(comp, 'setSrc').and.callThrough();
Expand Down Expand Up @@ -265,15 +275,15 @@ describe('ThumbnailComponent', () => {
});

describe('if there is no default image', () => {
it('should display the HTML placeholder', () => {
it('should display the HTML placeholder when defaultImage is null', () => {
comp.src.set('http://default.img');
comp.defaultImage = null;
comp.errorHandler();
expect(comp.src()).toBe(null);

fixture.detectChanges();
const placeholder = fixture.debugElement.query(By.css('div.thumbnail-placeholder')).nativeElement;
expect(placeholder.innerHTML).toContain('TRANSLATED ' + comp.placeholder);

expect(comp.src()).toBeNull();
expect(comp.isLoading()).toBeFalse();
});
});
});
Expand Down
29 changes: 28 additions & 1 deletion src/app/thumbnail/thumbnail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Inject,
Input,
OnChanges,
OnInit,
PLATFORM_ID,
signal,
SimpleChanges,
Expand Down Expand Up @@ -42,12 +43,17 @@ import { SafeUrlPipe } from '../shared/utils/safe-url-pipe';
TranslatePipe,
],
})
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: RemoteData<Bitstream>;

/**
* 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.
Expand All @@ -66,6 +72,11 @@ export class ThumbnailComponent implements OnChanges {
*/
@Input() alt? = 'thumbnail.default.alt';

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

/**
* i18n key of HTML placeholder text
*/
Expand All @@ -90,6 +101,22 @@ export class ThumbnailComponent implements OnChanges {
) {
}

/**
* Getting the description from the thumbnail file
* when rendering the screen.
*/
ngOnInit(): void{
if (this.thumbnail){
if ('payload' in this.thumbnail) {
this.listenThumbnail = this.thumbnail;
const bitstream = this.listenThumbnail.payload;
if (bitstream && bitstream.hasMetadata('dc.description')) {
this.customDescription = bitstream.firstMetadataValue('dc.description');
}
}
}
}

/**
* 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 @@ -7092,6 +7092,10 @@

"forgot-email.form.aria.label": "Enter your e-mail address",

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

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

"search-facet-option.update.announcement": "The page will be reloaded. Filter {{ filter }} is selected.",

"live-region.ordering.instructions": "Press spacebar to reorder {{ itemName }}.",
Expand Down
12 changes: 12 additions & 0 deletions src/assets/i18n/es.json5
Original file line number Diff line number Diff line change
Expand Up @@ -9747,6 +9747,15 @@
// "vocabulary-treeview.search.form.add": "Add",
"vocabulary-treeview.search.form.add": "Añadir",

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

// "collection.form.thumbnail": "Thumbnail Description",
"collection.form.thumbnail": "Descripción del logo de la colección",

// "file-download-link.download": "Download ",
"file-download-link.download": "Descargar ",

// "admin.notifications.publicationclaim.breadcrumbs": "Publication Claim",
"admin.notifications.publicationclaim.breadcrumbs": "Reclamo de publicación",

Expand Down Expand Up @@ -10799,6 +10808,9 @@
// "forgot-email.form.aria.label": "Enter your e-mail address",
"forgot-email.form.aria.label": "Introduzca su dirección de correo electrónico",

// "search.sidebar.advanced-search.add": "Add",
"search.sidebar.advanced-search.add": "Añadir",

// "search-facet-option.update.announcement": "The page will be reloaded. Filter {{ filter }} is selected.",
"search-facet-option.update.announcement": "La página será recargada. Filtro {{ filter }} seleccionado.",

Expand Down
6 changes: 6 additions & 0 deletions src/assets/i18n/pt-BR.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10899,6 +10899,12 @@
// "browse.search-form.placeholder": "Search the repository",
"browse.search-form.placeholder": "Buscar no repositório",

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

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

// "file-download-link.download": "Download ",
"file-download-link.download": "Baixar ",

Expand Down
5 changes: 5 additions & 0 deletions src/assets/i18n/pt-PT.json5
Original file line number Diff line number Diff line change
Expand Up @@ -11046,5 +11046,10 @@
// TODO New key - Add a translation
"file-download-link.request-copy": "Request a copy of ",

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

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

}
Loading