Skip to content

Commit

Permalink
[REF] survey : make survey result a widget
Browse files Browse the repository at this point in the history
This commit cake the survey result analysis js constroller become a widget.
This also simplify style rules using CSS (was handled in JS).
This also modifies the handling of filters to use real
and correctly formated GET parameters.
Redirect url with parameters are now handled automatically
using URLSearchParams() instead of building manually the query string.

Task ID : 1930132
PR #32419
  • Loading branch information
dbeguin committed Nov 19, 2019
1 parent f462bf0 commit ee0b11f
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 137 deletions.
20 changes: 9 additions & 11 deletions addons/survey/controllers/main.py
Expand Up @@ -382,12 +382,9 @@ def survey_report(self, survey, answer_token=None, **post):
result_template = 'survey.result'
current_filters = []
filter_display_data = []
filter_finish = False

answers = survey.user_input_ids.filtered(lambda answer: answer.state != 'new' and not answer.test_entry)
if 'finished' in post:
post.pop('finished')
filter_finish = True
filter_finish = post.get('finished') == 'true'
if post or filter_finish:
filter_data = self._get_filter_data(post)
current_filters = survey.filter_input_ids(filter_data, filter_finish)
Expand Down Expand Up @@ -504,13 +501,14 @@ def _prepare_question_values(self, question, current_filters):
def _get_filter_data(self, post):
"""Returns data used for filtering the result"""
filters = []
for ids in post:
#if user add some random data in query URI, ignore it
try:
row_id, answer_id = ids.split(',')
filters.append({'row_id': int(row_id), 'answer_id': int(answer_id)})
except:
return filters
filters_data = post.get('filters')
if filters_data:
for data in filters_data.split('|'):
try:
row_id, answer_id = data.split(',')
filters.append({'row_id': int(row_id), 'answer_id': int(answer_id)})
except:
return filters
return filters

def page_range(self, total_record, limit):
Expand Down
11 changes: 7 additions & 4 deletions addons/survey/static/src/css/survey_result.css
Expand Up @@ -20,6 +20,10 @@
cursor: pointer;
}

.o_active_filter {
cursor:default;
}

.nvtooltip h5 {
margin: 0;
line-height: 18px;
Expand All @@ -32,14 +36,13 @@
border-radius: 5px 5px 0 0;
}


.survey_answer i {
padding:3px;
cursor:pointer;
visibility:hidden;
}

.survey_answer i.invisible {
visibility: hidden!important;
.survey_answer:hover i {
visibility: visible;
}

@media print {
Expand Down

0 comments on commit ee0b11f

Please sign in to comment.