Skip to content

Commit 6af3589

Browse files
committed
Merge branch 'dspace-cris-7' into ux-plus
2 parents 4ba1891 + 274706e commit 6af3589

6 files changed

Lines changed: 52 additions & 15 deletions

File tree

src/app/shared/form/vocabulary-treeview/vocabulary-treeview.component.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
<div class="input-group">
55
<input type="text" class="form-control" [(ngModel)]="searchText" (keyup.enter)="search()">
66
<div class="input-group-append" id="button-addon4">
7-
<button class="btn btn-outline-primary" type="button" (click)="search()" [disabled]="!isSearchEnabled()">
7+
<button class="btn btn-primary" type="button" (click)="search()" [disabled]="!isSearchEnabled()">
88
<span><i class="fas fa-search"></i> {{'vocabulary-treeview.search.form.search' | translate}}</span>
99
</button>
10-
<button class="btn btn-outline-secondary ml-3 flex-shrink-0" type="button" (click)="reset()">
11-
<span><i class="fas fa-eraser"></i> {{'vocabulary-treeview.search.form.reset' | translate}}</span>
12-
</button>
13-
<button *ngIf="showAdd && this.vocabularyOptions.closed" class="btn btn-outline-primary" type="button" (click)="add()">
14-
{{'vocabulary-treeview.search.form.add' | translate}}
15-
</button>
1610
</div>
1711
</div>
12+
<button class="btn btn-secondary ml-3 flex-shrink-0" type="button" (click)="reset()">
13+
<span><i class="fas fa-eraser"></i> {{'vocabulary-treeview.search.form.reset' | translate}}</span>
14+
</button>
15+
<button *ngIf="showAdd " class="btn btn-secondary ml-3 flex-shrink-0" type="button" (click)="add()">
16+
<span><i class="fas fa-plus"></i> {{'vocabulary-treeview.search.form.add' | translate}}</span>
17+
</button>
1818
</div>
1919
</div>
2020
<div class="treeview-container">

src/app/shared/form/vocabulary-treeview/vocabulary-treeview.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
343343
* Return an id for a given {@link VocabularyTreeItemType}
344344
*/
345345
private getEntryId(entry: VocabularyTreeItemType): string {
346-
return entry?.authority || entry?.otherInformation?.id || (entry as any)?.id || undefined;
346+
const entryId: string = entry?.authority || entry?.otherInformation?.id || (entry as any)?.id || undefined;
347+
return entryId?.startsWith(this.vocabularyOptions.name) ? entryId.replace(`${this.vocabularyOptions.name}:`, '') : entryId;
347348
}
348349

