Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 103 additions & 97 deletions README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion demo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import './css/styles.css';

const store = configureStore(config);

const Demo = () =>
const Demo = () => (
<div className="d-flex" id="wrapper">
<div className="bg-light border-right sidenav" id="sidebar-wrapper">
<div className="sidebar-heading"><strong>redux-datatable</strong></div>
Expand All @@ -36,6 +36,7 @@ const Demo = () =>
</div>
</div>
</div>
);

render(
<Provider store={ store }>
Expand Down
4 changes: 2 additions & 2 deletions demo/src/schema/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default {
label: 'Delete',
indexField: '@id',
thunk: ( payload ) => ( dispatch, getState ) => {
confirm("Are your sure you want to delete the selected items?")
confirm('Are your sure you want to delete the selected items?')
? console.log('delete items', getState())
: console.log(false);

Expand Down Expand Up @@ -211,7 +211,7 @@ export default {
id: '@id'
},
thunk: ( payload ) => ( dispatch, getState ) => {
confirm("Are your sure you want to delete this page?")
confirm('Are your sure you want to delete this page?')
? console.log('delete', getState())
: console.log(false);

Expand Down
6 changes: 3 additions & 3 deletions demo/src/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import basic from './basic';

export default [
{
title: "Basic Table",
id: "basic-table",
className: "mb-4",
title: 'Basic Table',
id: 'basic-table',
className: 'mb-4',
config: basic
}
]
2 changes: 1 addition & 1 deletion nwb.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ module.exports = {
}
}
}
}
};
44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flipbyte/redux-datatable",
"version": "0.2.0",
"version": "0.2.1",
"description": "React-Redux data table",
"main": "lib/index.js",
"module": "es/index.js",
Expand All @@ -20,13 +20,13 @@
"test:watch": "nwb test-react --server"
},
"peerDependencies": {
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rxjs": "^6.4.0",
"prop-types": "^15.6.2",
"react-redux": "^6.0.1",
"redux": "^4.0.1",
"styled-components": "^4.1.3"
"styled-components": "^4.2.0"
},
"dependencies": {
"lodash": ">=4.17.10",
Expand All @@ -44,13 +44,13 @@
"bootstrap": "^4.3.1",
"nwb": "0.23.x",
"path-to-regexp": "^3.0.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-redux": "^6.0.1",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"rxjs": "^6.4.0",
"styled-components": "^4.1.3"
"styled-components": "^4.2.0"
},
"author": "",
"homepage": "",
Expand Down
4 changes: 2 additions & 2 deletions src/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const getRenderers = ( ofType ) => renderers[ofType] || {};
const Renderer = ({ ofType, forItem, ...props }) => {
const renderers = getRenderers(ofType);
const Renderer = renderers[forItem] || renderers['default'];
return <Renderer { ...props } />
}
return <Renderer { ...props } />;
};

export default Renderer;
2 changes: 1 addition & 1 deletion src/Renderer/Body/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect } from 'react-redux';
import React, { Component } from 'react';
import { deleteData } from '../../actions';
import { withTableConfig } from '../../TableProvider';
import { paramsResolver, prepareActionPayload } from '../../utils'
import { paramsResolver, prepareActionPayload } from '../../utils';
import Button from '../../components/Button';

const Actions = ({
Expand Down
3 changes: 1 addition & 2 deletions src/Renderer/Body/Date.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import _ from 'lodash';
import Time from 'react-pure-time';
import React, { Component } from 'react';
import { shouldUpdate } from '../../utils';

const Date = ({
data,
index,
colConfig: { name, textAlign, format }
}) => (
<Time value={ _.get(data, name, '') } format={ format ? format : 'F j, Y, g:i a' } />
)
);

export default Date;
3 changes: 1 addition & 2 deletions src/Renderer/Body/Image.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash';
import { shouldUpdate } from '../../utils';
import React, { Fragment, Component } from 'react';

const Image = ({
Expand All @@ -8,6 +7,6 @@ const Image = ({
colConfig: { name, imgWidth, imgHeight }
}) => (
<img src={ _.get(data, name, '') } width={ imgWidth } height={ imgHeight } />
)
);

export default Image;
5 changes: 2 additions & 3 deletions src/Renderer/Body/Options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import _ from 'lodash';
import Time from 'react-pure-time';
import { shouldUpdate } from '../../utils';
import React, { Fragment, Component } from 'react';

const Options = ({
Expand All @@ -10,14 +9,14 @@ const Options = ({
const value = _.get(data, name);

if(!options || !options[value]) {
return <Fragment>{ value }</Fragment>
return <Fragment>{ value }</Fragment>;
}

return (
<span className={ (options[value].badge ? 'badge ' + options[value].badge : '') }>
{ options[value].value }
</span>
);
}
};

export default Options;
6 changes: 3 additions & 3 deletions src/Renderer/Body/Selection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import PropTypes from "prop-types";
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import React, { Component } from 'react';
import { SET_SELECTION } from '../../actions';
Expand All @@ -11,7 +11,7 @@ const handleSelection = ({ data, indexField, action }, event ) => {
let paramKey = getConfigParam(indexField);
let key = getParam(indexField, data);
action(SET_SELECTION)({ paramKey, key, value: event.target.checked });
}
};

const Selection = ({
action,
Expand All @@ -31,6 +31,6 @@ const Selection = ({
onChange={ handleSelection.bind(this, { data, indexField, action }) } />
</div>
);
}
};

export default Selection;
1 change: 0 additions & 1 deletion src/Renderer/Body/Text.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash';
import { shouldUpdate } from '../../utils';
import React, { Fragment, Component } from 'react';

const Text = ({
Expand Down
2 changes: 1 addition & 1 deletion src/Renderer/Filter/Date.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var dateTo = null;
const applyFilter = ( key, filterer, event ) => {
let filter = {};

if (key == 0) {
if (key === 0) {
dateFrom = event.target.value;
} else {
dateTo = event.target.value;
Expand Down
2 changes: 1 addition & 1 deletion src/Renderer/Filter/Number.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var valTo = null;
const applyFilter = ( key, filterer, event ) => {
let filter = {};

if (key == 0) {
if (key === 0) {
valFrom = event.target.value;
} else {
valTo = event.target.value;
Expand Down
2 changes: 1 addition & 1 deletion src/Renderer/Pagination/Limiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ const Limiter = ({ options, limit, action, style, default: defaultLimit }) => {
</Field.Select> per page
</Label>
);
}
};

export default Limiter;
16 changes: 8 additions & 8 deletions src/Renderer/Pagination/Pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const List = styled.div `
background: ${props => props.background || '#fff'};
border: ${props => props.border || '1px solid rgba(34,36,38,.15)'};
border-radius: ${props => props.borderRadius || 'none'};
height: ${props => props.height || '40px'}
`
height: ${props => props.height || '40px'};
`;

const NUM_LINKS = 5;

Expand All @@ -23,18 +23,18 @@ const getPages = ( currentPage, total ) => {
var left = (currentPage - padding < padding) ? 1 : currentPage - padding;
var right = (left + NUM_LINKS - 1 > total) ? total : left + NUM_LINKS - 1;

left = (right == total) ?
left = (right === total) ?
(right - NUM_LINKS < 1) ? 1 : right - NUM_LINKS + 1
: left;

return fillRange(left, right);
}
};

const Pages = ({ page, total, action, style }) => {
const setPage = ( page ) => action(SET_PAGE)({ page });
return (
<List>
<Button onClick={ setPage.bind(this, 1) } disabled={ page == 1 }>First</Button>
<Button onClick={ setPage.bind(this, 1) } disabled={ page === 1 }>First</Button>
<Button onClick={ setPage.bind(this, page - 1) } disabled={ page < 2 } >Previous</Button>
{ getPages(page, total).map( (link, index) =>
<Button
Expand All @@ -44,9 +44,9 @@ const Pages = ({ page, total, action, style }) => {
>{ link }</Button>
) }
<Button onClick={ setPage.bind(this, page + 1) } disabled={ page >= total }>Next</Button>
<Button onClick={ setPage.bind(this, total) } disabled={ page == total }>Last</Button>
<Button onClick={ setPage.bind(this, total) } disabled={ total === 0 || page === total }>Last</Button>
</List>
);
}
};

export default Pages
export default Pages;
5 changes: 3 additions & 2 deletions src/Renderer/Pagination/ResultCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import React from 'react';
const lowerLimit = ( page, limit ) => ((page - 1) * limit) + 1;
const upperLimit = ( page, limit, count ) => (page * limit) > count ? count : page * limit;

const ResultCount = ({ page, limit, count }) =>
const ResultCount = ({ page, limit, count }) => (
!!count > 0 &&
<span>Showing { lowerLimit(page, limit) } to { upperLimit(page, limit, count) } of { count } entries</span>
);

export default ResultCount
export default ResultCount;
Loading