RED-3762: Use dictionary label in file workload

This commit is contained in:
Adina Țeudan 2022-04-06 17:16:25 +03:00
parent 745316dbf1
commit 9d3b417772
4 changed files with 36 additions and 6 deletions

View File

@ -5,9 +5,13 @@ import { Filter, handleCheckedValue, IFilter, INestedFilter, NestedFilter } from
import { annotationTypesTranslations } from '../../../translations/annotation-types-translations';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { IViewedPage } from '@red/domain';
import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service';
import { FilePreviewStateService } from '../../file-preview/services/file-preview-state.service';
@Injectable()
export class AnnotationProcessingService {
constructor(private readonly _state: FilePreviewStateService, private readonly _dictionariesMapService: DictionariesMapService) {}
static secondaryAnnotationFilters(viewedPages?: IViewedPage[]): INestedFilter[] {
const _viewedPages = viewedPages ? viewedPages.map(page => page.page) : [];
return [
@ -70,9 +74,10 @@ export class AnnotationProcessingService {
if (!parentFilter) {
parentFilter = this._createParentFilter(a.superType, filterMap, filters);
}
const dictionary = this._dictionariesMapService.getDictionary(a.type, this._state.dossierTemplateId);
const childFilter: IFilter = {
id: a.filterKey,
label: a.type,
label: dictionary.label,
checked: false,
matches: 1,
};

View File

@ -12,7 +12,7 @@
<strong>
<span>{{ annotation.descriptor | translate }}</span
>: </strong
>{{ annotation.type | humanize: false }}
>{{ (dictionary$ | async).label }}
</div>
<div *ngIf="annotation.shortContent && !annotation.isHint">
<strong><span translate="content"></span>: </strong>{{ annotation.shortContent }}

View File

@ -1,6 +1,12 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { MultiSelectService } from '../../services/multi-select.service';
import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service';
import { DOSSIER_ID } from '@utils/constants';
import { ActivatedRoute } from '@angular/router';
import { DossiersService } from '@services/dossiers/dossiers.service';
import { Dictionary } from '@red/domain';
import { BehaviorSubject } from 'rxjs';
@Component({
selector: 'redaction-annotation-card',
@ -8,9 +14,28 @@ import { MultiSelectService } from '../../services/multi-select.service';
styleUrls: ['./annotation-card.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AnnotationCardComponent {
export class AnnotationCardComponent implements OnChanges {
@Input() annotation: AnnotationWrapper;
@Input() isSelected = false;
readonly dictionary$ = new BehaviorSubject<Dictionary>(undefined);
readonly #dossierTemplateId: string;
constructor(readonly multiSelectService: MultiSelectService) {}
constructor(
readonly multiSelectService: MultiSelectService,
private readonly _route: ActivatedRoute,
private readonly _dictionariesMapService: DictionariesMapService,
private readonly _dossiersService: DossiersService,
) {
const dossierId: string = _route.snapshot.paramMap.get(DOSSIER_ID);
this.#dossierTemplateId = this._dossiersService.find(dossierId).dossierTemplateId;
}
ngOnChanges(changes: SimpleChanges): void {
if (changes.annotation) {
if (this.annotation.type !== 'manual' && !this.annotation.isHighlight) {
const dictionary = this._dictionariesMapService.getDictionary(this.annotation.type, this.#dossierTemplateId);
this.dictionary$.next(dictionary);
}
}
}
}

View File

@ -123,6 +123,6 @@
[dossierTemplateId]="state.dossierTemplateId"
></redaction-dictionary-annotation-icon>
{{ filter.label | humanize: false }}
{{ filter.label }}
</ng-container>
</ng-template>