Skip to content

Commit 6f1af9a

Browse files
committed
fix: move translateService.currentLang assignment to the component
1 parent 577209a commit 6f1af9a

18 files changed

+88
-13
lines changed

src/app/community-list-page/community-list/community-list.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</div>
4747
<ds-truncatable [id]="node.id">
4848
<div class="text-muted" cdkTreeNodePadding>
49-
<div class="d-flex" *ngIf="node.payload.shortDescription(translateService.currentLang) as shorDescription">
49+
<div class="d-flex" *ngIf="node.payload.shortDescription(currentLanguage) as shorDescription">
5050
<span aria-hidden="true" class="btn btn-default invisible">
5151
<span class="fa fa-chevron-right"></span>
5252
</span>
@@ -77,12 +77,12 @@ <h6 class="align-middle my-auto">
7777
</div>
7878
<ds-truncatable [id]="node.id">
7979
<div class="text-muted" cdkTreeNodePadding>
80-
<div class="d-flex" *ngIf="node.payload.shortDescription(translateService.currentLang)">
80+
<div class="d-flex" *ngIf="node.payload.shortDescription(currentLanguage) as shortDescription">
8181
<span aria-hidden="true" class="btn btn-default invisible">
8282
<span class="fa fa-chevron-right"></span>
8383
</span>
8484
<ds-truncatable-part [id]="node.id" [minLines]="3">
85-
<span>{{node.payload.shortDescription(translateService.currentLang)}}</span>
85+
<span>{{shortDescription}}</span>
8686
</ds-truncatable-part>
8787
</div>
8888
</div>

