diff --git a/addons/survey/static/src/js/survey.js b/addons/survey/static/src/js/survey.js index 72ee3c7945c..f14c8af4460 100644 --- a/addons/survey/static/src/js/survey.js +++ b/addons/survey/static/src/js/survey.js @@ -2,6 +2,27 @@ $(document).ready(function () { console.debug("[survey] Custom JS for survey is loading..."); + // Custom code for right behavior of radio buttons with comments box + $('.js_comments>input[type="text"]').focusin(function(){ + $(this).prev().find('>input').attr("checked","checked"); + }); + $('.js_radio input[type="radio"][data-oe-survey-otherr!="1"]').click(function(){ + $(this).closest('.js_radio').find('.js_comments>input[type="text"]').val(""); + }); + $('.js_comments input[type="radio"]').click(function(){ + $(this).closest('.js_comments').find('>input[data-oe-survey-othert="1"]').focus(); + }); + // Custom code for right behavior of dropdown menu with comments + $('.js_drop input[data-oe-survey-othert="1"]').hide(); + $('.js_drop select').change(function(){ + if($(this).val() === "Other..."){ + $(this).closest('.js_drop').find('input[data-oe-survey-othert="1"]').show().focus(); + } + else{ + $(this).closest('.js_drop').find('input[data-oe-survey-othert="1"]').val("").hide(); + } + }); + var the_form = $('.js_surveyform'); var prefill_controller = the_form.attr("data-prefill"); var validate_controller = the_form.attr("data-validate"); @@ -15,10 +36,6 @@ $(document).ready(function () { // return false; // } - // function submit(form){ - // return false; - // } - // Parameters for form submission $('.js_surveyform').ajaxForm({ url: submit_controller, @@ -52,4 +69,4 @@ $(document).ready(function () { console.debug("[survey] Custom JS for survey loaded!"); -}); \ No newline at end of file +}); diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 67339d3b0b6..67c6fbf7882 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -333,7 +333,8 @@ class survey_question(osv.osv): ondelete='cascade'), 'survey_id': fields.related('page_id', 'survey_id', type='many2one', relation='survey.survey', string='Survey', store=True), - 'parent_id': fields.many2one('survey.question', 'Parent question'), + 'parent_id': fields.many2one('survey.question', 'Parent question', + ondelete='cascade'), 'children_ids': fields.one2many('survey.question', 'parent_id', 'Children questions'), 'sequence': fields.integer(string='Sequence'), @@ -356,18 +357,17 @@ class survey_question(osv.osv): 'question_id', 'Suggested answers', oldname='answer_choice_ids'), # Display options - 'simple_choice_display' : fields.selection([('1col', 'Buttons (1 column)'), - ('2col', 'Buttons (2 columns)'), - ('3col', 'Buttons (3 columns)'), - ('horizontal', 'Buttons (horizontal)'), - ('dropdown', 'Dropdown menu'),], - 'Display mode', ), + 'simple_choice_display': fields.selection([('1col', '1 column choices'), + ('2col', '2 columns choices'), + ('3col', '3 columns choices'), + ('horizontal', 'Horizontal choices'), + ('dropdown', 'Dropdown menu')], 'Display mode'), # Comments 'comments_allowed': fields.boolean('Allow comments', oldname="allow_comment"), - #'comment_children_ids': fields.one2many('survey.question_id', - # 'parent_id', 'Comment question'), # one2one in fact + 'comment_children_ids': fields.one2many('survey.question', + 'parent_id', 'Comment question'), # one2one in fact 'comment_count_as_answer': fields.boolean('Comment field is an answer choice', oldname='make_comment_field'), @@ -416,7 +416,7 @@ class survey_question(osv.osv): 'constr_error_msg': lambda s, cr, uid, c: _('This question requires an answer.'), 'validation_error_msg': lambda s, cr, uid, c: _('The answer you entered has an invalid format.'), - 'validation_required': 'False', + 'validation_required': False, } _sql_constraints = [ ('positive_len_min', 'CHECK (validation_length_min >= 0)', 'A length must be positive!'), @@ -542,12 +542,12 @@ class survey_label(osv.osv): ''' A suggested answer for a question ''' _name = 'survey.label' _rec_name = 'value' + _order = 'sequence' _columns = { - #'survey_id': fields.related('page_id', 'survey_id', type='many2one', - # relation='survey.survey', string='Survey', store=True), 'question_id': fields.many2one('survey.question', 'Question', required=True, ondelete='cascade'), + 'sequence': fields.integer('Page number'), 'value': fields.char("Suggested value", length=128, translate=True, required=True) } diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index da9d2fd3eae..a05cbc675dd 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -397,19 +397,20 @@ - + + + - @@ -419,7 +420,7 @@ - + @@ -444,15 +445,15 @@ - + - + - + @@ -468,9 +469,13 @@ + + + + + - diff --git a/addons/survey/views/survey_templates.xml b/addons/survey/views/survey_templates.xml index a0a486e5391..0d858857dad 100644 --- a/addons/survey/views/survey_templates.xml +++ b/addons/survey/views/survey_templates.xml @@ -107,13 +107,14 @@ -
+
+ - - - -
@@ -190,29 +177,54 @@ + +