-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added everything for Step 11: Assign Multiple Targets
- Loading branch information
Showing
10 changed files
with
257 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
webapp/controller/employee/overview/EmployeeOverview.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
sap.ui.define([ | ||
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController" | ||
], function (BaseController) { | ||
"use strict"; | ||
return BaseController.extend("com.mrb.UI5-Navigation-and-Routing.controller.employee.overview.EmployeeOverview", { | ||
}); | ||
}); |
139 changes: 139 additions & 0 deletions
139
webapp/controller/employee/overview/EmployeeOverviewContent.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
sap.ui.define([ | ||
"com/mrb/UI5-Navigation-and-Routing/controller/BaseController", | ||
"sap/ui/model/Filter", | ||
"sap/ui/model/FilterOperator", | ||
"sap/ui/model/Sorter", | ||
"sap/m/ViewSettingsDialog", | ||
"sap/m/ViewSettingsItem" | ||
], function( | ||
BaseController, | ||
Filter, | ||
FilterOperator, | ||
Sorter, | ||
ViewSettingsDialog, | ||
ViewSettingsItem | ||
) { | ||
"use strict"; | ||
|
||
return BaseController.extend("com.mrb.UI5-Navigation-and-Routing.controller.employee.overview.EmployeeOverviewContent", { | ||
|
||
onInit: function () { | ||
this._oTable = this.byId("employeesTable"); | ||
this._oVSD = null; | ||
this._sSortField = null; | ||
this._bSortDescending = false; | ||
this._aValidSortFields = ["EmployeeID", "FirstName", "LastName"]; | ||
this._sSearchQuery = null; | ||
|
||
this._initViewSettingsDialog(); | ||
}, | ||
|
||
onSortButtonPressed : function () { | ||
this._oVSD.open(); | ||
}, | ||
|
||
onSearchEmployeesTable : function (oEvent) { | ||
this._applySearchFilter( oEvent.getSource().getValue() ); | ||
}, | ||
|
||
_initViewSettingsDialog : function () { | ||
this._oVSD = new ViewSettingsDialog("vsd", { | ||
confirm: function (oEvent) { | ||
var oSortItem = oEvent.getParameter("sortItem"); | ||
this._applySorter(oSortItem.getKey(), oEvent.getParameter("sortDescending")); | ||
}.bind(this) | ||
}); | ||
|
||
// init sorting (with simple sorters as custom data for all fields) | ||
this._oVSD.addSortItem(new ViewSettingsItem({ | ||
key: "EmployeeID", | ||
text: "Employee ID", | ||
selected: true // by default the MockData is sorted by EmployeeID | ||
})); | ||
|
||
this._oVSD.addSortItem(new ViewSettingsItem({ | ||
key: "FirstName", | ||
text: "First Name", | ||
selected: false | ||
})); | ||
|
||
this._oVSD.addSortItem(new ViewSettingsItem({ | ||
key: "LastName", | ||
text: "Last Name", | ||
selected: false | ||
})); | ||
}, | ||
|
||
_applySearchFilter : function (sSearchQuery) { | ||
var aFilters, oFilter, oBinding; | ||
|
||
// first check if we already have this search value | ||
if (this._sSearchQuery === sSearchQuery) { | ||
return; | ||
} | ||
this._sSearchQuery = sSearchQuery; | ||
this.byId("searchField").setValue(sSearchQuery); | ||
|
||
// add filters for search | ||
aFilters = []; | ||
if (sSearchQuery && sSearchQuery.length > 0) { | ||
aFilters.push(new Filter("FirstName", FilterOperator.Contains, sSearchQuery)); | ||
aFilters.push(new Filter("LastName", FilterOperator.Contains, sSearchQuery)); | ||
oFilter = new Filter({ filters: aFilters, and: false }); // OR filter | ||
} else { | ||
oFilter = null; | ||
} | ||
|
||
// update list binding | ||
oBinding = this._oTable.getBinding("items"); | ||
oBinding.filter(oFilter, "Application"); | ||
}, | ||
|
||
/** | ||
* Applies sorting on our table control. | ||
* @param {string} sSortField the name of the field used for sorting | ||
* @param {string} sortDescending true or false as a string or boolean value to specify a descending sorting | ||
* @private | ||
*/ | ||
_applySorter : function (sSortField, sortDescending){ | ||
var bSortDescending, oBinding, oSorter; | ||
|
||
// only continue if we have a valid sort field | ||
if (sSortField && this._aValidSortFields.indexOf(sSortField) > -1) { | ||
|
||
// convert the sort order to a boolean value | ||
if (typeof sortDescending === "string") { | ||
bSortDescending = sortDescending === "true"; | ||
} else if (typeof sortDescending === "boolean") { | ||
bSortDescending = sortDescending; | ||
} else { | ||
bSortDescending = false; | ||
} | ||
|
||
// sort only if the sorter has changed | ||
if (this._sSortField && this._sSortField === sSortField && this._bSortDescending === bSortDescending) { | ||
return; | ||
} | ||
|
||
this._sSortField = sSortField; | ||
this._bSortDescending = bSortDescending; | ||
oSorter = new Sorter(sSortField, bSortDescending); | ||
|
||
// sync with View Settings Dialog | ||
this._syncViewSettingsDialogSorter(sSortField, bSortDescending); | ||
|
||
oBinding = this._oTable.getBinding("items"); | ||
oBinding.sort(oSorter); | ||
} | ||
}, | ||
|
||
_syncViewSettingsDialogSorter : function (sSortField, bSortDescending) { | ||
// the possible keys are: "EmployeeID" | "FirstName" | "LastName" | ||
// Note: no input validation is implemented here | ||
this._oVSD.setSelectedSortItem(sSortField); | ||
this._oVSD.setSortDescending(bSortDescending); | ||
} | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<mvc:View | ||
controllerName="com.mrb.UI5-Navigation-and-Routing.controller.employee.overview.EmployeeOverview" | ||
xmlns="sap.m" | ||
xmlns:mvc="sap.ui.core.mvc"> | ||
<Page id="EmployeeOverviewParent" title="{i18n>EmployeeOverview}" | ||
showNavButton="true" | ||
navButtonPress=".onNavBack" | ||
class="sapUiResponsiveContentPadding"> | ||
<content> | ||
<!-- inserted by routing --> | ||
</content> | ||
</Page> | ||
</mvc:View> |
42 changes: 42 additions & 0 deletions
42
webapp/view/employee/overview/EmployeeOverviewContent.view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<mvc:View | ||
controllerName="com.mrb.UI5-Navigation-and-Routing.controller.employee.overview.EmployeeOverviewContent" | ||
xmlns="sap.m" | ||
xmlns:mvc="sap.ui.core.mvc"> | ||
<Table id="employeesTable" | ||
items="{/Employees}"> | ||
<headerToolbar> | ||
<Toolbar> | ||
<Title text="{i18n>Employees}" level="H2"/> | ||
<ToolbarSpacer /> | ||
<SearchField id="searchField" search=".onSearchEmployeesTable" width="50%"/> | ||
<Button icon="sap-icon://sort" press=".onSortButtonPressed"/> | ||
</Toolbar> | ||
</headerToolbar> | ||
<columns> | ||
<Column id="employeeIDCol"><Text text="{i18n>EmployeeID}"/></Column> | ||
<Column id="firstNameCol" demandPopin="true"><Text text="{i18n>FirstName}"/></Column> | ||
<Column id="lastNameCol" demandPopin="true"><Text text="{i18n>LastName}"/></Column> | ||
<Column id="addressCol" minScreenWidth="Tablet" demandPopin="true"><Text text="{i18n>Address}"/></Column> | ||
<Column id="cityCol" minScreenWidth="Tablet" demandPopin="true"><Text text="{i18n>City}"/></Column> | ||
<Column id="regionCol" minScreenWidth="Tablet" demandPopin="true"><Text text="{i18n>Region}"/></Column> | ||
<Column id="postalCodeCol" minScreenWidth="Tablet" demandPopin="true"><Text text="{i18n>PostalCode}"/></Column> | ||
<Column id="countryCol" minScreenWidth="Tablet" demandPopin="true"><Text text="{i18n>Country}"/></Column> | ||
<Column id="homePhoneCol" minScreenWidth="Tablet" demandPopin="true" hAlign="Right"><Text text="{i18n>Phone}"/></Column> | ||
</columns> | ||
<items> | ||
<ColumnListItem> | ||
<cells> | ||
<Text text="{EmployeeID}"/> | ||
<Text text="{FirstName}"/> | ||
<Text text="{LastName}"/> | ||
<Text text="{Address}"/> | ||
<Text text="{City}"/> | ||
<Text text="{Region}"/> | ||
<Text text="{PostalCode}"/> | ||
<Text text="{Country}"/> | ||
<Text text="{HomePhone}"/> | ||
</cells> | ||
</ColumnListItem> | ||
</items> | ||
</Table> | ||
</mvc:View> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" class="sapUiMediumMarginBottom"> | ||
<Title text="{i18n>EmployeeOverviewTop}"/> | ||
</mvc:View> |