src/app/community-list-page/community-list/community-list.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
} from '@angular/cdk/tree';
55
import {
66
AsyncPipe,
7-
NgClass,
87
NgIf,
98
} from '@angular/common';
109
import {
@@ -19,6 +18,7 @@ import {
1918
} from '@ngx-translate/core';
2019
import { take } from 'rxjs/operators';
2120

21+
import { environment } from '../../../environments/environment';
2222
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
2323
import {
2424
SortDirection,
@@ -45,10 +45,15 @@ import { FlatNode } from '../flat-node.model';
4545
templateUrl: './community-list.component.html',
4646
styleUrls: ['./community-list.component.scss'],
4747
standalone: true,
48-
imports: [NgIf, ThemedLoadingComponent, CdkTreeModule, NgClass, RouterLink, TruncatableComponent, TruncatablePartComponent, AsyncPipe, TranslateModule],
48+
imports: [NgIf, ThemedLoadingComponent, CdkTreeModule, RouterLink, TruncatableComponent, TruncatablePartComponent, AsyncPipe, TranslateModule],
4949
})
5050
export class CommunityListComponent implements OnInit, OnDestroy {
5151

52+
/**
53+
* The current language of the page
54+
*/
55+
currentLanguage: string = environment.defaultLanguage;
56+
5257
private expandedNodes: FlatNode[] = [];
5358
public loadingNode: FlatNode;
5459

@@ -68,6 +73,8 @@ export class CommunityListComponent implements OnInit, OnDestroy {
6873
this.paginationConfig.elementsPerPage = 2;
6974
this.paginationConfig.currentPage = 1;
7075
this.paginationConfig.sort = new SortOptions('dc.title', SortDirection.ASC);
76+
77+
this.currentLanguage = translateService.currentLang;
7178
}
7279

7380
ngOnInit() {

src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</span>
1010
<div class="card-body">
1111
<h4 class="card-title">{{ dsoNameService.getName(object) }}</h4>
12-
<p *ngIf="object.shortDescription(translateService.currentLang) as shortDescription" class="card-text">{{shortDescription}}</p>
12+
<p *ngIf="object.shortDescription(currentLanguage) as shortDescription" class="card-text">{{shortDescription}}</p>
1313
<div *ngIf="linkType !== linkTypes.None" class="text-center">
1414
<a [target]="(linkType === linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType === linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="['/collections/', object.id]" class="lead btn btn-primary viewButton">{{ 'search.results.view-result' | translate}}</a>
1515
</div>

src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
TranslateService,
1313
} from '@ngx-translate/core';
1414

15+
import { environment } from '../../../../environments/environment';
1516
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
1617
import { LinkService } from '../../../core/cache/builders/link.service';
1718
import { Collection } from '../../../core/shared/collection.model';
@@ -39,6 +40,12 @@ import { followLink } from '../../utils/follow-link-config.model';
3940
export class CollectionGridElementComponent extends AbstractListableElementComponent<
4041
Collection
4142
> {
43+
44+
/**
45+
* The current language of the page
46+
*/
47+
currentLanguage: string = environment.defaultLanguage;
48+
4249
private _object: Collection;
4350

4451
constructor(
@@ -47,6 +54,8 @@ export class CollectionGridElementComponent extends AbstractListableElementCompo
4754
public translateService: TranslateService,
4855
) {
4956
super(dsoNameService);
57+
58+
this.currentLanguage = translateService.currentLang;
5059
}
5160

5261
// @ts-ignore

src/app/shared/object-grid/community-grid-element/community-grid-element.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</span>
1010
<div class="card-body">
1111
<h4 class="card-title">{{ dsoNameService.getName(object) }}</h4>
12-
<p *ngIf="object.shortDescription(translateService.currentLang) as shortDescription" class="card-text">{{shortDescription}}</p>
12+
<p *ngIf="object.shortDescription(currentLanguage) as shortDescription" class="card-text">{{shortDescription}}</p>
1313
<div *ngIf="linkType !== linkTypes.None" class="text-center">
1414
<a [target]="(linkType === linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType === linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="['/communities/', object.id]" class="lead btn btn-primary viewButton">{{ 'search.results.view-result' | translate}}</a>
1515
</div>

src/app/shared/object-grid/community-grid-element/community-grid-element.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
TranslateService,
1313
} from '@ngx-translate/core';
1414

15+
import { environment } from '../../../../environments/environment';
1516
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
1617
import { LinkService } from '../../../core/cache/builders/link.service';
1718
import { Community } from '../../../core/shared/community.model';
@@ -38,6 +39,12 @@ import { followLink } from '../../utils/follow-link-config.model';
3839

3940
@listableObjectComponent(Community, ViewMode.GridElement)
4041
export class CommunityGridElementComponent extends AbstractListableElementComponent<Community> {
42+
43+
/**
44+
* The current language of the page
45+
*/
46+
currentLanguage: string = environment.defaultLanguage;
47+
4148
private _object: Community;
4249

4350
constructor(
@@ -46,6 +53,8 @@ export class CommunityGridElementComponent extends AbstractListableElementCompon
4653
public translateService: TranslateService,
4754
) {
4855
super(dsoNameService);
56+
57+
this.currentLanguage = translateService.currentLang;
4958
}
5059

5160
// @ts-ignore

src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="card-body">
1111
<ds-badges *ngIf="showLabel" [object]="dso" [context]="context"></ds-badges>
1212
<h4 class="card-title">{{ dsoNameService.getName(dso) }}</h4>
13-
<p *ngIf="dso.shortDescription(translateService.currentLang) as shortDescription" class="card-text">{{shortDescription}}</p>
13+
<p *ngIf="dso.shortDescription(currentLanguage) as shortDescription" class="card-text">{{shortDescription}}</p>
1414
<div *ngIf="linkType !== linkTypes.None" class="text-center">
1515
<a [target]="(linkType === linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType === linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="['/collections/', dso.id]" class="lead btn btn-primary viewButton">{{ 'search.results.view-result' | translate}}</a>
1616
</div>

src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
TranslateService,
1313
} from '@ngx-translate/core';
1414

15+
import { environment } from '../../../../../environments/environment';
1516
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
1617
import { LinkService } from '../../../../core/cache/builders/link.service';
1718
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
@@ -43,6 +44,11 @@ import { SearchResultGridElementComponent } from '../search-result-grid-element.
4344
export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent< CollectionSearchResult, Collection > {
4445
private _dso: Collection;
4546

47+
/**
48+
* The current language of the page
49+
*/
50+
currentLanguage: string = environment.defaultLanguage;
51+
4652
constructor(
4753
public dsoNameService: DSONameService,
4854
public translateService: TranslateService,
@@ -51,6 +57,8 @@ export class CollectionSearchResultGridElementComponent extends SearchResultGrid
5157
protected bitstreamDataService: BitstreamDataService,
5258
) {
5359
super(dsoNameService, truncatableService, bitstreamDataService);
60+
61+
this.currentLanguage = translateService.currentLang;
5462
}
5563

5664
// @ts-ignore

src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="card-body">
1111
<ds-badges *ngIf="showLabel" [object]="dso" [context]="context"></ds-badges>
1212
<h4 class="card-title">{{ dsoNameService.getName(dso) }}</h4>
13-
<p *ngIf="dso.shortDescription(translateService.currentLang) as shortDescription" class="card-text">{{shortDescription}}</p>
13+
<p *ngIf="dso.shortDescription(currentLanguage) as shortDescription" class="card-text">{{shortDescription}}</p>
1414
<div *ngIf="linkType !== linkTypes.None" class="text-center">
1515
<a [target]="(linkType === linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType === linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="['/communities/', dso.id]" class="lead btn btn-primary viewButton">{{ 'search.results.view-result' | translate}}</a>
1616
</div>

src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
TranslateService,
1313
} from '@ngx-translate/core';
1414

15+
import { environment } from '../../../../../environments/environment';
1516
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
1617
import { LinkService } from '../../../../core/cache/builders/link.service';
1718
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
@@ -44,6 +45,12 @@ import { SearchResultGridElementComponent } from '../search-result-grid-element.
4445
*/
4546
@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement)
4647
export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent<CommunitySearchResult,Community> {
48+
49+
/**
50+
* The current language of the page
51+
*/
52+
currentLanguage: string = environment.defaultLanguage;
53+
4754
private _dso: Community;
4855

4956
constructor(
@@ -54,6 +61,8 @@ export class CommunitySearchResultGridElementComponent extends SearchResultGridE
5461
protected bitstreamDataService: BitstreamDataService,
5562
) {
5663
super(dsoNameService, truncatableService, bitstreamDataService);
64+
65+
this.currentLanguage = translateService.currentLang;
5766
}
5867

5968
// @ts-ignore

0 commit comments

Comments
 (0)