From 42a6b73e7f8a5f2e9a5eda21905cb5d33d402e63 Mon Sep 17 00:00:00 2001 From: christophercr Date: Mon, 8 Oct 2018 10:58:38 +0200 Subject: [PATCH] feat(stark-ui): integrate translation support in AppMenu component ISSUES CLOSED: #755 --- .../components/app-menu-config.intf.ts | 8 +++++ .../components/app-menu-entry.intf.ts | 28 ++++++++++++++++ .../components/app-menu-group.intf.ts | 3 ++ .../components/app-menu-item.component.html | 18 +++++++--- .../components/app-menu-item.component.ts | 2 +- .../components/app-menu-section.intf.ts | 9 +++++ .../components/app-menu.component.html | 6 ++-- .../components/app-menu.component.spec.ts | 4 +-- .../app-menu/components/app-menu.component.ts | 33 ++++++++++++------- .../components/app-sidebar.component.spec.ts | 4 +-- .../components/breadcrumb.component.spec.ts | 3 +- .../date-range-picker.component.spec.ts | 2 +- .../components/date-range-picker.component.ts | 2 +- showcase/src/app/app.component.html | 2 +- .../app/demo/menu/demo-menu.component.html | 4 +-- .../src/assets/examples/menu/sections.html | 2 +- showcase/src/assets/examples/menu/simple.html | 2 +- starter/src/app/app.component.html | 2 +- 18 files changed, 101 insertions(+), 33 deletions(-) diff --git a/packages/stark-ui/src/modules/app-menu/components/app-menu-config.intf.ts b/packages/stark-ui/src/modules/app-menu/components/app-menu-config.intf.ts index c83169ef6f..251cd2c860 100644 --- a/packages/stark-ui/src/modules/app-menu/components/app-menu-config.intf.ts +++ b/packages/stark-ui/src/modules/app-menu/components/app-menu-config.intf.ts @@ -1,9 +1,17 @@ import { StarkMenuGroup } from "./app-menu-group.intf"; import { StarkMenuSection } from "./app-menu-section.intf"; + /** * StarkMenuConfig interface */ export interface StarkMenuConfig { + /** + * Array of menu groups to include in the menu. + */ menuGroups?: StarkMenuGroup[]; + + /** + * Array of menu sections to include in the menu. The menu sections provide a way to group a set of menu groups. + */ menuSections?: StarkMenuSection[]; } diff --git a/packages/stark-ui/src/modules/app-menu/components/app-menu-entry.intf.ts b/packages/stark-ui/src/modules/app-menu/components/app-menu-entry.intf.ts index 3cc8964382..c684c98b0f 100644 --- a/packages/stark-ui/src/modules/app-menu/components/app-menu-entry.intf.ts +++ b/packages/stark-ui/src/modules/app-menu/components/app-menu-entry.intf.ts @@ -2,11 +2,39 @@ * StarkMenuEntry interface */ export interface StarkMenuEntry { + /** + * Id of the container of the menu group/entry + */ id: string; + + /** + * Icon to display next to the menu group/entry label. + */ icon?: string; + + /** + * Text to be displayed as the label in the header of the menu group/entry + * (dynamically translated via the Translate service if the provided text is defined in the translation keys). + */ label: string; + + /** + * Whether the menu group/entry should be visible or not. + */ isVisible: boolean; + + /** + * Whether the menu group/entry should be enabled for user interaction or not. + */ isEnabled: boolean; + + /** + * Name of the Router state that will be navigated to when the header of the menu group/entry is clicked. + */ targetState?: string; + + /** + * Params object to be passed to the Router state defined as targetState. + */ targetStateParams?: { [param: string]: any }; } diff --git a/packages/stark-ui/src/modules/app-menu/components/app-menu-group.intf.ts b/packages/stark-ui/src/modules/app-menu/components/app-menu-group.intf.ts index a00dd84ede..081ffae489 100644 --- a/packages/stark-ui/src/modules/app-menu/components/app-menu-group.intf.ts +++ b/packages/stark-ui/src/modules/app-menu/components/app-menu-group.intf.ts @@ -4,5 +4,8 @@ import { StarkMenuEntry } from "./app-menu-entry.intf"; * StarkMenuGroup interface */ export interface StarkMenuGroup extends StarkMenuEntry { + /** + * Array of entries described by StarkMenuGroup objects + */ entries?: StarkMenuGroup[]; } diff --git a/packages/stark-ui/src/modules/app-menu/components/app-menu-item.component.html b/packages/stark-ui/src/modules/app-menu/components/app-menu-item.component.html index 169a8c35fe..47d6d4436e 100644 --- a/packages/stark-ui/src/modules/app-menu/components/app-menu-item.component.html +++ b/packages/stark-ui/src/modules/app-menu/components/app-menu-item.component.html @@ -1,9 +1,19 @@ - - - {{ menuGroup.label }} + + + {{ menuGroup.label }} - + diff --git a/packages/stark-ui/src/modules/app-menu/components/app-menu-item.component.ts b/packages/stark-ui/src/modules/app-menu/components/app-menu-item.component.ts index b268127fd6..eab8681994 100644 --- a/packages/stark-ui/src/modules/app-menu/components/app-menu-item.component.ts +++ b/packages/stark-ui/src/modules/app-menu/components/app-menu-item.component.ts @@ -20,7 +20,7 @@ import { StarkRoutingService, StarkRoutingTransitionHook } from "@nationalbankbelgium/stark-core"; -import { AbstractStarkUiComponent } from "./../../../common/classes/abstract-component"; +import { AbstractStarkUiComponent } from "../../../common/classes/abstract-component"; import { StarkMenuGroup } from "./app-menu-group.intf"; /** diff --git a/packages/stark-ui/src/modules/app-menu/components/app-menu-section.intf.ts b/packages/stark-ui/src/modules/app-menu/components/app-menu-section.intf.ts index 1f4490bb50..ef3b20ce8a 100644 --- a/packages/stark-ui/src/modules/app-menu/components/app-menu-section.intf.ts +++ b/packages/stark-ui/src/modules/app-menu/components/app-menu-section.intf.ts @@ -1,8 +1,17 @@ import { StarkMenuGroup } from "./app-menu-group.intf"; + /** * StarkMenuSection interface */ export interface StarkMenuSection { + /** + * Text to be displayed as the label in the header of the menu section + * (dynamically translated via the Translate service if the provided text is defined in the translation keys). + */ label: string; + + /** + * Array of menu groups to include in this section. + */ menuGroups: StarkMenuGroup[]; } diff --git a/packages/stark-ui/src/modules/app-menu/components/app-menu.component.html b/packages/stark-ui/src/modules/app-menu/components/app-menu.component.html index 1f5eef9507..9123b6fd93 100644 --- a/packages/stark-ui/src/modules/app-menu/components/app-menu.component.html +++ b/packages/stark-ui/src/modules/app-menu/components/app-menu.component.html @@ -1,14 +1,14 @@