How decrease the size of simple form and place in the middle of the screen - sapui5

I have the following simple form:
<Page title="{i18n>authorization}">
<content>
<VBox>
<f:SimpleForm id="registration" editable="true" layout="ResponsiveGridLayout" labelSpanXL="3" labelSpanL="3" labelSpanM="3" labelSpanS="12"
adjustLabelSpan="true" emptySpanXL="3" emptySpanL="3" emptySpanM="3" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1"
singleContainerFullSize="true">
<f:content>
<Label text=""/>
<Text text="{i18n>userAuthorize}"/>
<Label text=""/>
<Input placeholder="Enter your email address" id="email" type="Email" value="{confirm>/email}" liveChange="onHandleLiveChangeEmail"/>
<Label text=""/>
<Button type="Accept" enabled="{confirm>/enable}" text="{i18n>confirm}" press="handlePressAuthorization"
ariaDescribedBy="acceptButtonDescription genericButtonDescription">
<layoutData>
<FlexItemData growFactor="1"/>
</layoutData>
</Button>
</f:content>
</f:SimpleForm>
</VBox>
</content>
</Page>
and on the large screen, it stretches too width. What I would like that the simple form should take 4 columns width and place in the middle of screen.
How can I do it?

Try giving your VBox control a specific width. That way the SimpleForm will only fit that. In the VBox you can also add the alignItems="Center" attribute.
If you want to center controls and also not to the full width of the screen, you can do the following:
<VBox width="100%" alignItems="Center">
<VBox width="50%" alignItems="Start">
<!-- Content goes here... -->
</VBox>
</VBox>
This way your controls will be centered and also only stretched to the width of the inner VBox.

Related

How to align the FormGroups with the FormElements in a SimpleForm [UI5, Fiori]

i do have the case in which i would like to have the FormElements be inline like but also to have the group title in this case "First Group" and "Second Group" be aligned with the FormElemens block.
Code:
<form:SimpleForm
title="Databinding basics: SimpleForm - Beispiel"
layout="ResponsiveGridLayout" editable="true"
columnsM="1" columnsL="1" columnsXL="3"
labelSpanS="12" labelSpanM="4" labelSpanL="12" labelSpanXL="2"
emptySpanS="0" emptySpanM="0" emptySpanL="0" emptySpanXL="0" singleContainerFullSize="false">
<form:content>
<core:Title text="First Group" emphasized="false" level="H4"/>
<Label text="Enabled8"/>
<Text text="Yes"/>
<Label text="Enabled7"/>
<Text text="Yes"/>
<Label text="Enabled8"/>
<Text text="Yes"/>
<core:Title text="Second Group" emphasized="false" level="H4"/>
<Label text="Enabled7"/>
<Text text="Yes"/>
<Label text="Enabled8"/>
<Text text="Yes"/>
<Label text="Enabled7"/>
<Text text="Yes"/>
<Label text="Enabled8"/>
<Text text="Yes"/>
</form:content>
</form:SimpleForm>
My attempt: Via adding labelSpanXL="12" and emptySpan="0" the alignment can be achieved but it puts the Label-Text vertically which i want to avoid.
Question: How can i achieve both for the FormElements to be inline as well as it be aligned with the group Title

How to place icon next to or within input field

How I can put my icon next to or within the input field?
The problem is, the icon changes the form. Usually, it's like this:
But when I'm adding the icon (code below), it displaces the Dauer input Field.
Is there a way to make it look clean and that's next to it? Or better in the input field inside?
I can make the button smaller with CSS but there is still a gap between them.. And it does not move automatically.
The best solution is like the Datum above with a small icon inside where I can click or like the icon is next to the Dauer without no gap between input field from Dauer and the ? icon.
PS: I just want it like this (I will decide then later which option is better. But it is possible?)
<form:SimpleForm id="neuezeiterfassung"
editable="true"
title="Neue Zeiterfassung anlegen"
>
<Label
text="Auftrag"
class="font1"
tooltip="Auftrag eingeben"
/>
<l:VerticalLayout>
<ComboBox id="Auftrag"
items="{/ZAUFKSet}"
showSecondaryValues="true"
width="50%"
>
<core:ListItem text="{Aufnr}" />
</ComboBox>
</l:VerticalLayout>
<Label
text="Datum"
class="font1"
/>
<DatePicker id="DP3"
valueFormat="dd.MM.yyyy"
displayFormat="medium"
width="50%"
placeholder="dd.mm.yyyy"
/>
<Label class="font1" text="Dauer" />
<Input id="dauer"
class="dauer"
placeholder="Dauer eingeben ... "
width="50%"
/>
<HBox class="sapUiSmallMargin">
<core:Icon
src="sap-icon://sys-help"
class="size1" color="#031E48" press="aseads"
>
<core:layoutData>
<FlexItemData growFactor="1" />
</core:layoutData>
</core:Icon>
</HBox>
<!-- <Button icon="sap-icon://sys-help" class="myButton"/> -->
<Label class="font1" text="Arbeitsbeschreibung" />
<TextArea id="beschreibung" width="50%" />
</form:SimpleForm>
Update: with the change in commit:8f1757d, which is available since UI5 1.84, the value help icon can be changed via valueHelpIconSrc:
<Input showValueHelp="true"
valueHelpIconSrc="sap-icon://sys-help"
valueHelpRequest="alert('Help requested')"
/><!-- valueHelpIconSrc available since 1.84.0 -->
No need to extend sap.m.InputBase in this case. Other input controls like sap.m.MaskInput still need to be extended as shown in the linked Plunk below.
Original answer:
The best solution is like the Datum above with a small icon inside where I can click. (...) Is it possible?
Yes, it's possible. Here is a minimal example: https://embed.plnkr.co/EzlF2tkvalJWvSEn
For this, UI5 provides the API addEndIconapi which is protected, meaning it should be used only when extending sap.m.InputBase!
As an argument for the addEndIcon, you can pass a map of settings that are required to create sap.ui.core.Iconapi, which is highly customizable.
const icon = this.addEndIcon({
id: this.getId() + "-questionMarkBtn",
src: IconPool.getIconURI("sys-help"),
noTabStop: true,
tooltip: "Information",
press: [this.onEndButtonPress, this],
}); // See sap.ui.core.Icon/properties for more settings
// icon.addStyleClass(...); if even more customization required..
You can achieve it using the below code, just updated the CSS as per your requirement. It is a responsive design, it will work for all the devices.
CODE
<VBox class="sapUiSmallMargin">
<f:SimpleForm
editable="true"
layout="ResponsiveGridLayout"
title="Neue Zeiterfassung anlegen"
labelSpanXL="3"
labelSpanL="3"
labelSpanM="3"
labelSpanS="12"
adjustLabelSpan="false"
emptySpanXL="1"
emptySpanL="1"
emptySpanM="1"
emptySpanS="0"
columnsXL="1"
columnsL="1"
columnsM="1"
singleContainerFullSize="false" >
<f:content>
<Label text="Auftrag" tooltip="Auftrag eingeben" />
<ComboBox items="{/ZAUFKSet}" id="Auftrag" showSecondaryValues="true">
<core:ListItem text="{Aufnr}"/>
</ComboBox>
<Label text="Datum" labelFor="DP3"/>
<DatePicker id="DP3" valueFormat="dd.MM.yyyy" displayFormat="medium" placeholder="dd.mm.yyyy"/>
<Label class="font1" text="Dauer"/>
<Input value="Street">
<layoutData>
<l:GridData span="XL7 L7 M7 S10" />
</layoutData>
</Input>
<Button icon="sap-icon://sys-help" press="onPress" >
<layoutData>
<l:GridData span="XL1 L1 M1 S2" />
</layoutData>
</Button>
<Label text="Arbeitsbeschreibung"/>
<TextArea id="beschreibung"/>
</f:content>
</f:SimpleForm>
</VBox>
Output:
If you are looking for below output
<f:SimpleForm
editable="true"
layout="ResponsiveGridLayout"
title="Neue Zeiterfassung anlegen"
labelSpanXL="3"
labelSpanL="3"
labelSpanM="3"
labelSpanS="12"
adjustLabelSpan="false"
emptySpanXL="1"
emptySpanL="1"
emptySpanM="1"
emptySpanS="0"
columnsXL="1"
columnsL="1"
columnsM="1"
singleContainerFullSize="false" >
<f:content>
<Label text="Auftrag" tooltip="Auftrag eingeben" />
<ComboBox items="{/ZAUFKSet}" id="Auftrag" showSecondaryValues="true">
<core:ListItem text="{Aufnr}"/>
<layoutData>
<l:GridData span="XL8 L8 M7 S9" />
</layoutData>
</ComboBox>
<Label text="Datum" labelFor="DP3"/>
<DatePicker id="DP3" valueFormat="dd.MM.yyyy" displayFormat="medium"
placeholder="dd.mm.yyyy">
<layoutData>
<l:GridData span="XL8 L8 M7 S9" />
</layoutData>
</DatePicker>
<Label class="font1" text="Dauer"/>
<Input value="Street">
<layoutData>
<l:GridData span="XL8 L8 M7 S9" />
</layoutData>
</Input>
<Button icon="sap-icon://sys-help" press="onPress" width="40px" >
<layoutData>
<l:GridData span="XL1 L1 M1 S3" />
</layoutData>
</Button>
<Label text="Arbeitsbeschreibung"/>
<TextArea id="beschreibung">
<layoutData>
<l:GridData span="XL8 L8 M7 S9" />
</layoutData>
</TextArea>
</f:content>
</f:SimpleForm>
With icon
<VBox class="sapUiSmallMargin">
<f:SimpleForm
editable="true"
layout="ResponsiveGridLayout"
title="Neue Zeiterfassung anlegen"
labelSpanXL="3"
labelSpanL="3"
labelSpanM="3"
labelSpanS="12"
adjustLabelSpan="false"
emptySpanXL="1"
emptySpanL="1"
emptySpanM="1"
emptySpanS="0"
columnsXL="1"
columnsL="1"
columnsM="1"
singleContainerFullSize="false" >
<f:content>
<Label text="Auftrag" tooltip="Auftrag eingeben" />
<ComboBox items="{/ZAUFKSet}" id="Auftrag" showSecondaryValues="true">
<core:ListItem text="{Aufnr}"/>
<layoutData>
<l:GridData span="XL10 L10 M10 S10" />
</layoutData>
</ComboBox>
<Label text="Datum" labelFor="DP3"/>
<DatePicker id="DP3" valueFormat="dd.MM.yyyy" displayFormat="medium" placeholder="dd.mm.yyyy">
<layoutData>
<l:GridData span="XL10 L10 M10 S10" />
</layoutData>
</DatePicker>
<Label class="font1" text="Dauer"/>
<Input value="Street">
<layoutData>
<l:GridData span="XL10 L10 M10 S10" />
</layoutData>
</Input>
<HBox>
<core:Icon src="sap-icon://sys-help" color="#031E48" press="onPress" class="infoIcon"/>
<layoutData>
<l:GridData span="XL1 L1 M1 S1" />
</layoutData>
</HBox>
<Label text="Arbeitsbeschreibung"/>
<TextArea id="beschreibung">
<layoutData>
<l:GridData span="XL10 L10 M10 S10" />
</layoutData>
</TextArea>
</f:content>
</f:SimpleForm>
</VBox>
If you are using the ICON you need to add the style as well for alignment
.infoIcon {
line-height: 3rem;
}
Sometimes extending the InputBase class can be a bit overkill/increase the complexity of the code.
You can also use Flexbox containers to achieve the alignment of the input and the icon.
For example, if you want the input and the icon to be centered vertically and horizontally:
<HBox
alignItems="Center"
justifyContent="Center">
<Input>
<layoutData>
<FlexItemData growFactor="3" />
</layoutData>
</Input>
<core:Icon
src="sap-icon://sys-help">
<!-- Be careful here with the namespaces (use layoutData from core, not m) -->
<core:layoutData>
<FlexItemData growFactor="1" />
</core:layoutData>
</core:Icon>
</HBox>
This will give something like this:
See Flexbox for more examples (API Reference is available at the top of the page).

