Skip to content

Commit e526b0e

Browse files
authored
Merge pull request #301 from netgrif/NAE-2224
[NAE-2224] Title in optional text in case creation button as I18nString
2 parents 723332d + a73464a commit e526b0e

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
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.11",
3+
"version": "7.0.0-rc.12",
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/nae-example-app/src/app/doc/case-view/case-view.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export class CaseViewComponent extends AbstractCaseViewComponent implements Afte
5959
enableCaseTitle: true,
6060
isCaseTitleRequired: false,
6161
newCaseButtonConfig: {
62-
createCaseButtonTitle: 'test',
62+
createCaseButtonTitle: {
63+
defaultValue: 'test'
64+
},
6365
createCaseButtonIcon: 'home'
6466
}
6567
});

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.11",
3+
"version": "7.0.0-rc.12",
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/side-menu/content-components/new-case/model/new-case-injection-data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {SideMenuInjectionData} from '../../../models/side-menu-injection-data';
22
import {Observable} from 'rxjs';
33
import {PetriNetReference} from '../../../../resources/interface/petri-net-reference';
44
import {InjectionToken} from '@angular/core';
5+
import {I18nFieldValue} from "../../../../data-fields/i18n-field/models/i18n-field-value";
56

67
export interface NewCaseInjectionData extends SideMenuInjectionData {
78
allowedNets$: Observable<Array<PetriNetReference>>;
@@ -26,7 +27,7 @@ export interface NewCaseCreationConfigurationData {
2627

2728
export interface NewCaseButtonConfiguration {
2829

29-
createCaseButtonTitle?: string;
30+
createCaseButtonTitle?: I18nFieldValue;
3031

3132
createCaseButtonIcon?: string;
3233

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.11",
3+
"version": "7.0.0-rc.12",
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.11",
32+
"@netgrif/components-core": "7.0.0-rc.12",
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/navigation/group-navigation-component-resolver/default-components/tabbed/default-tab-view/default-tab-view.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
ViewIdService,
1515
FilterExtractionService,
1616
GroupNavigationConstants,
17-
hasView
17+
hasView,
18+
I18nFieldValue
1819
} from '@netgrif/components-core';
1920
import {DefaultTabbedCaseViewComponent} from '../default-tabbed-case-view/default-tabbed-case-view.component';
2021
import {DefaultTabbedTaskViewComponent} from '../default-tabbed-task-view/default-tabbed-task-view.component';
@@ -67,7 +68,7 @@ export class DefaultTabViewComponent {
6768

6869
const blockNetsString = extractFieldValueFromData<string>(viewDataGroups, GroupNavigationConstants.ITEM_FIELD_ID_CASE_BANNED_PROCESS_CREATION);
6970
const blockNets = blockNetsString === undefined ? [] : blockNetsString.split(',')
70-
const createCaseButtonTitle: string = extractFieldValueFromData<string>(viewDataGroups, GroupNavigationConstants.ITEM_FIELD_ID_CREATE_CASE_BUTTON_TITLE);
71+
const createCaseButtonTitle: I18nFieldValue = extractFieldValueFromData<I18nFieldValue>(viewDataGroups, GroupNavigationConstants.ITEM_FIELD_ID_CREATE_CASE_BUTTON_TITLE);
7172
const createCaseButtonIcon: string = extractFieldValueFromData<string>(viewDataGroups, GroupNavigationConstants.ITEM_FIELD_ID_CREATE_CASE_BUTTON_ICON);
7273
const requireTitle: boolean = extractFieldValueFromData<boolean>(viewDataGroups, GroupNavigationConstants.ITEM_FIELD_ID_CASE_TITLE_IN_CREATION);
7374
const showCreateCaseButton: boolean = extractFieldValueFromData<boolean>(viewDataGroups, GroupNavigationConstants.ITEM_FIELD_ID_SHOW_CREATE_CASE_BUTTON);

projects/netgrif-components/src/lib/view/case-view/components/create-case-button/create-case-button.component.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
LoadingEmitter
99
} from '@netgrif/components-core';
1010
import {map} from "rxjs/operators";
11+
import {TranslateService} from '@ngx-translate/core';
1112

1213
@Component({
1314
selector: 'nc-create-case-button',
@@ -24,7 +25,8 @@ export class CreateCaseButtonComponent implements OnInit {
2425
protected _resolvedCaseButtonIcon: string;
2526
protected _loading: LoadingEmitter;
2627

27-
constructor(protected _caseViewService: CaseViewService) {
28+
constructor(protected _caseViewService: CaseViewService,
29+
protected _translateService: TranslateService) {
2830
this._loading = new LoadingEmitter();
2931
}
3032

@@ -44,10 +46,20 @@ export class CreateCaseButtonComponent implements OnInit {
4446
const config: NewCaseButtonConfiguration = this.newCaseCreationConfig['newCaseButtonConfig'];
4547
if (!!config) {
4648
this._resolvedCaseButtonIcon = config.createCaseButtonIcon;
47-
this._resolvedCaseButtonTitle = config.createCaseButtonTitle;
49+
this._resolvedCaseButtonTitle = this.resolveTranslation(config);
4850
}
4951
}
5052

53+
public resolveTranslation(config: NewCaseButtonConfiguration): string {
54+
const locale = this._translateService.currentLang;
55+
if(!config.createCaseButtonTitle.defaultValue && !config.createCaseButtonTitle.translations) {
56+
return "";
57+
}
58+
return locale in config.createCaseButtonTitle.translations
59+
? config.createCaseButtonTitle.translations[locale]
60+
: config.createCaseButtonTitle.defaultValue;
61+
}
62+
5163
public shouldShowCreateButton(): Observable<boolean> {
5264
const blockNets = this.newCaseCreationConfig?.blockNets || [];
5365
return this._caseViewService.getNewCaseAllowedNets(blockNets).pipe(
@@ -67,7 +79,8 @@ export class CreateCaseButtonComponent implements OnInit {
6779
if (this._caseViewService.viewEnabled(kaze)) {
6880
this.caseCreatedEvent.next(kaze);
6981
}
70-
}, error => {},() => this._loading.off());
82+
}, error => {
83+
}, () => this._loading.off());
7184

7285
return myCase;
7386
}

0 commit comments

Comments
 (0)