Skip to content

Commit f7ed191

Browse files
authored
Merge pull request #3338 from ProgrammeVitam/bug_15299
Bug #15299 - [Search + Collect] "ORPHANS_NODE" is displayed when selecting the "No attachment" checkbox.
2 parents 9218c7c + 3504f2a commit f7ed191

File tree

5 files changed

+83
-46
lines changed

5 files changed

+83
-46
lines changed

ui/ui-frontend/projects/archive-search/src/app/archive/criteria-search/criteria-search.component.html

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,7 @@
221221
<ng-container *ngFor="let criteriaValue of criteriaVal.values; let isFirst = first; let isLast = last">
222222
<div
223223
class="button-content right-button"
224-
[vitamuiTooltip]="
225-
(criteriaValue.keyTranslated
226-
? ('ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.' + getCategoryName(criteriaVal.category) + '.' + criteriaVal.key
227-
| translateWithOptionalTypeSuffix)
228-
: criteriaVal.key) +
229-
' : ' +
230-
getCriteriaLabel(criteriaVal.key, criteriaValue)
231-
"
224+
[vitamuiTooltip]="getCriteriaKeyLabel(criteriaValue) + ' : ' + getCriteriaLabel(criteriaVal.key, criteriaValue)"
232225
[vitamuiTooltipShowDelay]="300"
233226
[ngClass]="[
234227
isFirst ? 'left-arround' : 'left-not-arround',
@@ -237,20 +230,10 @@
237230
>
238231
<ng-container *ngIf="isFirst">
239232
<i *ngIf="criteriaKey === 'NODE'" class="vitamui-icon vitamui-icon-radio-checked vitamui-row-icon"></i>
240-
{{
241-
(criteriaValue.keyTranslated
242-
? ('ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.' + getCategoryName(criteriaVal.category) + '.' + criteriaVal.key
243-
| translateWithOptionalTypeSuffix)
244-
: criteriaVal.key) + ' : '
245-
}}
233+
{{ getCriteriaKeyLabel(criteriaValue) + ' : ' }}
246234
</ng-container>
247235

248-
{{
249-
criteriaValue.valueTranslated
250-
? ('ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.' + getCategoryName(criteriaVal.category) + '.' + criteriaValue.label
251-
| translate)
252-
: (getCriteriaLabel(criteriaVal.key, criteriaValue) | truncate: 50)
253-
}}
236+
{{ getCriteriaLabel(criteriaVal.key, criteriaValue) | truncate: 50 }}
254237
</div>
255238
<div
256239
class="vitamui-remove-search-criteria"

