Business Example
In this exercise, you will learn how to work with a local Git Repository.
Steps
Log into your training SAP Business Application Studio.
Perform this step as shown in a previous exercise.
Create a new SAP Fiori Freestyle project using the following information.
SAP Fiori Freestyle Project Information
Field Value Template SAP Fiori application Template Type SAP Fiori Template Basic Data source None View name Main Module name ux402_repository Application title Repository-integration Application namespace student##.com.sap.training.ux402.repository Description A Fiori Application. Project folder path /home/user/projects Leave other fields and radio buttons as default values.
Perform this step as shown in a previous exercise.
Open the terminal for the ux402_repository folder. Initialize the local GIT repository by executing the following command:
git init
.Open the terminal for the ux402_repository folder by choosing Open in Integrated Terminal in the contextual menu.
Initialize the local GIT repository by executing the given command.
Stage all changes over the Git view for the first commit. The Git view is located on the left side menu in the form of a branch symbol. If you open it, you will see all changes. You can stage all changes by choosing the three dots symbol and in the dropdown menu, Changes → Stage All Changes.
From the left side menu of the SAP Business Application Studio, choose the branch symbol (Source Control) to open the Git view.
Check the commit section of the Git view (located under the Message input field). The files are marked as untracked (U) and located under Changes.
Now stage all changes for the first commit. For the staging, select the three dots symbol (Views and More actions…) and choose Changes → Stage All Changes.
Check the commit section of the Git view. As you can see, the files are now marked as added (A) and located under Staged Changes.
Commit the files that you have staged in your local Git repository. Use the Git view for the commit and Initial Commit as commit message. You can then go back to the Explorer pane.
Commit the files that you have staged in your local Git repository. For the commit, just type in Initial Commit into the Message input field of the Git view and select the Commit button or choose the checkmark symbol.
There will be zero changes within the Git view:
Go back to the Explorer pane.
Add the listed view of type XML in the view folder and the corresponding controller of type JavaScript in the controller folder of your project. To create the files, use Copy and Paste in the context menu of the Main.view.xml and Main.controller.js files. Rename them to the listed view and controller file names. In the created Detail.view.xml file, you need to change part of the
controllerName
attribute fromMain
toDetail
and remove thedisplayBlock
attribute. Then change the value of thetitle
attribute of thePage
element to the stringTitle
. A string is sufficient for this exercise, you do not need to use i18n. In the created Detail.controller.js file, you need to change part of the controller name in theextend
function fromMain
toDetail
.View and Controller File Names
View file name Controller file name Detail.view.xml Detail.controller.js Add the Detail.view.xml file in the view folder and the corresponding Detail.controller.js file in the controller folder of your project. Use Copy then Paste in the context menu of the Main.view.xml and Main.controller.js files to create the files. Now, rename them.
In the created Detail.view.xml file, you need to change part of the
controllerName
attribute fromMain
toDetail
and remove thedisplayBlock
attribute. Then change the value of thetitle
attribute of thePage
element to the stringTitle
. A string is sufficient for this exercise, you do not need to use i18n.Code snippetExpand<mvc:View controllerName="student00.com.sap.training.ux402.repository.ux402repository.controller.Detail" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"> <Page id="page" title="Title"> <content /> </Page> </mvc:View>
In the created Detail.controller.js file, you need to change part of the controller name in the extend function from
Main
toDetail
. The last part of the string should look like the following:
Stage your changes and commit them with the commit message, Detail view and controller added, and come back to the Explorer pane.
Open the Git view and check the commit section. As you can see, the Detail.controller.js and Detail.view.xml files are marked now as untracked (U) and located under Changes.
Now, stage all changes. For the staging, select the three dots symbol (Views and More actions…) and then on Changes → Stage All Changes. Alternatively, you can stage the files individually by selecting the + symbol (Stage Changes) for every file. Now, the files should be marked as added (A) and located under Staged Changes.
Commit the files that you have staged in your local Git repository. For the commit, just enter Detail view and controller added into the Message input field of the Git view and select the Commit button or choose the checkmark symbol. Now, there should be zero changes.
Come back to the Explorer pane.
Open the Detail.view.xml file and assign the value
Detail
to thetitle
attribute of thePage
element. For this exercise, there is no need to use i18n, just assign the valueDetail
as a string. Then save your changes.Open the Detail.view.xml file.
Change the value of the
title
attribute of thePage
element toDetail
:Save your changes.
Stage your changes and commit them with the Commit message, Detail view title changed.
Open the Git view. As you can see, the Detail.view.xml file is now marked as modified (M) and located under Changes.
Now, stage the changes. For the staging, you can select the + symbol (Stage Changes) for the Detail.view.xml file. When this action is complete, the Detail.view.xml file should still be marked as modified (M) but is now located under Staged Changes.
Commit the files that you have staged in your local Git repository. For the commit, enter Detail view title changed in the Message input field of the Git view and select the Commit button or select the checkmark symbol. Now, there should be zero changes.
Select the Git: View history (Git log) icon to see the history of commits. You should see all three commits done in this exercise: