mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
Merge pull request #699 from react-bootstrap-table/develop
20181205 release
This commit is contained in:
commit
bb752fcec8
@ -103,7 +103,7 @@ const columns = [{
|
||||
}, {
|
||||
dataField: 'quality',
|
||||
text: 'Product Quality',
|
||||
editorRenderer: (editorProps, value, row, rowIndex, columnIndex) => (
|
||||
editorRenderer: (editorProps, value, row, column, rowIndex, columnIndex) => (
|
||||
<QualityRanger { ...editorProps } value={ value } />
|
||||
)
|
||||
}];
|
||||
|
||||
@ -2,9 +2,9 @@ import React from 'react';
|
||||
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import Code from 'components/common/code-block';
|
||||
import { productsGenerator } from 'utils/common';
|
||||
import { productsGenerator, withOnSale } from 'utils/common';
|
||||
|
||||
const products = productsGenerator();
|
||||
const products = withOnSale(productsGenerator());
|
||||
|
||||
function priceFormatter(cell, row) {
|
||||
if (row.onSale) {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
/* eslint no-mixed-operators: 0 */
|
||||
/* eslint no-param-reassign: 0 */
|
||||
|
||||
/**
|
||||
* products generator for stories
|
||||
@ -22,6 +23,12 @@ export const productsGenerator = (quantity = 5, callback) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const withOnSale = rows => rows.map((row) => {
|
||||
if (row.id > 2) row.onSale = false;
|
||||
else row.onSale = true;
|
||||
return row;
|
||||
});
|
||||
|
||||
export const productsQualityGenerator = (quantity = 5) =>
|
||||
Array.from({ length: quantity }, (value, index) => ({
|
||||
id: index,
|
||||
|
||||
@ -43,12 +43,13 @@ class SelectionProvider extends React.Component {
|
||||
|
||||
let currSelected = [...this.state.selected];
|
||||
|
||||
let result = true;
|
||||
if (onSelect) {
|
||||
const row = dataOperator.getRowByRowId(data, keyField, rowKey);
|
||||
result = onSelect(row, checked, rowIndex, e);
|
||||
}
|
||||
|
||||
this.setState(() => {
|
||||
let result = true;
|
||||
if (onSelect) {
|
||||
const row = dataOperator.getRowByRowId(data, keyField, rowKey);
|
||||
result = onSelect(row, checked, rowIndex, e);
|
||||
}
|
||||
if (result === true || result === undefined) {
|
||||
if (mode === ROW_SELECT_SINGLE) { // when select mode is radio
|
||||
currSelected = [rowKey];
|
||||
@ -81,24 +82,22 @@ class SelectionProvider extends React.Component {
|
||||
currSelected = selected.filter(s => typeof data.find(d => d[keyField] === s) === 'undefined');
|
||||
}
|
||||
|
||||
this.setState(() => {
|
||||
let result;
|
||||
if (onSelectAll) {
|
||||
result = onSelectAll(
|
||||
!isUnSelect,
|
||||
dataOperator.getSelectedRows(
|
||||
data,
|
||||
keyField,
|
||||
isUnSelect ? this.state.selected : currSelected
|
||||
),
|
||||
e
|
||||
);
|
||||
if (Array.isArray(result)) {
|
||||
currSelected = result;
|
||||
}
|
||||
let result;
|
||||
if (onSelectAll) {
|
||||
result = onSelectAll(
|
||||
!isUnSelect,
|
||||
dataOperator.getSelectedRows(
|
||||
data,
|
||||
keyField,
|
||||
isUnSelect ? this.state.selected : currSelected
|
||||
),
|
||||
e
|
||||
);
|
||||
if (Array.isArray(result)) {
|
||||
currSelected = result;
|
||||
}
|
||||
return { selected: currSelected };
|
||||
});
|
||||
}
|
||||
this.setState(() => ({ selected: currSelected }));
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@ -18,8 +18,7 @@ const Header = (props) => {
|
||||
sortOrder,
|
||||
selectRow,
|
||||
onExternalFilter,
|
||||
expandRow,
|
||||
bootstrap4
|
||||
expandRow
|
||||
} = props;
|
||||
|
||||
let SelectionHeaderCellComp = () => null;
|
||||
@ -50,7 +49,6 @@ const Header = (props) => {
|
||||
return (
|
||||
<HeaderCell
|
||||
index={ i }
|
||||
bootstrap4={ bootstrap4 }
|
||||
key={ column.dataField }
|
||||
column={ column }
|
||||
onSort={ onSort }
|
||||
@ -78,8 +76,7 @@ Header.propTypes = {
|
||||
selectRow: PropTypes.object,
|
||||
onExternalFilter: PropTypes.func,
|
||||
className: PropTypes.string,
|
||||
expandRow: PropTypes.object,
|
||||
bootstrap4: PropTypes.bool
|
||||
expandRow: PropTypes.object
|
||||
};
|
||||
|
||||
export default Header;
|
||||
|
||||
@ -33,7 +33,7 @@ export default class ExpandCell extends Component {
|
||||
|
||||
handleClick(e) {
|
||||
const { rowKey, expanded, onRowExpand, rowIndex } = this.props;
|
||||
|
||||
e.stopPropagation();
|
||||
onRowExpand(rowKey, !expanded, rowIndex, e);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user