From de4135305c35cb2cc6d5236495a64ac41c8ed132 Mon Sep 17 00:00:00 2001 From: Ajay Patel Date: Thu, 4 Dec 2014 15:18:26 +0530 Subject: [PATCH] [IMP] survey: usability onboarding Various views and usability tweaks: - datetime picker in surveys - remove technical field res_model for survey - various relabelling - better validation of date constraints - onchange when email validation - button to the backend in survey frontends - icons in questions form views --- .../hr_evaluation/survey_data_appraisal.xml | 2 - .../survey_data_recruitment.xml | 1 - addons/survey/static/description/icon.png | Bin 0 -> 2334 bytes .../survey/static/src/css/survey_result.css | 21 ++++ addons/survey/static/src/js/survey.js | 13 +++ addons/survey/survey.py | 26 +++-- addons/survey/views/survey_result.xml | 8 +- addons/survey/views/survey_templates.xml | 23 ++-- addons/survey/views/survey_views.xml | 110 +++++++++++++++--- addons/web/views/webclient_templates.xml | 8 +- 10 files changed, 175 insertions(+), 37 deletions(-) create mode 100644 addons/survey/static/description/icon.png diff --git a/addons/hr_evaluation/survey_data_appraisal.xml b/addons/hr_evaluation/survey_data_appraisal.xml index d48326116c1..258d421859b 100644 --- a/addons/hr_evaluation/survey_data_appraisal.xml +++ b/addons/hr_evaluation/survey_data_appraisal.xml @@ -5,7 +5,6 @@ Employee Appraisal Form - hr_evaluation <p> </p> @@ -320,7 +319,6 @@ over the coming year.</p> Employee Opinion Form - hr_evaluation <p> </p> diff --git a/addons/hr_recruitment/survey_data_recruitment.xml b/addons/hr_recruitment/survey_data_recruitment.xml index f6aacb0f23c..0e5eb82dabc 100644 --- a/addons/hr_recruitment/survey_data_recruitment.xml +++ b/addons/hr_recruitment/survey_data_recruitment.xml @@ -5,7 +5,6 @@ Recruitment Form - hr_recruitment <p>This form is intended to help the responsible of a recruitment interview.</p> diff --git a/addons/survey/static/description/icon.png b/addons/survey/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..dece1016d57bc4296537e428ecd04a46b7496dd1 GIT binary patch literal 2334 zcmZ{mdpy(a8^^yG<`_B4DSApmsAR~gIVB7eA<-~$%p68yj*TW%`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_SR0&Mk~Lxe*iNIO!5E# literal 0 HcmV?d00001 diff --git a/addons/survey/static/src/css/survey_result.css b/addons/survey/static/src/css/survey_result.css index 9762bc3866f..967ea1bd74e 100644 --- a/addons/survey/static/src/css/survey_result.css +++ b/addons/survey/static/src/css/survey_result.css @@ -51,3 +51,24 @@ width: 1150px; } } + +.o_preview_questions { + border: 3px solid #C9C6C6; + width: auto; + padding: 10px 30px 5px; + margin-top: 15px; + color: #C9C6C6; +} + +.o_preview_questions .o_datetime { + border: 1px solid #D8D7D7; + margin-bottom: 5px; +} + +.o_preview_questions .o_matrix_head { + border-bottom: 1px solid #D8D7D7; +} + +.o_preview_questions .o_matrix_row { + border-top: 1px solid #D8D7D7; +} diff --git a/addons/survey/static/src/js/survey.js b/addons/survey/static/src/js/survey.js index 778bc24ea3d..02ddcd9547d 100644 --- a/addons/survey/static/src/js/survey.js +++ b/addons/survey/static/src/js/survey.js @@ -35,6 +35,7 @@ openerp.website.if_dom_contains('.js_surveyform', function (the_form) { // Printing mode: will disable all the controls in the form if (_.isUndefined(submit_controller)) { + $(".js_surveyform .input-group-addon span.fa-calendar").css("pointer-events", "none"); $('.js_surveyform :input').prop('disabled', true); print_mode = true; } @@ -44,6 +45,18 @@ openerp.website.if_dom_contains('.js_surveyform', function (the_form) { quiz_correction_mode = true; } + $("div.input-group span.fa-calendar").on('click', function(e) { + $(e.currentTarget).closest("div.date").datetimepicker({ + useSeconds: true, + icons : { + time: 'fa fa-clock-o', + date: 'fa fa-calendar', + up: 'fa fa-chevron-up', + down: 'fa fa-chevron-down' + }, + }); + }); + // 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"); diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 612ce78abfa..ec961b9bd2c 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -168,7 +168,6 @@ class survey_survey(osv.Model): _columns = { 'title': fields.char('Title', required=1, translate=True), - 'res_model': fields.char('Category'), 'page_ids': fields.one2many('survey.page', 'survey_id', 'Pages', copy=True), 'stage_id': fields.many2one('survey.stage', string="Stage", ondelete="set null", copy=False), 'auth_required': fields.boolean('Login required', @@ -573,8 +572,8 @@ class survey_question(osv.Model): oldname='descriptive_text'), # Answer - 'type': fields.selection([('free_text', 'Long Text Zone'), - ('textbox', 'Text Input'), + 'type': fields.selection([('free_text', 'Multiple Lines Text Box'), + ('textbox', 'Single Line Text Box'), ('numerical_box', 'Numerical Value'), ('datetime', 'Date and Time'), ('simple_choice', 'Multiple choice: only one answer'), @@ -601,7 +600,7 @@ class survey_question(osv.Model): ('2', '6')], 'Number of columns'), # These options refer to col-xx-[12|6|4|3|2] classes in Bootstrap - 'display_mode': fields.selection([('columns', 'Radio Buttons/Checkboxes'), + 'display_mode': fields.selection([('columns', 'Radio Buttons'), ('dropdown', 'Selection Box')], 'Display mode'), @@ -657,6 +656,9 @@ class survey_question(osv.Model): ('validation_date', 'CHECK (validation_min_date <= validation_max_date)', 'Max date cannot be smaller than min date!') ] + def onchange_validation_email(self, cr, uid, ids, validation_email, context=None): + return {'value': {'validation_required': False}} if validation_email else {} + def copy_data(self, cr, uid, ids, default=None, context=None): current_rec = self.read(cr, uid, ids, context=context) question = _("%s (copy)") % (current_rec.get('question')) @@ -746,7 +748,17 @@ class survey_question(osv.Model): # Answer is not in the right range try: dateanswer = datetime.datetime.strptime(answer, DF) - if not (datetime.datetime.strptime(question.validation_min_date, DF) <= dateanswer <= datetime.datetime.strptime(question.validation_max_date, DF)): + min_date = question.validation_min_date and datetime.datetime.strptime(question.validation_min_date, DF) or False + max_date = question.validation_max_date and datetime.datetime.strptime(question.validation_max_date, DF) or False + + if (min_date and max_date and not(min_date <= dateanswer <= max_date)): + # If Minimum and Maximum Date are entered + errors.update({answer_tag: question.validation_error_msg}) + elif (min_date and not(min_date <= dateanswer)): + # If only Minimum Date is entered and not Define Maximum Date + errors.update({answer_tag: question.validation_error_msg}) + elif (max_date and not(dateanswer <= max_date)): + # If only Maximum Date is entered and not Define Minimum Date errors.update({answer_tag: question.validation_error_msg}) except ValueError: # check that it is a datetime has been done hereunder pass @@ -821,7 +833,7 @@ class survey_label(osv.Model): 'sequence': fields.integer('Label Sequence order'), 'value': fields.char("Suggested value", translate=True, required=True), - 'quizz_mark': fields.float('Score for this answer', help="A positive score indicates a correct answer; a negative or null score indicates a wrong answer"), + 'quizz_mark': fields.float('Score for this choice', help="A positive score indicates a correct choice; a negative or null score indicates a wrong answer"), } _defaults = { 'sequence': 10, @@ -990,7 +1002,7 @@ class survey_user_input_line(osv.Model): 'value_free_text': fields.text("Free Text answer"), 'value_suggested': fields.many2one('survey.label', "Suggested answer"), 'value_suggested_row': fields.many2one('survey.label', "Row answer"), - 'quizz_mark': fields.float("Score given for this answer") + 'quizz_mark': fields.float("Score given for this choice") } _defaults = { diff --git a/addons/survey/views/survey_result.xml b/addons/survey/views/survey_result.xml index bc49f800832..deea5d19b47 100644 --- a/addons/survey/views/survey_result.xml +++ b/addons/survey/views/survey_result.xml @@ -14,6 +14,7 @@
+

@@ -98,17 +99,17 @@ -
+
-
+
-
+
@@ -326,6 +327,7 @@ + + +