[IMP] survey: slightly improve result template
Purpose is to remove an unnecessary template by directly including the "no result" inside the main result template. It eases understanding and updating of templates. This commit is linked to task ID 1932508 and PR #30508.
This commit is contained in:
@@ -348,8 +348,7 @@ class Survey(http.Controller):
|
||||
filter_display_data = []
|
||||
filter_finish = False
|
||||
|
||||
if not survey.user_input_ids or not [input_id.id for input_id in survey.user_input_ids if input_id.state != 'new']:
|
||||
result_template = 'survey.no_result'
|
||||
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
|
||||
@@ -359,6 +358,7 @@ class Survey(http.Controller):
|
||||
filter_display_data = survey.get_filter_display_data(filter_data)
|
||||
return request.render(result_template,
|
||||
{'survey': survey,
|
||||
'answers': answers,
|
||||
'survey_dict': self._prepare_result_dict(survey, current_filters),
|
||||
'page_range': self.page_range,
|
||||
'current_filters': current_filters,
|
||||
|
||||
@@ -415,8 +415,11 @@
|
||||
<div class="jumbotron mt32">
|
||||
<h1><span t-field="survey.title" /> <span style="font-size:1.5em;" class="fa fa-bar-chart-o float-right " role="img" aria-label="Chart" title="Chart"/></h1>
|
||||
<div t-field="survey.description" class="oe_no_empty" />
|
||||
<h2 t-if="not answers">
|
||||
Sorry, no one answered this survey yet.
|
||||
</h2>
|
||||
</div>
|
||||
<div class="card d-print-none">
|
||||
<div t-if="answers" class="card d-print-none">
|
||||
<div class="card-header"><span class="fa fa-filter"></span> Filters <span t-if="filter_display_data" class="float-right text-primary clear_survey_filter"><i class="fa fa-times"></i> Clear All Filters</span></div>
|
||||
<div class="card-body">
|
||||
<span t-if="filter_finish == True">
|
||||
@@ -430,7 +433,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div t-foreach="survey_dict['page_ids']" t-as='page_ids'>
|
||||
<div t-if="answers" t-foreach="survey_dict['page_ids']" t-as='page_ids'>
|
||||
<t t-set="page" t-value="page_ids['page']"/>
|
||||
<h1 class="mt16" t-field='page.title'></h1>
|
||||
<div t-field="page.description" class="oe_no_empty" />
|
||||
@@ -720,22 +723,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template id="no_result" name="Survey Result">
|
||||
<t t-call="survey.layout">
|
||||
<div class="container">
|
||||
<t t-call="survey.back" />
|
||||
<h2><span t-field='survey.title'></span></h2>
|
||||
<div class="jumbotron mt32">
|
||||
<h2 class="text-muted">
|
||||
<span>
|
||||
<i style="font-size:1.8em" class="fa fa-users float-right" role="img" aria-label="No answer" title="No answer"></i>
|
||||
</span>
|
||||
Sorry, No one answered this survey yet
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
<!-- Pagination Element -->
|
||||
<template id="pagination" name="Survey Result">
|
||||
<t t-set="record_limit" t-value="10"/><!-- Change This record_limit to change number of record per page-->
|
||||
|
||||
Reference in New Issue
Block a user