mirror of
https://github.com/strapi/strapi.git
synced 2025-11-14 09:07:59 +00:00
Fix limit picker
This commit is contained in:
parent
a5eaeb9b96
commit
5b69e1981b
@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
// import PropTypes from 'prop-types';
|
// import PropTypes from 'prop-types';
|
||||||
import _ from 'lodash';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
import { map } from 'lodash';
|
||||||
|
import styles from './styles.scss';
|
||||||
|
|
||||||
class LimitSelect extends React.Component {
|
class LimitSelect extends React.Component {
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
@ -14,10 +16,6 @@ class LimitSelect extends React.Component {
|
|||||||
this.setState({ id });
|
this.setState({ id });
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of default values to populate the select options
|
* Return the list of default values to populate the select options
|
||||||
*
|
*
|
||||||
@ -28,39 +26,30 @@ class LimitSelect extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <div />;
|
return (
|
||||||
|
<form className="form-inline">
|
||||||
|
|
||||||
// // Generate options
|
<div className={styles.selectWrapper}>
|
||||||
// const options = this.getOptionsValues().map(optionValue => (
|
<select
|
||||||
// <option value={optionValue} key={optionValue}>{optionValue}</option>
|
onChange={this.props.handleChange}
|
||||||
// ));
|
className={`form-control ${styles.select}`}
|
||||||
//
|
id={this.state.id}
|
||||||
// // Get id in order to link the `label` and the `select` elements
|
value={this.props.limit}
|
||||||
// const id = this.state.id;
|
>
|
||||||
//
|
{map(this.getOptionsValues(), (optionValue, key) => <option value={optionValue} key={key}>{optionValue}</option>)}
|
||||||
// return (
|
</select>
|
||||||
// <form className="form-inline">
|
</div>
|
||||||
// <div className="form-group">
|
<label className={styles.label} htmlFor={this.state.id}>
|
||||||
// <label className={styles.label} htmlFor={id}>
|
<FormattedMessage id="content-manager.components.LimitSelect.itemsPerPage" />
|
||||||
// <FormattedMessage id="content-manager.components.LimitSelect.itemsPerPage" />:
|
</label>
|
||||||
// </label>
|
</form>
|
||||||
// <div className={styles.selectWrapper}>
|
);
|
||||||
// <select
|
|
||||||
// onChange={this.props.onLimitChange}
|
|
||||||
// className={`form-control ${styles.select}`}
|
|
||||||
// id={id}
|
|
||||||
// >
|
|
||||||
// {options}
|
|
||||||
// </select>
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
// </form>
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LimitSelect.propTypes = {
|
LimitSelect.propTypes = {
|
||||||
// onLimitChange: PropTypes.func.isRequired,
|
handleChange: PropTypes.func.isRequired,
|
||||||
|
limit: PropTypes.number.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LimitSelect;
|
export default LimitSelect;
|
||||||
|
|||||||
@ -1,27 +1,28 @@
|
|||||||
.selectWrapper {
|
.selectWrapper {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
||||||
&:after {
|
|
||||||
content: "\f104";
|
|
||||||
position: absolute;
|
|
||||||
top: 10px;
|
|
||||||
right: 26px;
|
|
||||||
font-family: 'ionicons', Helvetica;
|
|
||||||
color: #465373;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.select {
|
.select {
|
||||||
|
|
||||||
|
height: 3.2rem !important;
|
||||||
|
min-width: 5.4rem;
|
||||||
|
padding-top: 0rem;
|
||||||
|
padding-left: 1rem;
|
||||||
|
padding-right: 3rem;
|
||||||
|
background-position: right -1px center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-image: url('./background_input.svg');
|
||||||
|
border: 1px solid #E3E9F3;
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
line-height: 3.2rem;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
font-family: 'Lato' !important;
|
||||||
|
-moz-appearance: none;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
background: #ffffff;
|
|
||||||
border-radius: 2.4rem;
|
|
||||||
padding-top: 0.6rem;
|
|
||||||
padding-right: 1.4rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
color: #465373;
|
color: #465373;
|
||||||
margin-right: 1rem;
|
margin-left: 1rem;
|
||||||
}
|
}
|
||||||
@ -18,8 +18,8 @@ class TableFooter extends React.Component {
|
|||||||
<div className={`row ${styles.tableFooter}`}>
|
<div className={`row ${styles.tableFooter}`}>
|
||||||
<div className="col-lg-6">
|
<div className="col-lg-6">
|
||||||
<LimitSelect
|
<LimitSelect
|
||||||
className="push-lg-right"
|
|
||||||
handleLimit={this.props.handleLimit}
|
handleChange={this.props.handleChangeLimit}
|
||||||
limit={this.props.limit}
|
limit={this.props.limit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -43,7 +43,7 @@ TableFooter.propTypes = {
|
|||||||
PropTypes.bool,
|
PropTypes.bool,
|
||||||
]).isRequired,
|
]).isRequired,
|
||||||
currentPage: PropTypes.number.isRequired,
|
currentPage: PropTypes.number.isRequired,
|
||||||
handleLimit: PropTypes.func.isRequired,
|
handleChangeLimit: PropTypes.func.isRequired,
|
||||||
limit: PropTypes.number.isRequired,
|
limit: PropTypes.number.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -125,6 +125,14 @@ export class List extends React.Component {
|
|||||||
this.addRoute = `${this.props.match.path.replace(':slug', slug)}/create`;
|
this.addRoute = `${this.props.match.path.replace(':slug', slug)}/create`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleChangeLimit = ({ target }) => {
|
||||||
|
this.props.changeLimit(parseInt(target.value));
|
||||||
|
router.push({
|
||||||
|
pathname: this.props.location.pathname,
|
||||||
|
search: `?page=${this.props.currentPage}&limit=${target.value}&sort=${this.props.sort}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
handleDelete = (e) => {
|
handleDelete = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@ -234,7 +242,7 @@ export class List extends React.Component {
|
|||||||
changePage={this.changePage}
|
changePage={this.changePage}
|
||||||
count={this.props.count}
|
count={this.props.count}
|
||||||
className="push-lg-right"
|
className="push-lg-right"
|
||||||
handleLimit={this.props.changeLimit}
|
handleChangeLimit={this.handleChangeLimit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -33,7 +33,7 @@ const initialState = fromJS({
|
|||||||
loadingCount: true,
|
loadingCount: true,
|
||||||
count: false,
|
count: false,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
limit: 2,
|
limit: 10,
|
||||||
sort: 'id',
|
sort: 'id',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
"containers.Edit.returnList": "Return to list",
|
"containers.Edit.returnList": "Return to list",
|
||||||
"containers.List.addAnEntry": "Add New {entity}",
|
"containers.List.addAnEntry": "Add New {entity}",
|
||||||
"containers.List.pluginHeaderDescription": "Manage your {label}",
|
"containers.List.pluginHeaderDescription": "Manage your {label}",
|
||||||
"components.LimitSelect.itemsPerPage": "Number of items per page",
|
"components.LimitSelect.itemsPerPage": "Items per page",
|
||||||
"containers.List.errorFetchRecords": "Error",
|
"containers.List.errorFetchRecords": "Error",
|
||||||
"pageNotFound": "Page not found",
|
"pageNotFound": "Page not found",
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
"containers.Edit.returnList": "Retourner à la liste",
|
"containers.Edit.returnList": "Retourner à la liste",
|
||||||
"containers.List.addAnEntry": "Ajouter {entity}",
|
"containers.List.addAnEntry": "Ajouter {entity}",
|
||||||
"containers.List.pluginHeaderDescription": "Gérér vos {label}",
|
"containers.List.pluginHeaderDescription": "Gérér vos {label}",
|
||||||
"components.LimitSelect.itemsPerPage": "Nombre d'éléments par page",
|
"components.LimitSelect.itemsPerPage": "Éléments par page",
|
||||||
"containers.List.errorFetchRecords": "Erreur",
|
"containers.List.errorFetchRecords": "Erreur",
|
||||||
|
|
||||||
"popUpWarning.button.cancel": "Annuler",
|
"popUpWarning.button.cancel": "Annuler",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user