Skip to content
Snippets Groups Projects
Commit bfae383f authored by Aurélien Warnon's avatar Aurélien Warnon Committed by Thibault Delavallée
Browse files

[FIX] survey: fix survey result filters

Since recent refactoring, filter data have 'question' and 'answers' as
filter_data keys, instead of 'question_text' and 'labels'. This commit fixes
the naming in template using filter_data.

Also, comment that does not count as answer is not linked to a suggested
answer. So that filtering on those comment does nothing because we cannot
find an answer_id in that case. As it makes no real sens anyway to filter
on those kind of comment, filtering have been disabled on those comments.

Triggered by task ID 1972640 (live sessions on survey)
PR #44205
parent 8862a32d
Branches
Tags
No related merge requests found
......@@ -549,8 +549,9 @@ class Survey(http.Controller):
line_choices.append(answer_id)
answers = request.env['survey.question.answer'].browse([answer_id])
if answer_id:
question_id = answers[0].matrix_question_id or answers[0].question_id
search_filters.append({
'question': answers[0].question_id.title,
'question': question_id.title,
'answers': '%s%s' % (answers[0].value, ': %s' % answers[1].value if len(answers) > 1 else '')
})
if line_choices:
......
......@@ -23,7 +23,7 @@
<span t-att-class="'badge only_left_radius filter-all %s' % 'badge-secondary' if search_finished else 'badge-primary o_active_filter'">All surveys</span>
<span t-att-class="'badge only_right_radius filter-finished %s' % 'badge-secondary' if not search_finished else 'badge-primary o_active_filter'">Finished surveys</span>
<span t-foreach="search_filters" t-as="filter_data">
<span class="badge badge-primary only_left_radius"><i class="fa fa-filter" role="img" aria-label="Filter" title="Filter"></i></span><span class="badge badge-primary no_radius" t-esc="filter_data['question_text']"></span><span class="badge badge-success only_right_radius" t-esc="' > '.join(filter_data['labels'])"></span>
<span class="badge badge-primary only_left_radius"><i class="fa fa-filter" role="img" aria-label="Filter" title="Filter"></i></span><span class="badge badge-primary no_radius" t-esc="filter_data['question']"></span><span class="badge badge-success only_right_radius" t-esc="' > '.join(filter_data['answers'])"></span>
</span>
</div>
</div>
......@@ -244,7 +244,8 @@
<td class="survey_answer">
<span t-esc="round(choice_data['count'] * 100.0/ (len(question_data['answer_line_done_ids']) or 1), 2)"></span> %
<span t-esc="'%s Votes' % choice_data['count']" class="badge badge-primary"/>
<i class="fa fa-filter text-primary survey_filter"
<i t-if="choice_data['suggested_answer'].id"
class="fa fa-filter text-primary survey_filter"
t-att-data-question_id="question.id"
t-att-data-answer_id="choice_data['suggested_answer'].id"
role="img" aria-label="Filter question" title="Filter question"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment