Skip to content

Commit 3355fb8

Browse files
authored
Merge pull request #310 from netgrif/NAE-2251
[NAE-2251] NAE - Map field options are not translated
2 parents 07ffba7 + 42b46b6 commit 3355fb8

File tree

8 files changed

+44
-18
lines changed

8 files changed

+44
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netgrif/components-project",
3-
"version": "7.0.0-rc.14",
3+
"version": "7.0.0-rc.15",
44
"description": "Netgrif Application Engine Frontend project. Project includes angular libraries as base for NAE applications.",
55
"homepage": "https://components.netgrif.com",
66
"license": "SEE LICENSE IN LICENSE",

projects/netgrif-components-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netgrif/components-core",
3-
"version": "7.0.0-rc.14",
3+
"version": "7.0.0-rc.15",
44
"description": "Netgrif Application engine frontend core Angular library",
55
"homepage": "https://components.netgrif.com",
66
"license": "SEE LICENSE IN LICENSE",

projects/netgrif-components-core/src/lib/filter/models/case-search-request-body.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ export interface PetriNetSearchRequest {
8282
/**
8383
* Queried PetriNet identifier
8484
*/
85-
identifier: string;
85+
identifier?: string;
86+
/**
87+
* Queried PetriNet mongo ID
88+
*/
89+
processId?: string;
8690
}
8791

8892
/**

projects/netgrif-components-core/src/lib/panel/abstract/panel-with-immediate-data.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {FeaturedValue} from './featured-value';
77
import {CurrencyPipe} from '@angular/common';
88
import {ImmediateData} from '../../resources/interface/immediate-data';
99
import {OverflowService} from '../../header/services/overflow.service';
10+
import {I18nFieldValue} from "../../data-fields/i18n-field/models/i18n-field-value";
1011

1112
@Component({
1213
selector: 'ncc-abstract-panel-with-immediate',
@@ -35,33 +36,37 @@ export abstract class AbstractPanelWithImmediateDataComponent extends AbstractPa
3536
case 'dateTime':
3637
return {
3738
value: toMoment(immediate.value as NaeDate).format(DATE_TIME_FORMAT_STRING),
38-
icon: 'event', type: immediate.type
39+
icon: 'event',
40+
type: immediate.type
3941
};
4042
case 'enumeration':
41-
return {value: immediate.value.defaultValue, icon: undefined, type: immediate.type};
43+
return {value: this.getTranslation(immediate.value), icon: undefined, type: immediate.type};
4244
case 'multichoice':
4345
return {
44-
value: immediate.value.map(it => it.defaultValue).join(', '),
46+
value: immediate.value.map(it => this.getTranslation(it)).join(', '),
4547
icon: undefined,
4648
type: immediate.type
4749
};
4850
case 'enumeration_map':
4951
return {
50-
value: immediate.options[immediate.value].defaultValue,
52+
value: this.getTranslation(immediate.options[immediate.value]),
5153
icon: undefined,
5254
type: immediate.type
5355
};
5456
case 'multichoice_map':
5557
return {
5658
value: immediate.value.map(it =>
57-
immediate.options[it].defaultValue).join(', '), icon: undefined, type: immediate.type
59+
this.getTranslation(immediate.options[it])).join(', '),
60+
icon: undefined,
61+
type: immediate.type
5862
};
5963
case 'file':
6064
return {value: immediate.value?.name, icon: 'insert_drive_file', type: immediate.type};
6165
case 'fileList':
6266
return {
6367
value: immediate.value?.namesPaths.map(obj => obj.name).join(', '),
64-
icon: 'file_copy', type: immediate.type
68+
icon: 'file_copy',
69+
type: immediate.type
6570
};
6671
case 'userList':
6772
return {value: immediate.value?.userValues.map(obj => obj.fullName).join(', '), icon: 'account_circle', type: immediate.type};
@@ -73,11 +78,18 @@ export abstract class AbstractPanelWithImmediateDataComponent extends AbstractPa
7378
icon: undefined, type: immediate.type
7479
};
7580
case 'button':
81+
let buttonValue: string;
82+
if ((immediate as any).placeholder?.defaultValue !== undefined) {
83+
buttonValue = this.getTranslation((immediate as any).placeholder);
84+
} else if (immediate.name?.defaultValue !== undefined) {
85+
buttonValue = this.getTranslation(immediate.name);
86+
} else {
87+
buttonValue = this._translate.instant('dialog.submit');
88+
}
7689
return {
77-
value: (immediate as any).placeholder && (immediate as any).placeholder.defaultValue !== undefined
78-
? (immediate as any).placeholder.defaultValue : (immediate.name && immediate.name.defaultValue !== undefined
79-
? immediate.name.defaultValue : this._translate.instant('dialog.submit')),
80-
icon: undefined, type: immediate.type
90+
value: buttonValue,
91+
icon: undefined,
92+
type: immediate.type
8193
};
8294
case 'filter':
8395
return {
@@ -101,6 +113,13 @@ export abstract class AbstractPanelWithImmediateDataComponent extends AbstractPa
101113
}
102114
}
103115

116+
protected getTranslation(i18n: I18nFieldValue | undefined): string {
117+
const locale = this._translate.currentLang;
118+
return (i18n && i18n.translations && locale in i18n.translations)
119+
? i18n.translations[locale]
120+
: (i18n?.defaultValue ?? '');
121+
}
122+
104123
protected formatCurrencyPipe(value: any, code: string, fraction: number, locale: string, type: string) {
105124
return {
106125
value:

projects/netgrif-components-core/src/lib/panel/case-panel/abstract-case-panel.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class TestWrapperComponent {
163163
{stringId: 'date', title: 'string', type: 'date', value: [2020, 1, 1, 10, 10]},
164164
{stringId: 'string', title: 'string', type: 'string', value: 'dasdsadsad'},
165165
{stringId: 'dateTime', title: 'string', type: 'dateTime', value: [2020, 1, 1, 10, 10]},
166-
{stringId: 'enum', title: 'string', type: 'enumeration', value: {defaultValue: 'dasd'}},
166+
{stringId: 'enum', title: 'string', type: 'enumeration', value: {defaultValue: 'dasd', translations: {}}},
167167
]
168168
};
169169
}

projects/netgrif-components-core/src/lib/resources/interface/immediate-data.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {FilterMetadata} from '../../search/models/persistance/filter-metadata';
22
import {FormatFilter} from '../../data-fields/models/format-filter';
33
import {Component} from '../../data-fields/models/component';
4+
import {I18nFieldValue} from "../../data-fields/i18n-field/models/i18n-field-value";
45

56
/**
67
* @ignore
@@ -47,5 +48,7 @@ export interface ImmediateData {
4748
/**
4849
* Only for enumeration_map and multichoice_map
4950
*/
50-
options?: { defaultValue?: string };
51+
options?: {
52+
[k: string]: I18nFieldValue
53+
};
5154
}

