2016-05-25 17:33:06 +02:00
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
2016-06-26 08:06:20 +02:00
|
|
|
angular.module('ariaNg').filter('fileOrderBy', ['$filter', 'ariaNgCommonService', function ($filter, ariaNgCommonService) {
|
2016-05-25 17:33:06 +02:00
|
|
|
return function (array, type) {
|
|
|
|
if (!angular.isArray(array)) {
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
2016-05-31 16:51:12 +02:00
|
|
|
var orderType = ariaNgCommonService.parseOrderType(type);
|
2016-05-25 17:33:06 +02:00
|
|
|
|
2016-08-01 19:26:10 +02:00
|
|
|
if (orderType === null) {
|
2016-05-25 17:33:06 +02:00
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
2016-08-01 19:26:10 +02:00
|
|
|
if (orderType.type === 'name') {
|
2016-06-26 08:06:20 +02:00
|
|
|
return $filter('orderBy')(array, ['fileName'], orderType.reverse);
|
2016-08-01 19:26:10 +02:00
|
|
|
} else if (orderType.type === 'size') {
|
2016-06-26 08:06:20 +02:00
|
|
|
return $filter('orderBy')(array, ['length'], orderType.reverse);
|
2016-08-01 19:26:10 +02:00
|
|
|
} else if (orderType.type === 'percent') {
|
2016-06-26 08:06:20 +02:00
|
|
|
return $filter('orderBy')(array, ['completePercent'], orderType.reverse);
|
2016-05-25 17:33:06 +02:00
|
|
|
} else {
|
|
|
|
return array;
|
|
|
|
}
|
2016-12-10 18:50:25 +01:00
|
|
|
};
|
2016-05-25 17:33:06 +02:00
|
|
|
}]);
|
2016-08-01 16:49:16 +02:00
|
|
|
}());
|