mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 22:01:06 +00:00
[my libs] mobile: improvement (#3839)
* [my libs] mobile: improvement * modified 'more' icon * modified background layer of op menu * added 'star/unstar' to the op menu * [my libs] mobile: redesigned 'sort'
This commit is contained in:
65
frontend/src/components/dialog/sort-options.js
Normal file
65
frontend/src/components/dialog/sort-options.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Modal, ModalBody } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
|
||||
const propTypes = {
|
||||
toggleDialog: PropTypes.func.isRequired,
|
||||
sortBy: PropTypes.string.isRequired,
|
||||
sortOrder: PropTypes.string.isRequired,
|
||||
sortList: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
class SortOptions extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.sortOptions = [
|
||||
{id: 'sort-option-1', value: 'name-asc', text: gettext('By name ascending')},
|
||||
{id: 'sort-option-2', value: 'name-desc', text: gettext('By name descending')},
|
||||
{id: 'sort-option-3', value: 'size-asc', text: gettext('By size ascending')},
|
||||
{id: 'sort-option-4', value: 'size-desc', text: gettext('By size descending')},
|
||||
{id: 'sort-option-5', value: 'time-asc', text: gettext('By time ascending')},
|
||||
{id: 'sort-option-6', value: 'time-desc', text: gettext('By time descending')}
|
||||
];
|
||||
const { sortBy, sortOrder } = this.props;
|
||||
this.state = {
|
||||
currentOption: `${sortBy}-${sortOrder}`
|
||||
};
|
||||
}
|
||||
|
||||
switchOption = (e) => {
|
||||
if (!e.target.checked) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
currentOption: e.target.value
|
||||
});
|
||||
|
||||
const [sortBy, sortOrder] = e.target.value.split('-');
|
||||
this.props.sortList(sortBy, sortOrder);
|
||||
this.props.toggleDialog();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal isOpen={true} toggle={this.props.toggleDialog}>
|
||||
<ModalBody>
|
||||
{this.sortOptions.map((item, index) => {
|
||||
return (
|
||||
<Fragment key={index}>
|
||||
<input id={item.id} className="align-middle" type="radio" name="sort-options" value={item.value} checked={this.state.currentOption == item.value} onChange={this.switchOption} />
|
||||
<label htmlFor={item.id} className="align-middle m-2">{item.text}</label><br />
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</ModalBody>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SortOptions.propTypes = propTypes;
|
||||
|
||||
export default SortOptions;
|
Reference in New Issue
Block a user