Refactor latestItems filter

pull/3913/head
Alex Dik 9 years ago
parent e0e2593e6d
commit b5946428d1
  1. 2
      frontend/app/components/common/filters/latest-items.filter.js
  2. 4
      frontend/app/components/common/filters/latest-items.filter.test.js
  3. 2
      frontend/app/components/wp-panels/activity-panel/activity-panel-overview.directive.html

@ -31,7 +31,7 @@ angular
.filter('latestItems', latestItems);
function latestItems() {
return function(items, reverse, visible) {
return function(items, visible, reverse) {
return reverse ? items.slice(-visible).reverse() : items.slice(0,visible);
};
}

@ -42,11 +42,11 @@ describe('Latest items filter', function() {
}));
it('should return the first 3 items', inject(function($filter) {
expect($filter('latestItems')(items, true, 3)).to.eql([9,8,7]);
expect($filter('latestItems')(items, 3, true)).to.eql([9,8,7]);
}));
it('should return the last 3 items reversed', inject(function($filter) {
expect($filter('latestItems')(items, false, 3)).to.eql([1,2,3]);
expect($filter('latestItems')(items, 3)).to.eql([1,2,3]);
}));
});

@ -2,7 +2,7 @@
activities="vm.activities"
autocomplete-path="{{ vm.autocompletePath }}">
<ul class='work-package-details-activities-list'>
<li ng-repeat="activity in vm.activities | latestItems : vm.reverse : 3"
<li ng-repeat="activity in vm.activities | latestItems : 3 : vm.reverse "
class="work-package-details-activities-activity"
ng-init="inf = vm.info(activity, $index)">

Loading…
Cancel
Save