Skip to content

Commit c487248

Browse files
authored
Merge pull request #2939 from kobotoolbox/2937-table-columns-not-displaying
2937 table columns not displaying
2 parents 06c0aa4 + 473eff5 commit c487248

2 files changed

Lines changed: 28 additions & 13 deletions

File tree

jsapp/js/components/submissionDataTable.es6

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
getSubmissionDisplayData
1212
} from 'js/submissionUtils';
1313
import {
14+
META_QUESTION_TYPES,
1415
QUESTION_TYPES,
1516
SCORE_ROW_TYPE,
1617
RANK_LEVEL_TYPE
@@ -301,9 +302,17 @@ class SubmissionDataTable extends React.Component {
301302
<bem.SubmissionDataTable>
302303
{this.renderGroup(displayData)}
303304

304-
{this.renderMetaResponse('start', t('start'))}
305-
{this.renderMetaResponse('end', t('end'))}
305+
{this.renderMetaResponse(META_QUESTION_TYPES.get('start'), t('start'))}
306+
{this.renderMetaResponse(META_QUESTION_TYPES.get('end'), t('end'))}
307+
{this.renderMetaResponse(META_QUESTION_TYPES.get('today'), t('today'))}
308+
{this.renderMetaResponse(META_QUESTION_TYPES.get('username'), t('username'))}
309+
{this.renderMetaResponse(META_QUESTION_TYPES.get('simserial'), t('sim serial'))}
310+
{this.renderMetaResponse(META_QUESTION_TYPES.get('subscriberid'), t('subscriber ID'))}
311+
{this.renderMetaResponse(META_QUESTION_TYPES.get('deviceid'), t('device ID'))}
312+
{this.renderMetaResponse(META_QUESTION_TYPES.get('phonenumber'), t('phone number'))}
313+
{this.renderMetaResponse(META_QUESTION_TYPES.get('audit'), t('audit'))}
306314
{this.renderMetaResponse('__version__', t('__version__'))}
315+
{this.renderMetaResponse('_id', t('_id'))}
307316
{this.renderMetaResponse('meta/instanceID', t('instanceID'))}
308317
{this.renderMetaResponse('_submitted_by', t('Submitted by'))}
309318
</bem.SubmissionDataTable>

jsapp/js/components/table.es6

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,10 @@ export class DataTable extends React.Component {
174174
getDisplayedColumns(data) {
175175
const flatPaths = getSurveyFlatPaths(this.props.asset.content.survey);
176176

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

180-
// makes sure the survey columns are displayed, even if current data's
181-
// submissions doesn't have them
180+
// Gather unique columns from all visible submissions and add them to output
182181
const dataKeys = Object.keys(data.reduce(function(result, obj) {
183182
return Object.assign(result, obj);
184183
}, {}));
@@ -194,18 +193,25 @@ export class DataTable extends React.Component {
194193
const foundPathKey = Object.keys(flatPaths).find((pathKey) => {
195194
return flatPaths[pathKey] === key;
196195
});
197-
const foundRow = this.props.asset.content.survey.find((row) => {
196+
197+
// no path means this definitely is not a note type
198+
if (!foundPathKey) {
199+
return true;
200+
}
201+
202+
const foundNoteRow = this.props.asset.content.survey.find((row) => {
198203
return (
199-
key === row.name ||
200-
key === row.$autoname ||
201-
foundPathKey === row.name ||
202-
foundPathKey === row.$autoname
204+
typeof foundPathKey !== 'undefined' &&
205+
(foundPathKey === row.name || foundPathKey === row.$autoname) &&
206+
row.type === QUESTION_TYPES.get('note').id
203207
);
204208
});
205-
if (foundRow) {
206-
return foundRow.type !== QUESTION_TYPES.get('note').id;
209+
if (typeof foundNoteRow !== 'undefined') {
210+
// filter out this row as this is a note type
211+
return false;
207212
}
208-
return false;
213+
214+
return true;
209215
});
210216

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

0 commit comments

Comments
 (0)