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

Allow input of alternative text for collection and community logos/th… #3389

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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 @@ -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: 8 additions & 3 deletions src/app/collection-page/collection-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
<ds-comcol-page-header
[name]="dsoNameService.getName(collection)">
</ds-comcol-page-header>
<!-- Collection logo -->
<ds-comcol-page-logo *ngIf="logoRD$"
<!-- Collection logo with custom description -->
<ds-comcol-page-logo *ngIf="logoRD$ && collection.descriptionThumbnail"
[logo]="(logoRD$ | async)?.payload"
[alternateText]="'collection.logo' | translate">
[alternateText]="collection.descriptionThumbnail">
</ds-comcol-page-logo>
<!-- Collection logo with simple description -->
<ds-comcol-page-logo *ngIf="logoRD$ && !collection.descriptionThumbnail"
[logo]="(logoRD$ | async)?.payload"
[alternateText]="'collection.logo' | translate">
</ds-comcol-page-logo>

<!-- Handle -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,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
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' | translate">
<!-- 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' | translate">
</ds-comcol-page-logo>
<!-- Handle -->
<ds-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 @@ -130,6 +130,14 @@
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');

Check warning on line 138 in src/app/core/shared/collection.model.ts

View check run for this annotation

Codecov / codecov/patch

src/app/core/shared/collection.model.ts#L138

Added line #L138 was not covered by tests
}

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 @@
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');

Check warning on line 119 in src/app/core/shared/community.model.ts

View check run for this annotation

Codecov / codecov/patch

src/app/core/shared/community.model.ts#L119

Added line #L119 was not covered by tests
}

getParentLinkKey(): keyof this['_links'] {
return 'parentCommunity';
}
Expand Down
6 changes: 4 additions & 2 deletions src/app/thumbnail/thumbnail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
</div>
</div>
<!-- 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}"
[src]="src | dsSafeUrl" [alt]="alt | translate" (error)="errorHandler()" (load)="successHandler()">
<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">
<div class="thumbnail-placeholder centered lead">
Expand Down
26 changes: 25 additions & 1 deletion src/app/thumbnail/thumbnail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Component,
Input,
OnChanges,
OnInit,
SimpleChanges,
} from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
Expand Down Expand Up @@ -35,12 +36,17 @@
standalone: true,
imports: [VarDirective, CommonModule, ThemedLoadingComponent, TranslateModule, SafeUrlPipe],
})
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 @@ -59,6 +65,11 @@
*/
@Input() alt? = 'thumbnail.default.alt';

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

/**
* i18n key of HTML placeholder text
*/
Expand All @@ -82,6 +93,19 @@
) {
}

/**
* 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;
this.customDescription = this.listenThumbnail.payload.metadata['dc.description'][0].value;

Check warning on line 104 in src/app/thumbnail/thumbnail.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/thumbnail/thumbnail.component.ts#L103-L104

Added lines #L103 - L104 were not covered by tests
}
}
}

/**
* Resolve the thumbnail.
* Use a default image if no actual image is available.
Expand Down
6 changes: 5 additions & 1 deletion src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -6763,4 +6763,8 @@
"register-page.registration.aria.label": "Enter your e-mail address",

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

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

"collection.form.thumbnail": "Thumbnail Description",
}
14 changes: 12 additions & 2 deletions src/assets/i18n/es.json5
Original file line number Diff line number Diff line change
Expand Up @@ -9164,6 +9164,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 @@ -10192,5 +10201,6 @@
// "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",
}
8 changes: 7 additions & 1 deletion src/assets/i18n/pt-BR.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10229,9 +10229,15 @@
// "item.page.cc.license.disclaimer": "Except where otherwised noted, this item's license is described as",
"item.page.cc.license.disclaimer": "Exceto quando indicado de outra forma, a licença deste item é descrita como",

//"browse.search-form.placeholder": "Search the repository",
// "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
6 changes: 6 additions & 0 deletions src/assets/i18n/pt-PT.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10361,4 +10361,10 @@
// "item.preview.dc.identifier.eisbn": "EISBN",
"item.preview.dc.identifier.eisbn": "EISBN",

// "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