Skip to content

Commit

Permalink
update(OrderBy): Check for valid input
Browse files Browse the repository at this point in the history
  • Loading branch information
coryshaw1 committed Jul 6, 2016
1 parent 261b5ba commit 4301af8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
16 changes: 9 additions & 7 deletions bundles/fuel-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4269,21 +4269,23 @@ System.registerDynamic("fuel-ui/dist/pipes/OrderBy/OrderBy", ["@angular/core"],
if (config === void 0) {
config = '+';
}
if (!input)
return input;
this.value = input.slice();
var value = this.value;
if (!Array.isArray(value))
return value;
if (!Array.isArray(config) || (Array.isArray(config) && config.length == 1)) {
var propertyToCheck = !Array.isArray(config) ? config : config[0];
var desc = propertyToCheck.substr(0, 1) == '-';
var desc_1 = propertyToCheck.substr(0, 1) == '-';
if (!propertyToCheck || propertyToCheck == '-' || propertyToCheck == '+') {
return !desc ? value.sort() : value.sort().reverse();
return !desc_1 ? value.sort() : value.sort().reverse();
} else {
var property = propertyToCheck.substr(0, 1) == '+' || propertyToCheck.substr(0, 1) == '-' ? propertyToCheck.substr(1) : propertyToCheck;
var property_1 = propertyToCheck.substr(0, 1) == '+' || propertyToCheck.substr(0, 1) == '-' ? propertyToCheck.substr(1) : propertyToCheck;
return value.sort(function(a, b) {
var aValue = a[property];
var bValue = b[property];
var propertySplit = property.split('.');
var aValue = a[property_1];
var bValue = b[property_1];
var propertySplit = property_1.split('.');
if (typeof aValue === 'undefined' && typeof bValue === 'undefined' && propertySplit.length > 1) {
aValue = a;
bValue = b;
Expand All @@ -4292,7 +4294,7 @@ System.registerDynamic("fuel-ui/dist/pipes/OrderBy/OrderBy", ["@angular/core"],
bValue = bValue[propertySplit[j]];
}
}
return !desc ? OrderByPipe._orderByComparator(aValue, bValue) : -OrderByPipe._orderByComparator(aValue, bValue);
return !desc_1 ? OrderByPipe._orderByComparator(aValue, bValue) : -OrderByPipe._orderByComparator(aValue, bValue);
});
}
} else {
Expand Down
Loading

0 comments on commit 4301af8

Please sign in to comment.