Skip to content

Commit

Permalink
Merge pull request #2195 from kobotoolbox/fix-table-view-crash
Browse files Browse the repository at this point in the history
Fix table view crashes with missing responses or `name`/`$autoname`
  • Loading branch information
magicznyleszek authored Feb 13, 2019
2 parents bae00d2 + 66a5bf2 commit 857512b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions jsapp/js/components/table.es6
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ export class DataTable extends React.Component {

const surveyKeys = [];
this.props.asset.content.survey.forEach((row) => {
surveyKeys.push(row.$autoname);
if (row.name) {
surveyKeys.push(row.name);
} else if (row.$autoname) {
surveyKeys.push(row.$autoname);
}
});

// make sure the survey columns are displayed, even if current data's
Expand Down Expand Up @@ -413,7 +417,11 @@ export class DataTable extends React.Component {
return formatTimeDate(row.value);
}
}
return typeof(row.value) == 'object' ? '' : row.value;
if (typeof(row.value) == 'object' || row.value === undefined) {
return '';
} else {
return row.value;
}
}
});

Expand Down Expand Up @@ -763,6 +771,8 @@ export class DataTable extends React.Component {
selectAll = this.state.selectAll;
var d = null;

// TODO bulk change to no status

if (!selectAll) {
d = {
submissions_ids: Object.keys(this.state.selectedRows),
Expand Down

0 comments on commit 857512b

Please sign in to comment.