summaryrefslogtreecommitdiff
path: root/addons/survey/static
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2018-11-26 17:04:31 +0100
committerDavid Beguin <dbe@odoo.com>2018-11-27 09:32:14 +0100
commit7d1c05216b318ea2a6bc3d991ff8aad6ea596e91 (patch)
treeff1a86ef3f0761b89878a555e3bf1f463081b662 /addons/survey/static
parent06e1a46c047bc98742016808872b599d7ba18a8d (diff)
[FIX] survey : apply min and max date configuration in survey page
The configuration of question of type 'Date' was not used at all. The datetimepicker configuration was hardcoded and did not take into account the configuration of questions of type 'Date'. Now, for each datetimepicker, we use the corresponding configuration for min and max date. Task ID : 1912194 Closes PR #28966
Diffstat (limited to 'addons/survey/static')
-rw-r--r--addons/survey/static/src/js/survey.js36
1 files changed, 20 insertions, 16 deletions
diff --git a/addons/survey/static/src/js/survey.js b/addons/survey/static/src/js/survey.js
index 6542f63a3dc..16def6107d2 100644
--- a/addons/survey/static/src/js/survey.js
+++ b/addons/survey/static/src/js/survey.js
@@ -183,22 +183,26 @@ if(!the_form.length) {
// frontend does not load moment locale at all.
// so wait until DOM ready with locale then init datetimepicker
ready_with_locale.then(function(){
- $('.input-group.date').datetimepicker({
- format : time.getLangDateFormat(),
- minDate: moment({ y: 1900 }),
- maxDate: moment().add(200, "y"),
- calendarWeeks: true,
- icons: {
- time: 'fa fa-clock-o',
- date: 'fa fa-calendar',
- next: 'fa fa-chevron-right',
- previous: 'fa fa-chevron-left',
- up: 'fa fa-chevron-up',
- down: 'fa fa-chevron-down',
- },
- locale : moment.locale(),
- allowInputToggle: true,
- keyBinds: null,
+ _.each($('.input-group.date'), function(date_field){
+ var minDate = $(date_field).data('mindate') || moment({ y: 1900 });
+ var maxDate = $(date_field).data('maxdate') || moment().add(200, "y");
+ $('#' + date_field.id).datetimepicker({
+ format : time.getLangDateFormat(),
+ minDate: minDate,
+ maxDate: maxDate,
+ calendarWeeks: true,
+ icons: {
+ time: 'fa fa-clock-o',
+ date: 'fa fa-calendar',
+ next: 'fa fa-chevron-right',
+ previous: 'fa fa-chevron-left',
+ up: 'fa fa-chevron-up',
+ down: 'fa fa-chevron-down',
+ },
+ locale : moment.locale(),
+ allowInputToggle: true,
+ keyBinds: null,
+ });
});
// Launch prefilling
prefill();