Skip to content
Merged
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
29 changes: 25 additions & 4 deletions jsapp/js/components/table.es6
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,36 @@ export class DataTable extends React.Component {
console.error(error);
});
}

_prepColumns(data) {
var excludes = ['_xform_id_string', '_attachments', '_notes', '_bamboo_dataset_id', '_status',
'formhub/uuid', '_tags', '_geolocation', '_submitted_by', 'meta/instanceID', 'meta/deprecatedID', '_validation_status'];
const excludedKeys = [
'_xform_id_string',
'_attachments',
'_notes',
'_bamboo_dataset_id',
'_status',
'formhub/uuid',
'_tags',
'_geolocation',
'_submitted_by',
'meta/instanceID',
'meta/deprecatedID',
'_validation_status'
];

var uniqueKeys = Object.keys(data.reduce(function(result, obj) {
const dataKeys = Object.keys(data.reduce(function(result, obj) {
return Object.assign(result, obj);
}, {}));

uniqueKeys = uniqueKeys.filter((el, ind, arr) => excludes.includes(el) === false);
const surveyKeys = [];
this.props.asset.content.survey.forEach((row) => {
surveyKeys.push(row.$autoname);
});

// make sure the survey columns are displayed, even if current data's
// submissions doesn't have them
let uniqueKeys = [...new Set([...dataKeys, ...surveyKeys])];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌈

uniqueKeys = uniqueKeys.filter((key) => excludedKeys.includes(key) === false);

let showLabels = this.state.showLabels,
showGroupName = this.state.showGroupName,
Expand Down