projects/netgrif-components/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netgrif/components",
3-
"version": "7.0.0-rc.14",
3+
"version": "7.0.0-rc.15",
44
"description": "Netgrif Application Engine frontend Angular components",
55
"homepage": "https://components.netgrif.com",
66
"license": "SEE LICENSE IN LICENSE",
@@ -29,7 +29,7 @@
2929
"nae frontend"
3030
],
3131
"peerDependencies": {
32-
"@netgrif/components-core": "7.0.0-rc.14",
32+
"@netgrif/components-core": "7.0.0-rc.15",
3333
"@angular-material-components/datetime-picker": "~16.0.0",
3434
"@angular-material-components/moment-adapter": "~16.0.0",
3535
"@angular/animations": "~17.1.0",

projects/netgrif-components/src/lib/panel/case-panel/case-panel.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class TestWrapperComponent {
104104
{stringId: 'date', title: 'string', type: 'date', value: [2020, 1, 1, 10, 10]},
105105
{stringId: 'string', title: 'string', type: 'string', value: 'dasdsadsad'},
106106
{stringId: 'dateTime', title: 'string', type: 'dateTime', value: [2020, 1, 1, 10, 10]},
107-
{stringId: 'enum', title: 'string', type: 'enumeration', value: {defaultValue: 'dasd'}},
107+
{stringId: 'enum', title: 'string', type: 'enumeration', value: {defaultValue: 'dasd', translations: {}}},
108108
]
109109
};
110110
}

0 commit comments

Comments
 (0)