How to put a line break in sapui5 text or input box?

I cant seem to find a way to put the <DatePicker id="DP1" placeholder="Enter Date" value="{/recipient2/name}" change="handleChange" class="sapUiSmallMarginBottom"/> and <Select selectedKey="{/recipient3/name}" id="input-c" forceSelection="false">
in new line. They show at the same line but I would like them in two different lines.
<mvc:View controllerName="Workspace.controller.App" xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form">
<Page title="{i18n>homePageTitle}">
<content>
<Panel width="auto" class="sapUiResponsiveMargin">
<Image src="https://www.enggwave.com/wp-content/uploads/2016/11/Sopra-Steria-Logo.png" width="100px" height="100px"
class="sapUiResponsiveMargin"></Image>
<Text text="Plot No. 20 21 Seaview Special Economic Zone"/>
<Image src="https://upload.wikimedia.org/wikipedia/en/thumb/0/02/Sopra_Steria_logo.svg/1280px-Sopra_Steria_logo.svg.png" width="500px"
height="100px" class="sapUiResponsiveMargin"></Image>
</Panel>
<Panel>
<f:SimpleForm id="SimpleFormChange354" width="100%" minWidth="1024" maxContainerCols="2" editable="true" layout="ResponsiveGridLayout"
title="FORM" labelSpanL="3" labelSpanM="3" emptySpanL="4" emptySpanM="4" columnsL="1" columnsM="1" class="editableForm">
<f:content>
<Label text="NAME : " labelFor="input-a" design="Bold"/>
<Input id="input-a" placeholder="Enter Name" value="{/recipient1/name}" valueLiveUpdate="true" width="100%" required="true"/>
<Label text="DATE : " labelFor="input-b" design="Bold"/>
<DatePicker id="DP1" placeholder="Enter Date" value="{/recipient2/name}" change="handleChange" class="sapUiSmallMarginBottom"/>
<InputListItem label="Country" >
<Select selectedKey="{/recipient3/name}" id="input-c" forceSelection="false">
<core:Item key="Greece" text="Greece"/>
<core:Item key="Mexico" text="Mexico"/>
<core:Item key="Norway" text="Norway"/>
<core:Item key="New Zealand" text="New Zealand"/>
<core:Item key="Netherlands" text="Netherlands"/>
</Select>
</InputListItem>
<Button text="{i18n>showHelloButtonText}" press="onShowHello"/>
</f:content>
</f:SimpleForm>
</Panel>
</content>
</Page>
</mvc:View>
Try putting the two in a Vbox
<Vbox>
<DatePicker id="DP1" placeholder="Enter Date" value="{/recipient2/name}"
change="handleChange" class="sapUiSmallMarginBottom"/>
<InputListItem label="Country" >
<Select selectedKey="{/recipient3/name}" id="input-c"
forceSelection="false">
<core:Item key="Greece" text="Greece"/>
<core:Item key="Mexico" text="Mexico"/>
<core:Item key="Norway" text="Norway"/>
<core:Item key="New Zealand" text="New Zealand"/>
<core:Item key="Netherlands" text="Netherlands"/>
</Select>
</InputListItem>
<Button text="{i18n>showHelloButtonText}" press="onShowHello"/>
</Vbox>

