/************************************************* * Copyright (c) 2015 Ansible, Inc. * * All Rights Reserved *************************************************/ /** * @ngdoc function * @name forms.function:Questions * @description This form is for adding a question */ export default angular.module('SurveyQuestionFormDefinition', []) .value('SurveyQuestionForm', { addTitle: 'Add Question', editTitle: 'Edit Question', base: 'survey_question', name: 'survey_question', well: true, twoColumns: true, breadcrumbs: false, fields: { question_name: { realName: 'question_text', label: 'Name', type: 'text', addRequired: true, editRequired: true, column: 1, awSurveyQuestion: true }, question_description: { realName: 'question_description', label: 'Description', type: 'text', addRequired: false, editRequired: false, column: 1 }, variable: { ealName: 'variable', type: 'custom', control:''+ '
'+ '
Please enter an answer variable name.
'+ '
Please remove the illegal character from the survey question variable name.
'+ '
This question variable is already in use. Please enter a different variable name.
' + '
'+ '
', addRequired: true, editRequired: true, column: 1 }, type: { realName: 'answer_type', label: 'Answer Type', type: 'select', defaultText: 'Choose an answer type', ngOptions: 'answer_types.name for answer_types in answer_types track by answer_types.type', addRequired: true, editRequired: true, column: 2, ngChange: 'typeChange()' }, choices: { realName: 'answer_options', label: 'Multiple Choice Options', type: 'textarea', rows: 3, addRequired: true, editRequired: true, ngRequired: "type.type=== 'multiselect' || type.type=== 'multiplechoice' " , ngShow: 'type.type=== "multiselect" || type.type=== "multiplechoice" ', awPopOver: '

Type an option on each line.

'+ '

For example the following input:

Apple
\n Banana
\n Cherry

would be displayed as:

\n'+ '
  1. Apple
  2. Banana
  3. Cherry
', dataTitle: 'Multiple Choice Options', dataPlacement: 'right', dataContainer: "body", column: 2 }, text_options: { realName: 'answer_options', type: 'custom', control:'
'+ '
'+ ''+ '
The minimum length you entered is not a valid number. Please enter a whole number.
'+ '
The minimium length is too high. Please enter a lower number.
'+ '
The minimum length is too low. Please enter a positive number.
'+ '
'+ '
'+ ''+ '
The maximum length you entered is not a valid number. Please enter a whole nnumber.
'+ '
The maximum length is too low. Please enter a number larger than the minimum length you set.
'+ '
'+ '
', ngShow: 'type.type==="text" ', addRequired: true, editRequired: true, column: 2 }, textarea_options: { realName: 'answer_options', type: 'custom', control:'
'+ '
'+ ''+ '
The minimum length you entered is not a valid number. Please enter a whole number.
'+ '
The minimium length is too high. Please enter a lower number.
'+ '
The minimum length is too low. Please enter a positive number.
'+ '
'+ '
'+ ''+ '
The maximum length you entered is not a valid number. Please enter a whole number.
'+ '
The maximum length is too low. Please enter a number larger than the minimum length you set.
'+ '
'+ '
', ngShow: 'type.type==="textarea" ', addRequired: true, editRequired: true, column: 2 }, password_options: { realName: 'answer_options', type: 'custom', control:'
'+ '
'+ ''+ '
The minimum length you entered is not a valid number. Please enter a whole number.
'+ '
The minimium length is too high. Please enter a lower number.
'+ '
The minimum length is too low. Please enter a positive number.
'+ '
'+ '
'+ ''+ '
The maximum length you entered is not a valid number. Please enter a whole number.
'+ '
The maximum length is too low. Please enter a number larger than the minimum length you set.
'+ '
'+ '
', ngShow: 'type.type==="password" ', addRequired: true, editRequired: true, column: 2 }, int_options: { realName: 'answer_options', type: 'custom', control:'
'+ '
'+ ''+ '
Please enter a valid integer.
'+ '
Please enter a smaller integer.
'+ '
'+ '
'+ ''+ '
Please enter a valid integer.
'+ '
Please enter a larger integer.
'+ '
'+ '
', ngShow: 'type.type==="integer" ', addRequired: true, editRequired: true, column: 2 }, float_options: { realName: 'answer_options', type: 'custom', control: '
'+ '
'+ ''+ '
Please enter a valid float.
'+ '
Please enter a smaller float.
'+ '
'+ '
'+ ''+ '
Please enter a valid float.
'+ '
Please enter a larger float.
'+ '
'+ '
', ngShow: 'type.type==="float" ', addRequired: true, editRequired: true, column: 2 }, default:{ realName: 'default_answer', type: 'custom' , control: '
'+ ''+ '
'+ ''+ '
Please enter an answer from the choices listed.
' + '
The answer is shorter than the minimium length. Please make the answer longer.
' + '
The answer is longer than the maximum length. Please make the answer shorter.
' + '
'+ '
'+ '
', column: 2, ngShow: 'type.type === "text" || type.type === "multiplechoice" ' }, default_multiselect: { realName: 'default_answer' , type: 'custom', control: '
'+ ''+ '
'+ ''+ '
Please enter an answer/answers from the choices listed.
' + '
'+ '
'+ '
', column: 2, ngShow: 'type.type==="multiselect" ' }, default_int: { realName: 'default_answer', type: 'custom', control: '
'+ ''+ ''+ '
Please enter a valid integer.
'+ '
Please enter a value in the range of {{int_min}} to {{int_max}}.
'+ '
', column: 2, ngShow: 'type.type === "integer" ' }, default_float: { realName: 'default_answer', type: 'custom', control: '
'+ ''+ ''+ '
Please enter a valid float.
'+ '
Please enter a value in the range of {{float_min}} to {{float_max}}!
'+ '
', column: 2, ngShow: 'type.type=== "float" ' }, default_textarea: { realName: "default_answer" , type: 'custom', control: '
'+ ''+ '
'+ ''+ '
The answer is shorter than the minimium length. Please make the answer longer.
' + '
The answer is longer than the maximum length. Please make the answer shorter.
' + '
'+ '
'+ '
', column : 2, ngShow: 'type.type === "textarea" ' }, default_password: { realName: 'default_answer' , type: 'custom' , control: '
'+ ''+ '
'+ '
'+ ''+ ''+ ''+ ''+ '
'+ '
The answer is shorter than the minimium length. Please make the answer longer.
' + '
The answer is longer than the maximum length. Please make the answer shorter.
' + '
'+ '
'+ '
', column: 2, ngShow: 'type.type === "password" ' }, required: { realName: 'required_answer', label: 'Required', type: 'checkbox', addRequired: false, editRequired: false, column: 2 } }, buttons: { question_cancel : { label: 'Cancel', 'class' : 'btn btn-default', ngClick: 'cancelQuestion($event)' }, submit_question: { ngClick: 'submitQuestion($event)', ngDisabled: true, 'class': 'btn btn-sm btn-primary', label: 'Add Question' } } });