[IMP] uniform view of filters and some code improvements

bzr revid: dizzy.zala@gmail.com-20140403062552-oa002zg7kdlbxh56
This commit is contained in:
Dharmraj Jhala (OpenERP) 2014-04-03 11:55:52 +05:30
parent 4d320b6eca
commit a9c6fb3ec9
4 changed files with 29 additions and 31 deletions

View File

@ -16,7 +16,7 @@
border-radius:0; border-radius:0;
} }
.clear_survey_filter{ .clear_survey_filter, .filter-all, .filter-finished{
cursor:pointer; cursor:pointer;
} }

View File

@ -153,13 +153,13 @@ $(document).ready(function () {
$('.clear_survey_filter').click(function(){ $('.clear_survey_filter').click(function(){
window.location.href = document.URL.substring(0,document.URL.indexOf("?")); window.location.href = document.URL.substring(0,document.URL.indexOf("?"));
}); });
$('li.filter-all').click(function(){ $('span.filter-all').click(function(){
event.preventDefault(); event.preventDefault();
if(document.URL.indexOf("finished") != -1){ if(document.URL.indexOf("finished") != -1){
window.location.href = document.URL.replace('?finished&','?').replace('&finished&','&').replace('?finished','').replace('&finished',''); window.location.href = document.URL.replace('?finished&','?').replace('&finished&','&').replace('?finished','').replace('&finished','');
} }
}); });
$('.filter-finished').click(function(){ $('span.filter-finished').click(function(){
event.preventDefault(); event.preventDefault();
if(document.URL.indexOf("?") == -1 && document.URL.indexOf("filter") == -1){ if(document.URL.indexOf("?") == -1 && document.URL.indexOf("filter") == -1){
window.location.href = document.URL+'?'+encodeURI('finished'); window.location.href = document.URL+'?'+encodeURI('finished');

View File

@ -137,7 +137,6 @@ class survey_survey(osv.Model):
context = {} context = {}
if filters: if filters:
input_line_obj = self.pool.get('survey.user_input_line') input_line_obj = self.pool.get('survey.user_input_line')
label_obj = self.pool.get('survey.label')
domain_filter, choice, filter_display_data = [], [], [] domain_filter, choice, filter_display_data = [], [], []
for filter in filters: for filter in filters:
row_id, answer_id = filter['row_id'], filter['answer_id'] row_id, answer_id = filter['row_id'], filter['answer_id']

View File

@ -17,20 +17,28 @@
<h1><span t-field="survey.title"></span> <span style="font-size:1.5em;" class="fa fa-bar-chart-o pull-right "/></h1> <h1><span t-field="survey.title"></span> <span style="font-size:1.5em;" class="fa fa-bar-chart-o pull-right "/></h1>
<h2><span t-field="survey.description"></span></h2> <h2><span t-field="survey.description"></span></h2>
</div> </div>
<div class="hidden-print"> <div class="filteres hidden-print">
<ul class="nav nav-pills"> <span><h3><span class="fa fa-filter"></span> Filters
<t t-if="filter_finish == True"> <small>
<li class="filter-all"><a href="#">All surveys</a></li> <t t-if="filter_finish == True">
<li class="active filter-finished"><a href="#">Finished surveys</a></li> <span class="label label-default only_left_radius filter-all">
</t> All surveys
<t t-if="filter_finish == False"> </span>
<li class="active filter-all"><a href="#">All surveys</a></li> <span class="label label-primary only_right_radius filter-finished">
<li class="filter-finished"><a href="#">Finished surveys</a></li> Finished surveys
</t> </span>
</ul> </t>
</div> <t t-if="filter_finish == False">
<div t-if="filter_display_data" class="filteres"> <span class="label label-primary only_left_radius filter-all">
<span><h3><span class="fa fa-filter"></span> Filters <small class="pull-right clear_survey_filter"> <i class="fa fa-times"></i> Clear All Filters</small></h3></span> All surveys
</span>
<span class="label label-default only_right_radius filter-finished">
Finished surveys
</span>
</t>
</small>
<small t-if="filter_display_data" class="pull-right clear_survey_filter"> <i class="fa fa-times"></i> Clear All Filters</small></h3>
</span>
<span t-foreach="filter_display_data" t-as="filter_data"> <span t-foreach="filter_display_data" t-as="filter_data">
<span class="label label-primary only_left_radius"><i class="fa fa-filter"></i></span><span class="label label-primary no_radius" t-esc="filter_data['question_text']"></span><span class="label label-success only_right_radius" t-esc="' > '.join(filter_data['labels'])"></span> <span class="label label-primary only_left_radius"><i class="fa fa-filter"></i></span><span class="label label-primary no_radius" t-esc="filter_data['question_text']"></span><span class="label label-success only_right_radius" t-esc="' > '.join(filter_data['labels'])"></span>
</span> </span>
@ -46,6 +54,9 @@
<h4> <h4>
<b>Question </b> <b>Question </b>
<span t-field='question.question'></span> <span t-field='question.question'></span>
<t t-if="question.type == 'matrix'">
<small><span t-field='question.type' class="label label-default"></span></small>
</t>
<span class="pull-right"> <span class="pull-right">
<span class="label label-success"><span t-esc="input_summary['answered']"></span> Answered</span> <span class="label label-success"><span t-esc="input_summary['answered']"></span> Answered</span>
<span class="label label-danger"><span t-esc="input_summary['skipped']"></span> Skipped</span> <span class="label label-danger"><span t-esc="input_summary['skipped']"></span> Skipped</span>
@ -86,32 +97,20 @@
<tbody> <tbody>
<t t-set="text_result" t-value="prepare_result"/> <t t-set="text_result" t-value="prepare_result"/>
<tr class="hidden" t-foreach="text_result" t-as="user_input"> <tr class="hidden" t-foreach="text_result" t-as="user_input">
<td><t t-esc="user_input_index+1"></t></td> <td><a t-att-href="'%s/%s' % (user_input.user_input_id.print_url, user_input.user_input_id.token)"><t t-esc="user_input_index+1"></t></a></td>
<t t-if="question.type == 'free_text'"> <t t-if="question.type == 'free_text'">
<td> <td>
<span t-field="user_input.value_free_text"></span><br/> <span t-field="user_input.value_free_text"></span><br/>
<small><p t-field="user_input.date_create" class="fa fa-calendar oe_date text-muted"></p></small>
<span class="pull-right hidden-print">
<a t-att-href="'%s/%s' % (user_input.user_input_id.print_url, user_input.user_input_id.token)"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
</span>
</td> </td>
</t> </t>
<t t-if="question.type == 'textbox'"> <t t-if="question.type == 'textbox'">
<td> <td>
<span t-field="user_input.value_text"></span><br/> <span t-field="user_input.value_text"></span><br/>
<small><p t-field="user_input.date_create" class="fa fa-calendar oe_date text-muted"></p>
<span class="pull-right hidden-print">
<a t-att-href="'%s/%s' % (user_input.user_input_id.print_url, user_input.user_input_id.token)"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
</span>
</small>
</td> </td>
</t> </t>
<t t-if="question.type == 'datetime'"> <t t-if="question.type == 'datetime'">
<td> <td>
<span class="oe_date" t-field="user_input.value_date"></span><br/> <span class="oe_date" t-field="user_input.value_date"></span><br/>
<span class="pull-right hidden-print">
<a t-att-href="'%s/%s' % (user_input.user_input_id.print_url, user_input.user_input_id.token)"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
</span>
</td> </td>
</t> </t>
</tr> </tr>