SAPUI5 Utilize full width of WizardStep

I am using a Wizard object in my app with multiple steps. I want the content of this step to utilize the full width available. I am currently using the below XML, though this is just resulting in the content being bunched together on the left (see attached image).
How can I modify this so the SimpleForms will use the full width of the page ?
Any help would be greatly appreciated,
thanks,
Joe
<WizardStep id="wizStep2" validated="true" title="Customer Confirm"
icon="sap-icon://customer" >
<HBox width="100%" fitContainer="true">
<form:SimpleForm editable="true">
<Label text="Title"/>
<Input value="MR"/>
<Label text="Name"/>
<Input value="John"/>
<Input value="Smith"/>
<Label text="House"/>
<Input value="81"/>
<Label text="Street"/>
<Input value="Main Road"/>
<Label text="City"/>
<Input value=""/>
<Label text="PostCode"/>
<Input value=""/>
</form:SimpleForm>
<form:SimpleForm editable="true">
<Label text="Home Tel"/>
<Input value=""/>
<Label text="Mobile No"/>
<Input value=""/>
<Label text="Email"/>
<Input value=""/>
</form:SimpleForm>
</HBox>
</WizardStep>
Current output
A SimpleForm will start a new column if you use a Title element: Simple Form API Doc. You also can control the Layout of the Simple Form by using SimpleFormLayout.
So basically, you need to place content that will actually use the 100% width.
By default it uses 100% with ... your limitation comes from somewhere else in your view.
This wizard takes 100% of your screen:
<mvc:View controllerName="tc_v1.test.controller.Main" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
displayBlock="true" xmlns="sap.m" xmlns:form="sap.ui.layout.form">
<App id="idAppControl">
<pages>
<Page title="{i18n>title}">
<content>
<Wizard id="wizard" complete="onPressReview" finishButtonText="Review" showNextButton="true">
<WizardStep id="wizStep1" validated="true" title="Customer Confirm" icon="sap-icon://customer">
<HBox fitContainer="true">
<form:SimpleForm editable="true">
<Label text="Title"/>
<Input value="MR"/>
<Label text="Name"/>
<Input value="John"/>
<Input value="Smith"/>
<Label text="House"/>
<Input value="81"/>
<Label text="Street"/>
<Input value="Main Road"/>
<Label text="City"/>
<Input value=""/>
<Label text="PostCode"/>
<Input value=""/>
</form:SimpleForm>
<form:SimpleForm editable="true">
<Label text="Home Tel"/>
<Input value=""/>
<Label text="Mobile No"/>
<Input value=""/>
<Label text="Email"/>
<Input value=""/>
</form:SimpleForm>
</HBox>
</WizardStep>
<WizardStep id="id_wizStp2" validated="true" title="Step 2"/>
<WizardStep id="id_wizStp3" validated="true" title="Step 3"/>
</Wizard>
</content>
</Page>
</pages>
</App>
</mvc:View>

