mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 14:57:22 +03:00
Fixed short URLs ordering in desktop resolutions
This commit is contained in:
parent
c5f59a17dd
commit
e4d5424c07
3 changed files with 23 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
import caretDownIcon from '@fortawesome/fontawesome-free-solid/faCaretDown';
|
import caretDownIcon from '@fortawesome/fontawesome-free-solid/faCaretDown';
|
||||||
import caretUpIcon from '@fortawesome/fontawesome-free-solid/faCaretUp';
|
import caretUpIcon from '@fortawesome/fontawesome-free-solid/faCaretUp';
|
||||||
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
||||||
import { isEmpty, pick } from 'ramda';
|
import { head, isEmpty, pick } from 'ramda';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { ShortUrlsRow } from './helpers/ShortUrlsRow';
|
import { ShortUrlsRow } from './helpers/ShortUrlsRow';
|
||||||
|
@ -20,10 +20,10 @@ export class ShortUrlsList extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
const orderBy = props.shortUrlsListParams.orderBy;
|
const { orderBy } = props.shortUrlsListParams;
|
||||||
this.state = {
|
this.state = {
|
||||||
orderField: orderBy ? Object.keys(orderBy)[0] : 'dateCreated',
|
orderField: orderBy ? head(Object.keys(orderBy)) : undefined,
|
||||||
orderDir: orderBy ? Object.values(orderBy)[0] : 'ASC',
|
orderDir: orderBy ? head(Object.values(orderBy)) : undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,13 +33,24 @@ export class ShortUrlsList extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const determineOrderDir = field => {
|
||||||
|
if (this.state.orderField !== field) {
|
||||||
|
return 'ASC';
|
||||||
|
}
|
||||||
|
|
||||||
|
const newOrderMap = {
|
||||||
|
'ASC': 'DESC',
|
||||||
|
'DESC': undefined,
|
||||||
|
};
|
||||||
|
return this.state.orderDir ? newOrderMap[this.state.orderDir] : 'ASC';
|
||||||
|
}
|
||||||
const orderBy = field => {
|
const orderBy = field => {
|
||||||
const newOrderDir = this.state.orderField !== field ? 'ASC' : (this.state.orderDir === 'DESC' ? 'ASC' : 'DESC');
|
const newOrderDir = determineOrderDir(field);
|
||||||
this.setState({ orderField: field, orderDir: newOrderDir });
|
this.setState({ orderField: field, orderDir: newOrderDir });
|
||||||
this.refreshList({ orderBy: { [field]: newOrderDir } })
|
this.refreshList({ orderBy: { [field]: newOrderDir } })
|
||||||
};
|
};
|
||||||
const renderOrderIcon = field => {
|
const renderOrderIcon = field => {
|
||||||
if (this.state.orderField !== field) {
|
if (this.state.orderField !== field || this.state.orderDir === undefined) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,3 +13,7 @@
|
||||||
.short-urls-list__header-icon {
|
.short-urls-list__header-icon {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.short-urls-list__header-cell--with-action {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
|
@ -27,10 +27,11 @@
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 3px;
|
top: 3.5px;
|
||||||
right: .5rem;
|
right: .5rem;
|
||||||
width: auto;
|
width: auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue