Skip to content

Commit

Permalink
Clear complex code
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-jung committed Dec 25, 2017
1 parent 6c878a5 commit af29b7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions public/management/list.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chain, upperFirst, camelCase, remove, pick, attempt, isArray, find } from 'lodash';
import { chain, remove, pick, attempt, isArray, find } from 'lodash';
import Promise from 'bluebird';
import angular from 'angular';
import { saveAs } from '@elastic/filesaver';
Expand Down Expand Up @@ -38,10 +38,11 @@ uiRoutes
.reduce((map, hit) => {
const { _id, _type, _source, indexPatternId } = hit;
const item = map[_id] || (map[_id] = { _id });
item[`has${upperFirst(camelCase(_type))}`] = true;
if (_type === 'index-pattern') {
item.hasIndexPattern = true;
item.indexPatternId = indexPatternId;
} else if (_type === 'markdown_template') {
item.hasMarkdownTemplate = true;
item._type = _type;
item._source = _source;
}
Expand All @@ -63,6 +64,10 @@ uiRoutes
.then(() => $scope.$apply());
};

$scope.isSorted = key => {
return $scope.listOrder.endsWith(key);
};

$scope.changeOrder = key => {
const [direction, field] = $scope.listOrder.match(/^([\+\-])?(.+)$/).slice(1);
if (field !== key) $scope.listOrder = `+${key}`;
Expand Down

0 comments on commit af29b7f

Please sign in to comment.