[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
This commit is contained in:
David Beguin
2018-11-27 09:32:14 +01:00
parent 06e1a46c04
commit 7d1c05216b
2 changed files with 23 additions and 17 deletions
+20 -16
View File
@@ -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();
+3 -1
View File
@@ -238,7 +238,9 @@
<template id="date" name="Date box">
<div class="form-group">
<div class="input-group date" t-attf-id="datetimepicker_#{question.id}" data-target-input="nearest">
<div class="input-group date" t-attf-id="datetimepicker_#{question.id}" data-target-input="nearest"
t-att-data-mindate="question.validation_min_date"
t-att-data-maxdate="question.validation_max_date">
<input type="text" class="form-control datetimepicker-input" t-attf-data-target="#datetimepicker_#{question.id}" t-att-name="prefix"/>
<div class="input-group-append" t-attf-data-target="#datetimepicker_#{question.id}" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>