From 25ecd6326d4d74a833af09486068ff8c05b2c39e Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 8 Oct 2014 11:58:46 -0400 Subject: [PATCH] adding directives to integer min/max and integer default answer fields this was supposed to be included in the last commit --- awx/ui/static/js/forms/SurveyQuestion.js | 162 +++++++++++------------ 1 file changed, 74 insertions(+), 88 deletions(-) diff --git a/awx/ui/static/js/forms/SurveyQuestion.js b/awx/ui/static/js/forms/SurveyQuestion.js index 81d1f8a257..2217e1316c 100644 --- a/awx/ui/static/js/forms/SurveyQuestion.js +++ b/awx/ui/static/js/forms/SurveyQuestion.js @@ -15,22 +15,12 @@ angular.module('SurveyQuestionFormDefinition', []) .value('SurveyQuestionForm', { addTitle: 'Add Question', - // editTitle: '{{ survey_name }}', + editTitle: 'Edit Question', + base: 'survey_question', name: 'survey_question', well: true, twoColumns: true, - - // actions: { - // stream: { - // 'class': "btn-primary btn-xs activity-btn", - // ngClick: "showActivity()", - // awToolTip: "View Activity Stream", - // dataPlacement: "top", - // icon: "icon-comments-alt", - // mode: 'edit', - // iconSize: 'large' - // } - // }, + breadcrumbs: false, fields: { question_name: { @@ -57,13 +47,6 @@ angular.module('SurveyQuestionFormDefinition', []) addRequired: true, editRequired: true, column: 1 - // sourceModel: 'organization', - // sourceField: 'name', - // ngClick: 'lookUpOrganization()', - // awRequiredWhen: { - // variable: "organizationrequired", - // init: "true" - // } }, type: { realName: 'answer_type', @@ -75,15 +58,6 @@ angular.module('SurveyQuestionFormDefinition', []) column: 2 }, - // answer_options_text: { - // realName: 'answer_options', - // label: 'Answer Options', - // type: 'text', - // addRequired: true, - // editRequired: true, - // ngHide: 'answer_type.type!=="text" ', - // column: 1 - // }, choices: { realName: 'answer_options', label: 'Multiple Choice Options', @@ -91,41 +65,52 @@ angular.module('SurveyQuestionFormDefinition', []) rows: 3, addRequired: true, editRequired: true, - ngShow: 'type.type==="multiselect" || type.type==="multiplechoice" ', + 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
    1. ', + '
      1. Apple
      2. Banana
      3. Cherry
      ', dataTitle: 'Multiple Choice Options', dataPlacement: 'right', dataContainer: "body", column: 2 }, - answer_options_number: { + int_options: { realName: 'answer_options', - // label: 'Answer Options', type: 'custom', - control: '
      '+ - '
      '+ - '
      ', - ngShow: 'type.type==="integer" || type.type==="float" ', + control:'
      '+ + '
      '+ + ''+ + '
      This is not valid integer!
      '+ + '
      '+ + '
      '+ + ''+ + '
      This is not valid integer!
      '+ + '
      '+ + '
      ', + ngShow: 'type.type==="integer" ', + addRequired: true, + editRequired: true, + column: 2 + }, + float_options: { + realName: 'answer_options', + type: 'custom', + control: '
      '+ + '
      '+ + ''+ + '
      This is not valid integer!
      '+ + '
      '+ + '
      '+ + ''+ + '
      This is not valid integer!
      '+ + '
      '+ + '
      ', + ngShow: 'type.type==="float" ', addRequired: true, editRequired: true, column: 2 }, - // answer_options_json: { - // realName: 'answer_options', - // label: 'Answer Options', - // type: 'textarea', - // rows: 3, - // ngShow: 'type.type==="json" ', - // addRequired: true, - // editRequired: true, - // awPopOver: '

      Insert some good JSON!

      ', - // dataTitle: 'Answer Options', - // dataPlacement: 'right', - // dataContainer: "body", - // column: 1 - // }, default: { realName: 'default_answer', label: 'Default Answer', @@ -148,8 +133,42 @@ angular.module('SurveyQuestionFormDefinition', []) default_int: { realName: 'default_answer', type: 'custom', - control: '
      '+ - '
      ', + control: '
      '+ + ''+ + ''+ + '
      This is not valid integer!
      '+ + '
      The value must be in range {{int_min}} to {{int_max}}!
      '+ + // 'value = {{default_int}}
      '+ + // 'value.$valid = {{survey_question_form.default_int.$valid}}'+ + '
      ', + + // '
      '+ + // '
      '+ + // '
      '+ + // '
      This is not valid integer!
      ', + + + // '
      '+ + // '
      '+ + + // '
      This is not valid integer!
      '+ + // // '
      '+ + // '
      '+ + // '
      ', + + + + + + + + //
      + // + //
      A value is required!
      + //
      + //
      + column: 2, ngShow: 'type.type === "integer" ' }, @@ -175,51 +194,18 @@ angular.module('SurveyQuestionFormDefinition', []) realName: 'required_answer', label: 'Required', type: 'checkbox', - // checked: true, addRequired: false, editRequired: false, - column: 2, - // trueValue: true, - // falseValue: false - // label: 'Answer required or optional', - // type: 'custom', - // column: 2, - // control: '
      '+ - // '
      ', - + column: 2 } - // answer_options: { - // label: 'Variables', - // type: 'textarea', - // 'class': 'span12', - // addRequired: false, - // editRequird: false, - // rows: 6, - // "default": "---", - // awPopOver: "

      Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two.

      " + - // "JSON:
      \n" + - // "
      {
      \"somevar\": \"somevalue\",
      \"password\": \"magic\"
      }
      \n" + - // "YAML:
      \n" + - // "
      ---
      somevar: somevalue
      password: magic
      \n" + - // '

      View JSON examples at www.json.org

      ' + - // '

      View YAML examples at docs.ansible.com

      ', - // dataTitle: 'Inventory Variables', - // dataPlacement: 'right', - // dataContainer: 'body' - // } - // }, }, buttons: { submit_question: { ngClick: 'submitQuestion()', - ngDisabled: "!question_name || !variable || !type || ((type.type==='multiplechoice' || type.type === 'multiselect' ) && !choices)", //|| type.type===multiselect ',//'!question_name || !variable || !type' , + ngDisabled: true, //'survey_question.$valid', //"!question_name || !variable || !type || ((type.type==='multiplechoice' || type.type === 'multiselect' ) && !choices)", //|| type.type===multiselect ',//'!question_name || !variable || !type' , 'class': 'btn btn-sm btn-primary', label: 'Submit Question' } - }, - - related: { - } }); \ No newline at end of file