diff --git a/src/common.js b/src/common.js index 1e5fe1d..fb218d0 100644 --- a/src/common.js +++ b/src/common.js @@ -10,9 +10,9 @@ export const createTextFilter = (text) => ({ export const createValueFilter = (column, value) => { const { key, - getValueTitle = () => undefined, - getValueClassName = () => undefined, - getValueLabel = () => { + getFilterTitle = () => undefined, + getFilterClassName = () => undefined, + getFilterLabel = () => { let labelValue = value; if (_.isBoolean(value)) { labelValue = value ? 'Yes' : 'No'; @@ -20,9 +20,9 @@ export const createValueFilter = (column, value) => { return `${column.header}:${labelValue}`; }, } = column; - const title = getValueTitle(value); - const label = getValueLabel(value); - const className = getValueClassName(value); + const title = getFilterTitle(value); + const label = getFilterLabel(value); + const className = getFilterClassName(value); return { key, label, diff --git a/src/selectors.js b/src/selectors.js index 572f06a..5694433 100644 --- a/src/selectors.js +++ b/src/selectors.js @@ -41,9 +41,9 @@ function filter(rows = [], filters = [], filterText, columns) { } if (valueFilters.length > 0) { - // apply value filters on taggable columns + // apply value filters on filterable columns filteredRows = _.filter(filteredRows, row => _.every(columns, column => { - if (!column.taggable) { + if (!column.filterable) { return true; } const value = _.get(row, column.key); @@ -117,15 +117,15 @@ export default (tableName) => { // set predefined values columns.forEach(column => { - if (column.taggable && column.values) { - values[column.key] = column.values; + if (column.filterable && column.filterValues) { + values[column.key] = column.filterValues; } }); // collect values for columns that don't have predefined values initialData.forEach(row => { columns.forEach(column => { - if (!column.taggable || column.values) { + if (!column.filterable || column.filterValues) { return; } if (!values[column.key]) { diff --git a/stories/UsersTable.js b/stories/UsersTable.js index 7270aaa..c6e83a1 100644 --- a/stories/UsersTable.js +++ b/stories/UsersTable.js @@ -11,24 +11,24 @@ const columns = [ { key: 'status', header: 'Status', - taggable: true, - values: [ + filterable: true, + filterValues: [ 'UNKNOWN', 'ACTIVE', 'DISABLED', ], - getValueTitle: (value) => ({ + getFilterTitle: (value) => ({ UNKNOWN: 'Gone missing users', ACTIVE: 'Active users', }[value]), - getValueClassName: (value) => `col-${value.toLowerCase()}`, + getFilterClassName: (value) => `col-${value.toLowerCase()}`, }, { key: 'confirmed', header: 'Confirmed', Component: YesNo, - taggable: true, - getValueTitle: (value) => value ? 'Confirmed' : 'Not confirmed', + filterable: true, + getFilterTitle: (value) => value ? 'Confirmed' : 'Not confirmed', }, ];