mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Merge pull request #83 from acelaya/feature/insensitive-ordering
Ensured bar graphs are sorted case insensitive
This commit is contained in:
commit
12cddac27a
2 changed files with 10 additions and 3 deletions
|
@ -26,7 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||
|
||||
#### Fixed
|
||||
|
||||
* *Nothing*
|
||||
* [#77](https://github.com/shlinkio/shlink-web-client/issues/77) Sortable graphs ordering is now case insensitive.
|
||||
|
||||
|
||||
## 1.2.0 - 2018-11-01
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { fromPairs, head, keys, prop, reverse, sortBy, toPairs } from 'ramda';
|
||||
import { fromPairs, head, identity, keys, pipe, prop, reverse, sortBy, toLower, toPairs, type } from 'ramda';
|
||||
import SortingDropdown from '../utils/SortingDropdown';
|
||||
import GraphCard from './GraphCard';
|
||||
|
||||
|
@ -23,7 +23,14 @@ export default class SortableBarGraph extends React.Component {
|
|||
return stats;
|
||||
}
|
||||
|
||||
const sortedPairs = sortBy(prop(this.state.orderField === head(keys(sortingItems)) ? 0 : 1), toPairs(stats));
|
||||
const toLowerIfString = (value) => type(value) === 'String' ? toLower(value) : identity(value);
|
||||
const sortedPairs = sortBy(
|
||||
pipe(
|
||||
prop(this.state.orderField === head(keys(sortingItems)) ? 0 : 1),
|
||||
toLowerIfString
|
||||
),
|
||||
toPairs(stats)
|
||||
);
|
||||
|
||||
return fromPairs(this.state.orderDir === 'ASC' ? sortedPairs : reverse(sortedPairs));
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue