How to implement custom icon in SAPUI5's Shellbar Control? - sapui5

I implemented a functionality so that the users of my SAPUI5 application can change between different SAPUI5 themes. Now I would like to place a button in the existing ShellBar of my app to trigger that functionality from there.
Currently I have a fragment with the following code, which I want to make use of within a simple button in the ShellBar. I tried different things like f.ex. calling it via the avaterPressed attribute from the shellbar, but it looks all messed up - I'd be very happy if someone could help me out here - Thanks!
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core">
<Menu itemSelected="onSelectTheme" >
<MenuItem text="Choose Theme">
<items>
<MenuItem key="sap_fiori_3" text="Standard Light" />
<MenuItem key="sap_fiori_3_dark" text="Standard Dark" />
<MenuItem key="sap_hcw" text="High Contrast White" />
<MenuItem key="sap_hcb" text="High Contrast Black" />
</items>
</MenuItem>
</Menu>
</core:FragmentDefinition>
It should look like the "Administrator" button in the following example (Instead of "User Settings" there should be my text "Choose Theme" from the fragment shown above: https://sapui5.hana.ondemand.com/sdk/test-resources/sap/tnt/demokit/toolpageapp/webapp/index.html?sap-ui-theme=sap_horizon#/

If you want to keep using the ShellBar, you can implement the press event on the Avatar and use the ActionSheet for your needs.
https://sapui5.hana.ondemand.com/#/entity/sap.m.ActionSheet/sample/sap.m.sample.ActionSheet

The developers from the linked example don't use the SAPUI5 Control ShellBar, but instead they made use of ToolHeader, which you can also implement within the Control ToolPage.
With ToolHeader, you can simply add a Button wherever you'd like and also call the fragment from f.ex. the profile picture button (shown below).
<tnt:ToolHeader>
<Avatar src="..." press="YOUR_FUNCTION_TO_OPEN_FRAGMENT"/>
</tnt:ToolHeader>

Related

Add aria-hidden to Title element

I am trying to make a business critical SAPUI5 application more accessible using screen readers by adding ARIA labels and landmarks. One issue is that some SAPUI5 elements such as sap.m.Title's without text have been used (abused) for layout purposes. I would like to add the aria-hidden attribute or a SAPUI5 analogue to these Title elements. But I can't figure out how to do this. I would like to change
<Title text="" class="title" />
into
<Title aria-hidden="true" text="" class="title" />
But setting aria-hidden on the Title like this seems to be invalid. How would I go about setting a standard HTML attribute on a SAPUI5 control?
Thank you in advance for your help!
Joshua

How we can click on buttons which is inside in Process Flow control in SAPUI5?

I have added two buttons(Approve, Reject) in Process Flow node. But I am not able to click on that buttons.
Can anyone help on this, How we can click on that buttons?
sap.suite.ui.commons.sample.ProcessFlow
ProcessFlow
Code
<ProcessFlow id="processflow1" scrollable="false" nodePress="onNodePress" foldedCorners="true" nodes="{/nodes}" lanes="{/lanes}">
<nodes>
<ProcessFlowNode id="processflownode1" laneId="{lane}" nodeId="{id}"
title="{title}" titleAbbreviation="{titleAbbreviation}"
children="{children}" state="Neutral" stateText="{stateText}"
texts="{texts}" focused="false" selected="false"
highlighted="false" isTitleClickable="false">
<zoomLevelOneContent>
<m:HBox height="100%" justifyContent="SpaceBetween" renderType="Bare">
<m:Button type="Accept" text="Approve" press="onPress"></m:Button>
<m:Button text="Reject" type="Reject"/>
</m:HBox>
</zoomLevelOneContent>
</ProcessFlowNode>
</nodes>
<lanes>
<ProcessFlowLaneHeader laneId="{id}" iconSrc="{icon}" text="{label}" position="{position}"/>
</lanes>
</ProcessFlow>
Screenshot
This feature is not possible with ProcessFlowNode. You can use nodePress event to open an action sheet or popover for your actions according to your need.
For more information please check:
Process Flow | SAP Fiori Design Guidelines

Error While Creating a Dialog Box Using XML Fragments

I am getting the below error while trying to display a dialog box after user presses a button,
sap-ui-core.js:80 Uncaught Error: failed to load 'sap/m/buttons.js' from resources/sap/m/buttons.js: 404 - Resource could not be found!
Please find the XML code below.
<Dialog xmlns="sap.m"
icon="sap.icon://filter"
title="Filter product details">
<content>
<List id="ls2"
items="{/value}"
mode="MultiSelect">
<StandardListItem title="{CompanyName}"/>
</List>
</content>
<buttons>
<Button text="ok" icon="sap-icon://accept" press="handleok"/>
<Button text="Cancel" icon="sap.icon://cancel"/>
</buttons>
</Dialog>
So the issue was that the UI5 version was quite outdated after all. The aggregation buttons was introduced as of version 1.21.1.
You have to wrap the sap.m.Dialog control inside a FragmentDefinition according to the walkthrough guide.
Here is minimal example https://embed.plnkr.co/OjUCXTg2afohZyDvPp67/
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core">
<Dialog
id="helloDialog"
title="Hello World">
<buttons>
<Button text="Ok">
<Button text="Cancel">
</buttons>
</Dialog>
</core:FragmentDefinition>
And instead of using a dialog control you can use a sap.m.MessageBox control which provides you with "Ok" and "Cancel" or custom buttons.

Why are Breadcrumbs sapui5 minimized?

in my SAPUI5-application i use breadcrumbs. This feature is quite nice, but on a specific word ("Vertrag") the link to the overriding breadcrumb is collapsed and there's a dropdown-field. By changing the word from "Vertrag" to "Vertrags", the overriding breadcrumb isn't collapsed anymore.
Can you help me, to disaple this dropdown-field?
XML-file containing the breadcrumb:
<FlexBox height="50px" alignItems="Start" justifyContent="Center">
<Breadcrumbs currentLocationText="{i18n>Contract}">
<Link press="onPressBreadcrumb" text="{i18n>Overview}" id="Overview"/>
</Breadcrumbs>
</FlexBox>
OK
Not OK
Thanks.
I think, this must be a issue on calculation width of the flex box. Try to play with margins, pattern or other stuff that affect rendering.
Or try to force for test like this
<FlexBox height="50px" alignItems="Start" justifyContent="Center">
<Breadcrumbs currentLocationText="{i18n>Contract}">
<Link press="onPressBreadcrumb" text="{i18n>Overview}" id="Overview"/>
</Breadcrumbs>
<Label text="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />
</FlexBox>
It may be necessary to test it on all popular browsers.

Set visible property of MenuItem

I want set visible property of MenuItem https://openui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.MenuButton/code/MB.view.xml) component but if I write
<items>
<MenuItem text="Edit" icon="sap-icon://edit" visible="true" />
<MenuItem text="Save" icon="sap-icon://save" visible="false" />
<MenuItem text="Open" icon="sap-icon://open-folder" />
</items>
The result is always all three items visible
EDIT:
release1.40.6 fix the bug
But I want use the last long-term maintenance release (1.38.x)... I don't see the fix here
https://openui5.hana.ondemand.com/#releasenotes.html
This is was a bug of the framework (GitHub issue). The fix is now available as of UI5 1.38.8.