349350
/**

src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
[routerLink]="[searchLink]"
44
[queryParams]="addQueryParams" queryParamsHandling="merge">
55
<label class="mb-0 d-flex w-100">
6-
<input type="checkbox" [checked]="false" class="my-1 align-self-stretch filter-checkbox"/>
6+
<input type="checkbox" [checked]="false" class="my-1 align-self-stretch"/>
77
<span class="w-100 pl-1 break-facet">
8-
<span class="float-right badge badge-secondary badge-pill mt-1 ml-1">{{filterValue.count | dsShortNumber}}</span>
9-
{{ 'search.filters.' + filterConfig.name + '.' + filterValue.value | translate: {default: filterValue.value} }}
8+
{{ labelTranslation | dsCapitalize}}
9+
({{filterValue.count}})
1010
</span>
1111
</label>
1212

src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
33
import { FormsModule } from '@angular/forms';
44
import { By } from '@angular/platform-browser';
55
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
6-
import { Router } from '@angular/router';
6+
import { ActivatedRoute, Router } from '@angular/router';
77
import { TranslateModule } from '@ngx-translate/core';
88
import { of as observableOf } from 'rxjs';
99
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
@@ -19,6 +19,8 @@ import { PaginationComponentOptions } from '../../../../../pagination/pagination
1919
import { PaginationService } from '../../../../../../core/pagination/pagination.service';
2020
import { PaginationServiceStub } from '../../../../../testing/pagination-service.stub';
2121
import { ShortNumberPipe } from '../../../../../utils/short-number.pipe';
22+
import { MockActivatedRoute } from '../../../../../mocks/active-router.mock';
23+
import { CapitalizePipe } from '../../../../../utils/capitalize.pipe';
2224

2325
describe('SearchFacetOptionComponent', () => {
2426
let comp: SearchFacetOptionComponent;
@@ -90,9 +92,10 @@ describe('SearchFacetOptionComponent', () => {
9092
beforeEach(waitForAsync(() => {
9193
TestBed.configureTestingModule({
9294
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule],
93-
declarations: [SearchFacetOptionComponent, ShortNumberPipe],
95+
declarations: [SearchFacetOptionComponent, ShortNumberPipe, CapitalizePipe],
9496
providers: [
9597
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) },
98+
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
9699
{ provide: Router, useValue: new RouterStub() },
97100
{ provide: PaginationService, useValue: paginationService },
98101
{

src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
22
import { map } from 'rxjs/operators';
33
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
4-
import { Router } from '@angular/router';
4+
import { ActivatedRoute, Router } from '@angular/router';
55
import { FacetValue } from '../../../../models/facet-value.model';
66
import { SearchFilterConfig } from '../../../../models/search-filter-config.model';
77
import { SearchService } from '../../../../../../core/shared/search/search.service';
@@ -11,6 +11,7 @@ import { hasValue } from '../../../../../empty.util';
1111
import { currentPath } from '../../../../../utils/route.utils';
1212
import { getFacetValueForType } from '../../../../search.utils';
1313
import { PaginationService } from '../../../../../../core/pagination/pagination.service';
14+
import { TranslateService } from '@ngx-translate/core';
1415

1516
@Component({
1617
selector: 'ds-search-facet-option',
@@ -63,18 +64,27 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy {
6364

6465
paginationId: string;
6566

67+
configuration: string;
68+
labelTranslation: string;
69+
6670
constructor(protected searchService: SearchService,
6771
protected filterService: SearchFilterService,
6872
protected searchConfigService: SearchConfigurationService,
6973
protected router: Router,
70-
protected paginationService: PaginationService
74+
protected activatedRoute: ActivatedRoute,
75+
protected paginationService: PaginationService,
76+
protected translateService: TranslateService
7177
) {
7278
}
7379

7480
/**
7581
* Initializes all observable instance variables and starts listening to them
7682
*/
7783
ngOnInit(): void {
84+
this.configuration = this.activatedRoute?.snapshot?.queryParams?.configuration;
85+
86+
this.handleTranslation();
87+
7888
this.paginationId = this.searchConfigService.paginationID;
7989
this.searchLink = this.getSearchLink();
8090
this.isVisible = this.isChecked().pipe(map((checked: boolean) => !checked));
@@ -84,6 +94,27 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy {
8494
});
8595
}
8696

97+
/**
98+
* Handles translation of the label
99+
*/
100+
handleTranslation() {
101+
let translation = '';
102+
const labelWithConfiguration = `search.filters.${this.configuration}.${this.filterConfig.name}.${this.filterValue.value}`;
103+
104+
translation = this.translateService.instant(labelWithConfiguration);
105+
if (translation !== labelWithConfiguration) {
106+
this.labelTranslation = translation;
107+
} else {
108+
const labelWithoutConfiguration = `search.filters.${this.filterConfig.name}.${this.filterValue.value}`;
109+
translation = this.translateService.instant(labelWithoutConfiguration);
110+
if (translation !== labelWithoutConfiguration) {
111+
this.labelTranslation = translation;
112+
} else {
113+
this.labelTranslation = this.filterValue.value;
114+
}
115+
}
116+
}
117+
87118
/**
88119
* Checks if a value for this filter is currently active
89120
*/

src/assets/i18n/en.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6801,6 +6801,8 @@
68016801

68026802
"vocabulary-treeview.tree.description.srsc": "Research Subject Categories",
68036803

6804+
"vocabulary-treeview.tree.description.publication-coar-types": "Publication types",
6805+
68046806
"vocabulary-treeview.info": "Select a subject to add as search filter",
68056807

68066808
"uploader.browse": "browse",

0 commit comments

Comments
 (0)