Skip to content

Commit

Permalink
Merge pull request #1199 from zetkin/enhancement/view-filter-survey-r…
Browse files Browse the repository at this point in the history
…esponse

Handle survey_response cells when searching in view
  • Loading branch information
richardolsson authored Dec 4, 2020
2 parents 93a86c8 + f88e516 commit d8d95d6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/misc/personViews/PersonViewTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,20 @@ export default class PersonViewTable extends React.Component {
const searchStr = this.state.searchStr.toLowerCase();

visibleRows = visibleRows.filter(item => {
return item.data.content.some(cell => {
if (cell && cell.toLowerCase) {
return cell.toLowerCase().indexOf(searchStr) >= 0;
return item.data.content.some((cell, idx) => {
const col = colList.items[idx].data;

let text = null;

if (cell && col.type == 'survey_response') {
text = cell.map(r => r.text).join('\n');
}
else if (typeof cell == 'string') {
text = cell;
}

if (text) {
return text.toLowerCase().indexOf(searchStr) >= 0;
}
else {
return false;
Expand Down

0 comments on commit d8d95d6

Please sign in to comment.