Skip to content

Commit

Permalink
Merge pull request #2939 from kobotoolbox/2937-table-columns-not-disp…
Browse files Browse the repository at this point in the history
…laying

2937 table columns not displaying
  • Loading branch information
jnm authored Dec 30, 2020
2 parents 06c0aa4 + 473eff5 commit c487248
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
13 changes: 11 additions & 2 deletions jsapp/js/components/submissionDataTable.es6
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getSubmissionDisplayData
} from 'js/submissionUtils';
import {
META_QUESTION_TYPES,
QUESTION_TYPES,
SCORE_ROW_TYPE,
RANK_LEVEL_TYPE
Expand Down Expand Up @@ -301,9 +302,17 @@ class SubmissionDataTable extends React.Component {
<bem.SubmissionDataTable>
{this.renderGroup(displayData)}

{this.renderMetaResponse('start', t('start'))}
{this.renderMetaResponse('end', t('end'))}
{this.renderMetaResponse(META_QUESTION_TYPES.get('start'), t('start'))}
{this.renderMetaResponse(META_QUESTION_TYPES.get('end'), t('end'))}
{this.renderMetaResponse(META_QUESTION_TYPES.get('today'), t('today'))}
{this.renderMetaResponse(META_QUESTION_TYPES.get('username'), t('username'))}
{this.renderMetaResponse(META_QUESTION_TYPES.get('simserial'), t('sim serial'))}
{this.renderMetaResponse(META_QUESTION_TYPES.get('subscriberid'), t('subscriber ID'))}
{this.renderMetaResponse(META_QUESTION_TYPES.get('deviceid'), t('device ID'))}
{this.renderMetaResponse(META_QUESTION_TYPES.get('phonenumber'), t('phone number'))}
{this.renderMetaResponse(META_QUESTION_TYPES.get('audit'), t('audit'))}
{this.renderMetaResponse('__version__', t('__version__'))}
{this.renderMetaResponse('_id', t('_id'))}
{this.renderMetaResponse('meta/instanceID', t('instanceID'))}
{this.renderMetaResponse('_submitted_by', t('Submitted by'))}
</bem.SubmissionDataTable>
Expand Down
28 changes: 17 additions & 11 deletions jsapp/js/components/table.es6
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,10 @@ export class DataTable extends React.Component {
getDisplayedColumns(data) {
const flatPaths = getSurveyFlatPaths(this.props.asset.content.survey);

// start with all paths
// add all questions from the survey definition
let output = Object.values(flatPaths);

// makes sure the survey columns are displayed, even if current data's
// submissions doesn't have them
// Gather unique columns from all visible submissions and add them to output
const dataKeys = Object.keys(data.reduce(function(result, obj) {
return Object.assign(result, obj);
}, {}));
Expand All @@ -194,18 +193,25 @@ export class DataTable extends React.Component {
const foundPathKey = Object.keys(flatPaths).find((pathKey) => {
return flatPaths[pathKey] === key;
});
const foundRow = this.props.asset.content.survey.find((row) => {

// no path means this definitely is not a note type
if (!foundPathKey) {
return true;
}

const foundNoteRow = this.props.asset.content.survey.find((row) => {
return (
key === row.name ||
key === row.$autoname ||
foundPathKey === row.name ||
foundPathKey === row.$autoname
typeof foundPathKey !== 'undefined' &&
(foundPathKey === row.name || foundPathKey === row.$autoname) &&
row.type === QUESTION_TYPES.get('note').id
);
});
if (foundRow) {
return foundRow.type !== QUESTION_TYPES.get('note').id;
if (typeof foundNoteRow !== 'undefined') {
// filter out this row as this is a note type
return false;
}
return false;

return true;
});

// exclude kobomatrix rows as data is not directly tied to them, but
Expand Down

0 comments on commit c487248

Please sign in to comment.