ui/ui-frontend/projects/archive-search/src/app/archive/criteria-search/criteria-search.component.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
4141
import { RouterTestingModule } from '@angular/router/testing';
4242
import { TranslateModule } from '@ngx-translate/core';
4343
import { environment } from 'projects/archive-search/src/environments/environment';
44-
import { BASE_URL, InjectorModule, LoggerModule, SearchCriteriaTypeEnum, WINDOW_LOCATION } from 'vitamui-library';
44+
import {
45+
BASE_URL,
46+
InjectorModule,
47+
LoggerModule,
48+
SearchCriteriaTypeEnum,
49+
TranslateWithOptionalTypeSuffixPipe,
50+
WINDOW_LOCATION,
51+
} from 'vitamui-library';
4552
import { VitamUICommonTestModule } from 'vitamui-library/testing';
4653
import { CriteriaSearchComponent } from './criteria-search.component';
4754
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
@@ -64,6 +71,7 @@ describe('CriteriaSearchComponent', () => {
6471
TranslateModule.forRoot(),
6572
],
6673
providers: [
74+
TranslateWithOptionalTypeSuffixPipe,
6775
{ provide: WINDOW_LOCATION, useValue: window.location },
6876
{ provide: BASE_URL, useValue: '/fake-api' },
6977
{ provide: environment, useValue: environment },

ui/ui-frontend/projects/archive-search/src/app/archive/criteria-search/criteria-search.component.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,28 @@
3535
* knowledge of the CeCILL-C license and that you accept its terms.
3636
*/
3737
import { Component, EventEmitter, Input, Output } from '@angular/core';
38-
import { CriteriaSearchCriteria, CriteriaValue, QueryParamsService, SearchCriteriaTypeEnum, SearchCriteriaValue } from 'vitamui-library';
38+
import {
39+
CriteriaSearchCriteria,
40+
CriteriaValue,
41+
QueryParamsService,
42+
SearchCriteriaTypeEnum,
43+
SearchCriteriaValue,
44+
TranslateWithOptionalTypeSuffixPipe,
45+
} from 'vitamui-library';
46+
import { TranslateService } from '@ngx-translate/core';
3947
@Component({
4048
selector: 'app-criteria-search',
4149
templateUrl: './criteria-search.component.html',
4250
styleUrls: ['./criteria-search.component.scss'],
4351
standalone: false,
52+
providers: [TranslateWithOptionalTypeSuffixPipe],
4453
})
4554
export class CriteriaSearchComponent {
46-
constructor(private queryParamsService: QueryParamsService) {}
55+
constructor(
56+
private queryParamsService: QueryParamsService,
57+
private translateService: TranslateService,
58+
private translateWithOptionalTypeSuffixPipe: TranslateWithOptionalTypeSuffixPipe,
59+
) {}
4760

4861
@Input()
4962
criteriaKey: string;
@@ -79,13 +92,31 @@ export class CriteriaSearchComponent {
7992
this.removeCriteriaList(this.criteriaVal.values.map((value) => value.value));
8093
}
8194

95+
getCriteriaKeyLabel(criteriaValue: SearchCriteriaValue): string {
96+
if (criteriaValue.keyTranslated) {
97+
const translationKey = `ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.${this.getCategoryName(this.criteriaVal.category)}.${this.criteriaVal.key}`;
98+
return this.translateWithOptionalTypeSuffixPipe.transform(translationKey);
99+
}
100+
return this.criteriaVal.key;
101+
}
102+
82103
getCriteriaLabel(key: string, criteriaValue: SearchCriteriaValue): string {
104+
if (criteriaValue.valueTranslated) {
105+
return this.translateService.instant(
106+
`ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.${this.getCategoryName(this.criteriaVal.category)}.${criteriaValue.label}`,
107+
);
108+
}
83109
if (key === 'ALL_ARCHIVE_UNIT_TYPES') {
84-
return criteriaValue.label;
110+
return criteriaValue.keyTranslated
111+
? this.translateService.instant(`ARCHIVE_SEARCH.SEARCH_CRITERIA_FILTER.FIELDS.${criteriaValue.label}`)
112+
: criteriaValue.label;
85113
}
86114
if (key === 'VIRTUAL') {
87115
return criteriaValue.value.value + ' (' + criteriaValue.value.virtualNodeRealParentTitle + ')';
88116
}
117+
if (key === 'ORPHANS_NODE') {
118+
return this.translateService.instant('ARCHIVE_SEARCH.FILING_SCHEMA.ORPHANS_NODE');
119+
}
89120
return criteriaValue.value?.value ?? '';
90121
}
91122
}

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-criteria/components/criteria-search/criteria-search.component.html

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,7 @@
221221
<ng-container *ngFor="let criteriaValue of criteriaVal.values; let index = index; let isFirst = first; let isLast = last">
222222
<div
223223
class="button-content right-button"
224-
[vitamuiTooltip]="
225-
(criteriaValue.keyTranslated
226-
? ('COLLECT.SEARCH_CRITERIA_FILTER.' + getCategoryName(criteriaVal.category) + '.' + criteriaVal.key
227-
| translateWithOptionalTypeSuffix)
228-
: criteriaVal.key) +
229-
' : ' +
230-
getCriteriaLabel(criteriaVal.key, criteriaValue)
231-
"
224+
[vitamuiTooltip]="getCriteriaKeyLabel(criteriaValue) + ' : ' + getCriteriaLabel(criteriaVal.key, criteriaValue)"
232225
[vitamuiTooltipShowDelay]="300"
233226
[ngClass]="[
234227
isFirst ? 'left-arround' : 'left-not-arround',
@@ -237,19 +230,10 @@
237230
>
238231
<ng-container *ngIf="isFirst">
239232
<i *ngIf="criteriaKey === 'NODE'" class="vitamui-icon vitamui-icon-radio-checked vitamui-row-icon"></i>
240-
{{
241-
(criteriaValue.keyTranslated
242-
? ('COLLECT.SEARCH_CRITERIA_FILTER.' + getCategoryName(criteriaVal.category) + '.' + criteriaVal.key
243-
| translateWithOptionalTypeSuffix)
244-
: criteriaVal.key) + ' : '
245-
}}
233+
{{ getCriteriaKeyLabel(criteriaValue) + ' : ' }}
246234
</ng-container>
247235

248-
{{
249-
criteriaValue.valueTranslated
250-
? ('COLLECT.SEARCH_CRITERIA_FILTER.' + getCategoryName(criteriaVal.category) + '.' + criteriaValue.label | translate)
251-
: (getCriteriaLabel(criteriaVal.key, criteriaValue) | truncate: 50)
252-
}}
236+
{{ getCriteriaLabel(criteriaVal.key, criteriaValue) | truncate: 50 }}
253237
</div>
254238
<div
255239
class="vitamui-remove-search-criteria"

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-criteria/components/criteria-search/criteria-search.component.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,29 @@
3636
*/
3737

3838
import { Component, EventEmitter, Input, Output } from '@angular/core';
39-
import { CriteriaSearchCriteria, CriteriaValue, QueryParamsService, SearchCriteriaTypeEnum, SearchCriteriaValue } from 'vitamui-library';
39+
import { TranslateService } from '@ngx-translate/core';
40+
import {
41+
CriteriaSearchCriteria,
42+
CriteriaValue,
43+
QueryParamsService,
44+
SearchCriteriaTypeEnum,
45+
SearchCriteriaValue,
46+
TranslateWithOptionalTypeSuffixPipe,
47+
} from 'vitamui-library';
4048

4149
@Component({
4250
selector: 'app-criteria-search',
4351
templateUrl: './criteria-search.component.html',
4452
styleUrls: ['./criteria-search.component.scss'],
4553
standalone: false,
54+
providers: [TranslateWithOptionalTypeSuffixPipe],
4655
})
4756
export class CriteriaSearchComponent {
48-
constructor(private queryParamsService: QueryParamsService) {}
57+
constructor(
58+
private queryParamsService: QueryParamsService,
59+
private translateService: TranslateService,
60+
private translateWithOptionalTypeSuffixPipe: TranslateWithOptionalTypeSuffixPipe,
61+
) {}
4962

5063
@Input()
5164
criteriaKey: string;
@@ -80,13 +93,31 @@ export class CriteriaSearchComponent {
8093
this.removeCriteriaList(this.criteriaVal.values.map((value) => value.value));
8194
}
8295

96+
getCriteriaKeyLabel(criteriaValue: SearchCriteriaValue): string {
97+
if (criteriaValue.keyTranslated) {
98+
const translationKey = `COLLECT.SEARCH_CRITERIA_FILTER.${this.getCategoryName(this.criteriaVal.category)}.${this.criteriaVal.key}`;
99+
return this.translateWithOptionalTypeSuffixPipe.transform(translationKey);
100+
}
101+
return this.criteriaVal.key;
102+
}
103+
83104
getCriteriaLabel(key: string, criteriaValue: SearchCriteriaValue): string {
105+
if (criteriaValue.valueTranslated) {
106+
return this.translateService.instant(
107+
`COLLECT.SEARCH_CRITERIA_FILTER.${this.getCategoryName(this.criteriaVal.category)}.${criteriaValue.label}`,
108+
);
109+
}
84110
if (key === 'ALL_ARCHIVE_UNIT_TYPES') {
85-
return criteriaValue.label;
111+
return criteriaValue.keyTranslated
112+
? this.translateService.instant(`COLLECT.SEARCH_CRITERIA_FILTER.FIELDS.${criteriaValue.label}`)
113+
: criteriaValue.label;
86114
}
87115
if (key === 'VIRTUAL') {
88116
return criteriaValue.value.value + ' (' + criteriaValue.value.virtualNodeRealParentTitle + ')';
89117
}
118+
if (key === 'ORPHANS_NODE') {
119+
return this.translateService.instant('COLLECT.FILING_SCHEMA.ORPHANS_NODE');
120+
}
90121
return criteriaValue.value?.value ?? '';
91122
}
92123
}

0 commit comments

Comments
 (0)