.. index:: menu, menu defaultItem **** Menu **** Menu element ============ The menu of the Scolvo client is described by the *menu* keyword, what is mandatory for each client device type script: each one must have exactly one *menu* defined. It is mandatory to define the default menu item globally using the *defaultItem* keyword. Syntax of the *menu* element ---------------------------- .. menu defaultItem {} where: - The consists of *items*, *group* definitions and *default items* definition. - The usage of the *defaultItem* keyword is mandatory, the given must be one of the defined menu *items* or *groups*. - Every menu item or group can have *roles* definition what is used to filer menu items and groups according to the roles of the actual user. - When a client session is started, then the default or the first available menu item is selected by the system, and the corresponding menu event is executed. .. index:: menu events Events of the *menu* -------------------- When a menu item is selected, then the function with name *on(originId)* is executed. .. code-block:: scolvoscript :caption: Example menu and menu event definition for menu item Item1 :linenos: menu defaultItem Item1 { item Item1 } function onItem1(originId) { // some logic } .. index:: menu dictionary keys Dictionary keys of the *menu* ----------------------------- Every client application instance uses a dictionary to resolve values when building UIs. The UI values of the menu are also defined in the dictionary. The corresponding keys have the form of 'menu__label' (the pattern is similar for menu items in group: menu___label). .. code-block:: properties :caption: Dictionary key definitions for menu example in the mobile_dictionary_en.properties file :linenos: menu_Item1_label=This is the UI value of the Item1 menu Items of the *menu* =================== A menu definition contains a list of menu items. These can be simple menu items, item groups, and default item definition section for user roles. Syntax of the ------------------------- .. ((||)[,])+ where: - At least one of the possible types must be defined. - If more than one item is defined, then the definitions can be seprarated by ',' .. index:: menu item Menu *item* =========== The *item* definition represents a selectable menu item. It has name, and it can be defined for which roles it is available. If the active user does not have the one of the defined roles, then the menu item is not visible. Syntax of the ------------------------- .. item [{}] where: - The is the name of the menu item in form of string. - The is optional. Syntax of the -------------------------------- .. roles: where: - The is a list of names with double quotes in form of list of strings (["role-name1", "role-name2"]. .. index:: menu group Menu *group* ============ A menu *group* can be used to form groups of menu items and other menu groups. .. Note:: Only first level group is supported by the Scolvo clients, a group cannot contain another group. Syntax of the -------------------------- .. group defaultItem {} where: - The *defaultItem* is mandatory, the must be one of the defined menu items. - The consists of role definition and item definitions. Syntax of the ------------------------------- .. ((|)[,])+ where: - At least one of must be defined. - If more than one defined, then the definitions are optionally seprarated by ','. - The syntax is described above in *item* definition. .. index:: menu defaultItems The *defaultItems* of a menu ============================ Sometimes the globally defined *defaultItem* is not enough to define default menu items for different user roles. For this scenario the *defaultItems* keyword can be used where different user roles and corresponding default menu items can be defined. Syntax of the ----------------------------- .. defaultItems: {} where: - The is mandatory. Syntax of the --------------------------------- .. (: [,])+ where: - The is given in form of quoted string. - The is given in form of string with-or-without double quotes. Complex menu example ==================== In this setion a complex *menu* definition is given, where all above described details are used. .. code-block:: scolvoscript :caption: Menu definition with all possible elements :linenos: menu defaultItem Item1 { item Item1 { roles: "role1" }, item Item2 { roles: ["role2"] }, item Item3 { roles: ["role1", "role2"], }, item Item4 { roles: ["role1"] }, group Group1 defaultItem GroupItem1 { roles: ["role1", "role2"], item GroupItem1 { roles: ["role1"], }, item GroupItem2 { roles: ["role2"], } }, defaultItems: { "role1": Item1, "role2": Item2 } } .. code-block:: properties :caption: Dictionary keys in e.g. mobile_dictionary_en.properties file :linenos: menu_Item1_label=Item1 menu_Item2_label=Item2 menu_Item3_label=Item3 menu_Item4_label=Item4 menu_Group1_label=Group1 menu_Group1_GroupItem1_label=GroupItem1 menu_Group1_GroupItem2_label=GroupItem2 ..