Skip to content

Commit

Permalink
[ACA-3426] Add translate pipe to search-header tooltip (#5804)
Browse files Browse the repository at this point in the history
* [ACA-3426] Add translate pipe to search-header tooltip

* [ACA-3426] Get tooltip translation from member

* [ACA-3426] Refactor template
  • Loading branch information
BaptisteMahe committed Jun 22, 2020
1 parent 9a156fa commit 1daffc0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/content-services/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@
},
"SEARCH_HEADER" : {
"TITLE":"Filter",
"TYPE": "Type",
"FILTER_BY": "Filter by {{ category }}",
"CLEAR": "Clear",
"APPLY": "Apply"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#menuTrigger="matMenuTrigger"
(click)="onMenuButtonClick($event)"
class="adf-filter-button"
matTooltip="{{ 'SEARCH.SEARCH_HEADER.FILTER_BY' | translate: { category: col.title || 'Type' } }}">
[matTooltip]="getTooltipTranslation(col?.title)">
<adf-icon value="adf:filter"
[ngClass]="{ 'adf-icon-active': isActive || menuTrigger.menuOpen }"
matBadge="filter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { Component, Input, Output, OnInit, OnChanges, EventEmitter, SimpleChanges, ViewEncapsulation, ViewChild, Inject, OnDestroy } from '@angular/core';
import { DataColumn } from '@alfresco/adf-core';
import { DataColumn, TranslationService } from '@alfresco/adf-core';
import { SearchWidgetContainerComponent } from '../search-widget-container/search-widget-container.component';
import { SearchHeaderQueryBuilderService } from '../../search-header-query-builder.service';
import { NodePaging } from '@alfresco/js-api';
Expand Down Expand Up @@ -67,7 +67,8 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {

private onDestroy$ = new Subject<boolean>();

constructor(@Inject(SEARCH_QUERY_SERVICE_TOKEN) private searchHeaderQueryBuilder: SearchHeaderQueryBuilderService) {
constructor(@Inject(SEARCH_QUERY_SERVICE_TOKEN) private searchHeaderQueryBuilder: SearchHeaderQueryBuilderService,
private translationService: TranslationService) {
this.isFilterServiceActive = this.searchHeaderQueryBuilder.isFilterServiceActive();
}

Expand Down Expand Up @@ -141,4 +142,11 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
this.searchHeaderQueryBuilder.execute();
}
}

getTooltipTranslation(columnTitle: string): string {
if (!columnTitle) {
columnTitle = 'SEARCH.SEARCH_HEADER.TYPE';
}
return this.translationService.instant('SEARCH.SEARCH_HEADER.FILTER_BY', {category: this.translationService.instant(columnTitle)});
}
}

0 comments on commit 1daffc0

Please sign in to comment.