Layout with Label, Inputfield, and Checkbox

Mockup
Current Code
<mvc:View
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
displayBlock="true" height="100%">
<Page showHeader="false" id="page">
<content>
<l:Grid defaultSpan="L12 M12 S12" width="auto">
<l:content>
<f:Form editable="true">
<f:title>
<core:Title text="Test" />
</f:title>
<f:layout>
<f:ResponsiveGridLayout
labelSpanL="3"
labelSpanM="3"
emptySpanL="4"
emptySpanM="4"
columnsL="1"
columnsM="1"
/>
</f:layout>
<f:formContainers>
<f:FormContainer>
<f:formElements>
<f:FormElement label="Name">
<f:fields>
<Input id="name1" value="" />
</f:fields>
</f:FormElement>
<f:FormElement label="Name">
<f:fields>
<Input id="name2" value="" />
</f:fields>
</f:FormElement>
<f:FormElement>
<f:fields>
<CheckBox id="cb1" />
<Text wrapping="true" text="lorem ipsum" />
</f:fields>
</f:FormElement>
</f:formElements>
</f:FormContainer>
</f:formContainers>
</f:Form>
</l:content>
</l:Grid>
</content>
</Page>
</mvc:View>
Problem
The checkbox is not centered. The current code is responsive and the solution should also be responsive.
If you want the checkbox to be centered you need to use a label on your formElement just as you do with the others. If you don't want a label you will probably need some css to put a left-margin on that specific FormElement.
There is maybe another way more "polite" to do that, but if it exists I do not know it, will keep looking at that post to see if someone actually offers a better solution.
But for now, I hope this works for you for the moment.