Skip to content

Commit

Permalink
[FEATURE] Model properties are sorted alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
mitch-b committed Dec 17, 2016
1 parent ee8a48b commit 45a0df3
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions control/lib/PopoverHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ sap.ui.define([
_loadPropertiesAtDepth: function () {
var sFragmentId = this._getId('FragmentId');
var sPropertyListId = this._getId('PropertyListId');
var sPropertyPageId = this._getId('PropertyPageId');

var oPropertyList = Fragment.byId(sFragmentId, sPropertyListId);
var sModelName = this.getCurrentModelName();
Expand All @@ -641,7 +640,8 @@ sap.ui.define([
var oModelData = this._getDataFromModel(sModelName);
var aProperties = this._getControlArray(oModelData);

var oPropertiesPage = Fragment.byId(sFragmentId, sPropertyPageId);
aProperties.sort(this._sortPropertyListAlphabetically);

oPropertyList.destroyItems();

for (var i = 0; i < aProperties.length; i++) {
Expand All @@ -651,6 +651,29 @@ sap.ui.define([
return this;
},

/**
* Sort Property List (Alphabetically)
* @function
*
* Sorter function to place items in property list in order.
* Uses <code>sap.m.InputListItem.getLabel()</code> to sort.
*
* @param {sap.m.InputListItem} a - First item in sort function
* @param {sap.m.InputListItem} b - Second item in sort function
* @returns {int} iPosition - JavaScript sort function return value
*/
_sortPropertyListAlphabetically: function (a, b) {
var sALabel = a.getLabel().toLowerCase();
var sBLabel = b.getLabel().toLowerCase();
if (sALabel < sBLabel) {
return -1;
}
if (sALabel > sBLabel) {
return 1;
}
return 0;
},

/**
* Get Data from Model
*
Expand Down

0 comments on commit 45a0df3

Please sign in to comment.