Ivan - Add sorting arrows to table and list users [skip ci]
This commit is contained in:
parent
9c027c91c0
commit
d5cdbd723f
|
@ -14,6 +14,8 @@ class AdminPanelListUsers extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
loading: true,
|
loading: true,
|
||||||
users: [],
|
users: [],
|
||||||
|
orderBy: 'id',
|
||||||
|
desc: true,
|
||||||
page: 1,
|
page: 1,
|
||||||
pages: 1
|
pages: 1
|
||||||
};
|
};
|
||||||
|
@ -65,12 +67,18 @@ class AdminPanelListUsers extends React.Component {
|
||||||
{
|
{
|
||||||
key: 'tickets',
|
key: 'tickets',
|
||||||
value: i18n('TICKETS'),
|
value: i18n('TICKETS'),
|
||||||
className: 'admin-panel-list-users__table-tickets col-md-2'
|
className: 'admin-panel-list-users__table-tickets col-md-2',
|
||||||
|
order: true,
|
||||||
|
onOrderUp: this.orderByTickets.bind(this, false),
|
||||||
|
onOrderDown: this.orderByTickets.bind(this, true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'signupDate',
|
key: 'signupDate',
|
||||||
value: i18n('SIGNUP_DATE'),
|
value: i18n('SIGNUP_DATE'),
|
||||||
className: 'admin-panel-list-users__table-date col-md-2'
|
className: 'admin-panel-list-users__table-date col-md-2',
|
||||||
|
order: true,
|
||||||
|
onOrderUp: this.orderById.bind(this, false),
|
||||||
|
onOrderDown: this.orderById.bind(this, true)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -110,6 +118,24 @@ class AdminPanelListUsers extends React.Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
orderByTickets(desc) {
|
||||||
|
this.retrieveUsers({
|
||||||
|
page: 1,
|
||||||
|
orderBy: 'tickets',
|
||||||
|
desc: desc,
|
||||||
|
search: this.state.search
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
orderById(desc) {
|
||||||
|
this.retrieveUsers({
|
||||||
|
page: 1,
|
||||||
|
orderBy: 'id',
|
||||||
|
desc: desc,
|
||||||
|
search: this.state.search
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
retrieveUsers(data) {
|
retrieveUsers(data) {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: true
|
loading: true
|
||||||
|
|
|
@ -3,6 +3,7 @@ import _ from 'lodash';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import Menu from 'core-components/menu';
|
import Menu from 'core-components/menu';
|
||||||
|
import Icon from 'core-components/icon';
|
||||||
import Loading from 'core-components/loading';
|
import Loading from 'core-components/loading';
|
||||||
|
|
||||||
class Table extends React.Component {
|
class Table extends React.Component {
|
||||||
|
@ -56,7 +57,23 @@ class Table extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<th className={classNames(classes)} key={header.key}>{header.value}</th>
|
<th className={classNames(classes)} key={header.key}>
|
||||||
|
{header.value}
|
||||||
|
{(header.order) ? this.renderHeaderArrows(header.onOrderUp, header.onOrderDown) : null}
|
||||||
|
</th>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderHeaderArrows(onArrowUp, onArrowDown) {
|
||||||
|
return (
|
||||||
|
<span className="table__header-arrows">
|
||||||
|
<span className="table__header-arrow-up" onClick={onArrowUp}>
|
||||||
|
<Icon name="arrow-up"/>
|
||||||
|
</span>
|
||||||
|
<span className="table__header-arrow-down" onClick={onArrowDown}>
|
||||||
|
<Icon name="arrow-down"/>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,18 @@
|
||||||
background-color: $primary-blue;
|
background-color: $primary-blue;
|
||||||
color: white;
|
color: white;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
|
|
||||||
|
&-arrow-up {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: $font-size--xs;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-arrow-down {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: $font-size--xs;
|
||||||
|
margin-left: 3px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__header-column {
|
&__header-column {
|
||||||
|
|
Loading…
Reference in New Issue