Skip to content

Commit

Permalink
[#3] Add values column option to predefine possible values
Browse files Browse the repository at this point in the history
  • Loading branch information
amir-hadzic committed Nov 1, 2016
1 parent 59d3f67 commit a7aff1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,20 @@ export default (tableName) => {
getColumns,
(initialData, columns) => {
const options = [];
const values = {};
const columnMap = _.keyBy(columns, 'key');
const values = {};

// set predefined values
columns.forEach(column => {
if (column.taggable && column.values) {
values[column.key] = column.values;
}
});

// collect values for columns that don't have predefined values
initialData.forEach(row => {
columns.forEach(column => {
if (!column.taggable) {
if (!column.taggable || column.values) {
return;
}
if (!values[column.key]) {
Expand Down
5 changes: 5 additions & 0 deletions stories/UsersTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const columns = [
key: 'status',
header: 'Status',
taggable: true,
values: [
'UNKNOWN',
'ACTIVE',
'DISABLED',
],
getValueTitle: (value) => ({
UNKNOWN: 'Gone missing users',
ACTIVE: 'Active users',
Expand Down

0 comments on commit a7aff1e

Please sign in to comment.