odoo/addons/survey/views/survey_templates.xml

263 lines
13 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- List of all the surveys -->
<template id="list" name="Survey List">
<t t-call="website.layout">
<div class="wrap">
<div class="container">
<h1>Open surveys</h1>
<div class="table-responsive">
<table class="table table-hover">
<tr><th>Title</th><th>Category</th><th>Description</th><th>Public URL</th></tr>
<t t-foreach="surveys" t-as="survey">
<tr>
<td><span t-field="survey.title" /></td>
<td><span t-field="survey.category"/></td>
<td><t t-if="survey.description is not False"><span t-field="survey.description"/></t></td>
<td><a t-att-href="survey.public_url"><t t-esc="survey.id" /></a></td>
</tr>
</t>
</table>
</div>
</div>
</div>
</t>
</template>
<!-- List of all the surveys -->
<template id="finished" name="Survey Finished">
<t t-call="website.layout">
<div class="wrap">
<div class="container">
<div class="jumbotron">
<h1>Thank you!</h1>
<p>Your answers have been recorded.</p>
</div>
</div>
</div>
</t>
</template>
<!-- A survey -->
<template id="survey" name="Survey">
<t t-call="website.layout">
<t t-set="head">
<script type="text/javascript" src="/survey/static/src/js/survey.js" />
</t>
<div class="wrap">
<div class="container">
<div class="row">
<div class="col-md-12">
<t t-if="pagination['current'] == -1">
<div class='jumbotron'>
<h1><span t-field='survey.title'/></h1>
<t t-if="survey.description"><p><span t-field='survey.description'/></p></t>
<form role="form" method="post" t-att-name="survey.id.__str__() + '---1'" t-att-action="'/survey/fill/' + survey.id.__str__()" target="">
<input type="hidden" name="current" t-att-value="pagination['current'].__str__()" />
<input type="hidden" name="next" t-att-value="pagination['next'].__str__()" />
<input type="submit" class="btn btn-primary btn-lg active" value="Take survey"/>
</form>
</div>
</t>
<t t-if="pagination['current'] != -1">
<t t-set='page' t-value="survey.page_ids[pagination['current']]" />
<t t-call="survey.page" />
</t>
</div>
</div>
</div>
</div>
</t>
</template>
<!-- Navigation & Submission -->
<template id="navsub" name="Footer for navigation and submission">
<div class="text-center">
<t t-if="pagination['current'] != -1 and pagination['next'] != 'finished'"><input type="submit" class="btn btn-primary active survey-btn" value="Next page"/></t>
<t t-if="pagination['next'] == 'finished'"><input type="submit" class="btn btn-success active survey-btn" value="Submit survey"/></t>
</div>
</template>
<!-- A page -->
<template id="page" name="Page">
<div class="page-header">
<h2><span t-field='page.title' /></h2>
<p><t t-if="page.description"><span t-field='page.description'/></t></p>
</div>
<!-- Panel to display input errors -->
<!-- <t t-if="problems">
<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title">Errors on this page</h3>
</div>
<div class="panel-body text-danger">
<ul>
<t t-foreach="problems" t-as='problem'>
<li><strong><t t-esc="problem['qlabel']"/> :</strong> <t t-esc="problem['errmsg']"/></li>
</t>
</ul>
</div>
</div>
</t> -->
<form role="form" method="post" t-att-name="survey.id.__str__() + '--' + pagination['current'].__str__()" t-att-action="'/survey/fill/' + survey.id.__str__()" target="">
<input type="hidden" name="current" t-att-value="pagination['current'].__str__()" />
<input type="hidden" name="next" t-att-value="pagination['next'].__str__()" />
<t t-foreach='page.question_ids' t-as='question'>
<t t-call='survey.question'/>
</t>
<t t-call='survey.navsub' />
</form>
</template>
<!-- A question -->
<template id='question' name='Question'>
<!-- Detection of matrix/vector elements and creating flags for easy use -->
<t t-if="question.parent_id and question.children_ids"><t t-set="is_matrix_vector" t-value="True" /></t>
<t t-if="question.parent_id"><t t-set="is_vector_element" t-value="True" /></t>
<div class="question-wrapper" t-att-id="'survey_' + survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question.id.__str__()" t-att-data-oe-survey-qparams='json.dumps({
"type": question.type,
"constr_mandatory": question.constr_mandatory,
"constr_type": question.constr_type,
"constr_maximum_req_ans": question.constr_maximum_req_ans,
"constr_minimum_req_ans": question.constr_minimum_req_ans,
"constr_error_msg": question.constr_error_msg
})'>
<t t-if="not is_vector_element"> <!-- if -->
<h3><span t-field='question.question' /> <t t-if="question.constr_mandatory"><abbr title="This question is mandatory." class="text-danger">*</abbr></t></h3>
<p class="text-muted"><t t-if="question.description"><span t-field='question.description'/></t></p>
</t>
<t t-if="is_vector_element"> <!-- else -->
<t t-if="question.type == 'simple_choice_scale'">
<span t-field='question.question' t-att-id="'survey_' + survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question.id.__str__()"/><t t-raw="'&lt;/td&gt;&lt;td&gt;'" />
</t>
</t> <!-- endif -->
<!-- instanciating different types of questions -->
<t t-if="question.type in ['free_text']">
<textarea class="form-control" rows="3" t-att-name="survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question.id.__str__()"></textarea>
</t>
<t t-if="question.type in ['textbox']">
<input type="text" class="form-control" t-att-name="survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question.id.__str__()"/>
</t>
<t t-if="question.type in ['numerical_box']">
<input type="number" step=".1" class="form-control" t-att-name="survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question.id.__str__()"/>
</t>
<t t-if="question.type in ['datetime']" >
<input type="datetime-local" class="form-control" t-att-name="survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question.id.__str__()" placeholder="jj-mm-aaaaThh:mm" />
TODO: replace html5 datetime widget by OpenERP-CMS datetime widget
</t>
<t t-if="question.type in ['simple_choice_scale']">
<t t-foreach='question.suggested_answers_ids' t-as='suggestion'>
<div class="radio">
<label>
<input type="radio" t-att-name="survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question.id.__str__()" t-att-value='suggestion.value' />
<span t-field='suggestion.value'/>
</label>
</div>
</t>
</t>
<t t-if="question.type in ['simple_choice_dropdown']">
<select class="form-control" t-att-name="survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question.id.__str__()">
<option disabled="1" selected="1">Choose...</option>
<t t-foreach='question.suggested_answers_ids' t-as='suggestion'>
<option><t t-esc='suggestion.value'/></option>
</t>
</select>
</t>
<t t-if="question.type in ['multiple_choice']">
<t t-foreach='question.suggested_answers_ids' t-as='suggestion'>
<div class="checkbox">
<label>
<input type="checkbox" t-att-name="survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question.id.__str__() + '--' + suggestion.id.__str__()" t-att-value='suggestion.value' />
<span t-field='suggestion.value'/>
</label>
</div>
</t>
</t>
<t t-if="question.type in ['vector']">
<t t-if="not is_matrix_vector">
<t t-raw="'&lt;table class=&quot;table table-responsive&quot;&gt;'" />
</t>
<t t-if="question.children_ids[0].type != 'simple_choice_scale'">
<tr>
<t t-foreach='question.children_ids' t-as='question'>
<td><t t-call='survey.question' /></td>
</t>
</tr>
</t>
<t t-if="question.children_ids[0].type == 'simple_choice_scale'">
<t t-foreach='question.children_ids' t-as='question'>
<tr>
<td><t t-call='survey.question' /></td>
</tr>
</t>
</t>
<t t-if="not is_matrix_vector">
<t t-raw="'&lt;/table&gt;'" />
</t>
</t>
<t t-if="question.type in ['matrix']">
<table class="table table-responsive">
<t t-foreach='question.children_ids' t-as='question'>
<t t-call='survey.question' />
</t>
</table>
</t>
<!-- Comments -->
<t t-if="question.comments_allowed">
Other: <input type="text" class="form-control" t-att-name="survey.id.__str__() + '--' + pagination['current'].__str__() + '--' + question."/>
</t>
<div class="js_errzone alert alert-danger" style="display:none;"></div>
</div>
</template>
<!-- Printable view of a survey (all pages) -->
<template id="survey_print" name="Survey">
<t t-call="website.layout">
<div class="wrap">
<div class="container">
<div class="row">
<div class='jumbotron'>
<h1><span t-field='survey.title'/></h1>
<t t-if="survey.description is not False"><p><span t-field='survey.description'/></p></t>
</div>
<t t-foreach="survey.page_ids" t-as="page">
<t t-call="survey.page" />
<hr/>
</t>
</div>
</div>
</div>
</t>
</template>
</data>
</openerp>