Daily updates from Odoo
Tuesday, November 19, 2019
1 change
Code cleanup and technical improvements
The survey app’s behind-the-scenes flow for saving answers, moving between pages, timing tests, and viewing results has been modernized. This should make surveys more reliable for participants and easier to maintain, while reducing unnecessary server calls.
Original PR description
PURPOSE Purpose of this PR is to standardize and update JS code of the survey application. It impacts mainly save, pagination and validation flows when taking surveys. Python code will have to be…
PURPOSE
Purpose of this PR is to standardize and update JS code of the survey
application. It impacts mainly save, pagination and validation flows
when taking surveys.
Python code will have to be adapted consequently.
SPECIFICATIONS: UDPATE WIDGETS
Update JS code remove global selectors / global JS and use standard
widgets. Lessen number of RPCs and clean old code for prefilling and
validation of surveys.
Contains update of notably
* Survey Form: make it a real widget calling routes in RPC and
doing some validation;
* Prefill is now handled in the template instead of in js controller;
* Submit is now done in json rpc;
* Survey Timer: make timer a real widget;
* Survey Result Analysis: make result, graph and pagifation
real widgets;
* Charts handling have been externalised in a sub widget;
* Pagination have been externalised in a sub widget;
Clean Prefill: prefill can be done directly in the template as the template
has already all the needed values (in answer object).
Clean Validation: validation is done at server side and is independent
from prefilling values.
Dates: dates are now formatted directly in the template at rendering using
a format_date fonction pointer called in the template.
Don't use widget in review mode: remove o_survey_form class from review
template as only dates were processed in the widget for review template.
Breadcrumb: remove button previous, prev=prev and go_back mechanism.
The previous page is handled by the breadcrump. Remove redirect url
mechanism. Breadcrumb now saves the answers when going to a previous page.
Move o_survey_form class to a higher div to englobe breadcrumb in the widget
and ease his handling.
Modify the route type of survey submit to work in json. The js survey form
controller calls now manually the route via rpc.
SPECIFICATIONS: UDPATE CONTROLLERS
Refactor questions naming, validation and save flow. Simplify the answer_tag
and question name by removing the survey_id (uses now only question id)
for the most simple cases.
Factorise the save and validate survey answers to avoid duplicate code.
Review posted submit data :
* process all questions by question type (instead of using form data
(key,value) that needed key parsing and was un-typed)
* regroup answers by questions and adapt all validation and save flow
* remove post data in save and validate question methods
and uses directly the answer(s)
* remove useless input names
Validation and submit functions have been rewritten to avoid
duplicated code as many question types have quite the same
validation and save process.
SPECIFICATIONS: MISC
Partial Forward Port : Web assets have been split into another
template to avoid multiple load of those assets when website is
installed.
Also reset is_time_limited on scoring type change.
Also remove locale load as already done in session.js#load_modules
See sub commits for more details.
Task ID 1930132
Closes PR #32419