From 0778e93f4980c1116e996a91e12dd7c16c657422 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 3 Jun 2015 17:52:19 -0400 Subject: [PATCH 1/3] Survey maker -> default password input replacement turning the default password input on survey maker to use the new schema --- awx/ui/static/js/forms/SurveyQuestion.js | 36 ++++++++++++++++++------ awx/ui/static/js/helpers/Survey.js | 16 ++++++++++- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/awx/ui/static/js/forms/SurveyQuestion.js b/awx/ui/static/js/forms/SurveyQuestion.js index 523dff3a2a..3d3cb80819 100644 --- a/awx/ui/static/js/forms/SurveyQuestion.js +++ b/awx/ui/static/js/forms/SurveyQuestion.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + /** * @ngdoc function * @name forms.function:Questions @@ -274,17 +274,35 @@ export default default_password: { realName: 'default_answer' , type: 'custom' , - control: '
'+ - ''+ + 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.
' + - '
'+ + '
'+ + ''+ + ''+ + ''+ + ''+ + '
'+ + '
'+ + '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.
'+ + '
'+ '
'+ '
', + + // 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" ' }, diff --git a/awx/ui/static/js/helpers/Survey.js b/awx/ui/static/js/helpers/Survey.js index 5e740ea7c4..bf008a2135 100644 --- a/awx/ui/static/js/helpers/Survey.js +++ b/awx/ui/static/js/helpers/Survey.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + /** * @ngdoc function * @name helpers.function:Survey @@ -1027,5 +1027,19 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', } }; + //for toggling the input on password inputs + scope.toggleInput = function(id) { + var buttonId = id + "_show_input_button", + inputId = id, + buttonInnerHTML = $(buttonId).html(); + if (buttonInnerHTML.indexOf("ABC") > -1) { + $(buttonId).html(""); + $(inputId).attr("type", "text"); + } else { + $(buttonId).html("ABC"); + $(inputId).attr("type", "password"); + } + }; + }; }]); From 96659ac6577b0d9c5755c53b53c1ee14b779e37f Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Thu, 4 Jun 2015 10:31:53 -0400 Subject: [PATCH 2/3] Default multiplechoice answer fix the default answer for a multiplechoice question was not saving correctly. --- awx/ui/static/js/forms.js | 2 - awx/ui/static/js/forms/SurveyMaker.js | 70 ----------------------- awx/ui/static/js/forms/SurveyQuestion.js | 40 ++----------- awx/ui/static/js/helpers/JobSubmission.js | 8 ++- awx/ui/static/js/helpers/Survey.js | 11 ++-- awx/ui/static/less/survey-maker.less | 13 +---- 6 files changed, 19 insertions(+), 125 deletions(-) delete mode 100644 awx/ui/static/js/forms/SurveyMaker.js diff --git a/awx/ui/static/js/forms.js b/awx/ui/static/js/forms.js index 031b77e5a4..7f619d8d39 100644 --- a/awx/ui/static/js/forms.js +++ b/awx/ui/static/js/forms.js @@ -28,7 +28,6 @@ import Permissions from "tower/forms/Permissions"; import ProjectStatus from "tower/forms/ProjectStatus"; import Projects from "tower/forms/Projects"; import Source from "tower/forms/Source"; -import SurveyMaker from "tower/forms/SurveyMaker"; import SurveyQuestion from "tower/forms/SurveyQuestion"; import Teams from "tower/forms/Teams"; import Users from "tower/forms/Users"; @@ -59,7 +58,6 @@ export ProjectStatus, Projects, Source, - SurveyMaker, SurveyQuestion, Teams, Users diff --git a/awx/ui/static/js/forms/SurveyMaker.js b/awx/ui/static/js/forms/SurveyMaker.js deleted file mode 100644 index 3565d045c4..0000000000 --- a/awx/ui/static/js/forms/SurveyMaker.js +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************* - * Copyright (c) 2015 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - - /** - * @ngdoc function - * @name forms.function:SurveyMaker - * @description This form is for adding/editing a survey -*/ - -export default - angular.module('SurveyMakerFormDefinition', []) - .value('SurveyMakerForm', { - - addTitle: 'Add Survey', //Title in add mode - editTitle: 'Edit Survey', //Title in edit mode - name: 'survey_maker', //entity or model name in singular form - // // well: true, - breadCrumbs: false, - - - fields: { - survey_name: { - type: 'custom', - control: '
'+ - // '
- //
'+ - // ' - //
'+ - // ''+ - // '
Please enter a survey name.
'+ - // '
'+ - // '
'+ - // '
'+ - // '
'+ - // ''+ - // '
'+ - // '
'+ - '
'+ - ''+ - '
'+ - '
'+ - ''+ - '
'+ - '
'+ - '
'//
' - // label: 'Survey Name', - // type: 'text', - // addRequired: true, - // editRequired: true, - // capitalize: false, - // // column: 1 - }, - - }, - - // buttons: { //for now always generates '+ ''+ - ''+ + ''+ ''+ - '
'+ - '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.
'+ - '
'+ + '
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.
' + + '
'+ ''+ '', - - // 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" ' }, @@ -323,7 +295,7 @@ export default }, submit_question: { ngClick: 'submitQuestion($event)', - ngDisabled: true, //'survey_question.$valid', //"!question_name || !variable || !type || ((type.type==='multiplechoice' || type.type === 'multiselect' ) && !choices)", //|| type.type===multiselect ',//'!question_name || !variable || !type' , + ngDisabled: true, 'class': 'btn btn-sm btn-primary', label: 'Add Question' } diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js index 30cf5cacf7..52f2bcccc7 100644 --- a/awx/ui/static/js/helpers/JobSubmission.js +++ b/awx/ui/static/js/helpers/JobSubmission.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + /** * @ngdoc function * @name helpers.function:JobSubmission @@ -526,8 +526,10 @@ function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm, requiredAsterisk = (question.required===true) ? "prepend-asterisk" : ""; requiredClasses = (question.required===true) ? "ng-pristine ng-invalid-required ng-invalid" : ""; - html+='
'; - html += '\n'; + html+='
'; + html += ''; + + // html += '\n'; if(!Empty(question.question_description)){ html += '
'+question.question_description+'
\n'; diff --git a/awx/ui/static/js/helpers/Survey.js b/awx/ui/static/js/helpers/Survey.js index bf008a2135..78af9d3a7f 100644 --- a/awx/ui/static/js/helpers/Survey.js +++ b/awx/ui/static/js/helpers/Survey.js @@ -285,7 +285,10 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', } required = (question.required===true) ? "prepend-asterisk" : ""; - html = '
'+question.question_name+'
\n'; + html = '
'; + html += ''; + html += '
'; + if(!Empty(question.question_description)){ html += '
'+question.question_description+'
\n'; } @@ -326,7 +329,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', if(question.type === 'password'){ defaultValue = (question.default) ? question.default : ""; - defaultValue = $filter('defaultValue')(choices[i]); + defaultValue = $filter('sanitize')(defaultValue); defaultValue = scope.serialize(defaultValue); html+='
'+ '
'+ @@ -925,7 +928,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', } //set the data.default depending on which type - if (scope.type.type === 'text') { + if (scope.type.type === 'text' || scope.type.type === 'multiplechoice') { data.default = scope.default; } else if (scope.type.type === 'textarea') { data.default = scope.default_textarea; @@ -985,7 +988,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope.resetForm = function(){ html = '
'+ '
'+ - ''+ + ''+ '
'+ '
'+ ''+ diff --git a/awx/ui/static/less/survey-maker.less b/awx/ui/static/less/survey-maker.less index 5a95056463..7c485bf2d7 100644 --- a/awx/ui/static/less/survey-maker.less +++ b/awx/ui/static/less/survey-maker.less @@ -37,10 +37,9 @@ border-top: 1px dashed; border-color: rgb(204,204,204); border-radius: 4px; - padding: 5px; position: relative; - + .final{ margin-left: 15px; margin-top: 5px; @@ -87,13 +86,3 @@ .survey_taker_description{ margin-bottom:10px } - - - - - - - - - - From ef5d3372db067e35295d6160a725d6e9584e2822 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 5 Jun 2015 10:24:24 -0400 Subject: [PATCH 3/3] adding 'sensitive' field to survey taker for password fields --- awx/ui/static/js/helpers/JobSubmission.js | 50 +++++++++++++---------- awx/ui/static/js/helpers/Survey.js | 10 +++-- awx/ui/static/less/survey-maker.less | 6 ++- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js index 52f2bcccc7..c45573cb9e 100644 --- a/awx/ui/static/js/helpers/JobSubmission.js +++ b/awx/ui/static/js/helpers/JobSubmission.js @@ -517,6 +517,20 @@ function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm, checked, min, max, survey_url = GetBasePath('job_templates') + id + '/survey_spec/' ; + //for toggling the input on password inputs + scope.toggleInput = function(id) { + var buttonId = id + "_show_input_button", + inputId = id, + buttonInnerHTML = $(buttonId).html(); + if (buttonInnerHTML.indexOf("ABC") > -1) { + $(buttonId).html(""); + $(inputId).attr("type", "text"); + } else { + $(buttonId).html("ABC"); + $(inputId).attr("type", "password"); + } + }; + function buildHtml(question, index){ question.index = index; question.question_name = $filter('sanitize')(question.question_name); @@ -573,28 +587,20 @@ function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm, if(question.type === 'password' ){ minlength = (!Empty(question.min)) ? Number(question.min) : ""; maxlength =(!Empty(question.max)) ? Number(question.max) : "" ; - html+=''+ - '
Please enter an answer.
'+ - '
Please enter an answer between {{'+minlength+'}} to {{'+maxlength+'}} characters long.
'+ - '
'; - html+=''+ - '
Please enter an answer.
'+ - '
Please enter an answer between {{'+minlength+'}} to {{'+maxlength+'}} characters long.
'+ - '
'; - html+= ''; - + html+= '
'+ + ''+ + ''+ + ''+ + ''+ + '
'+ + '
Please enter an answer.
'+ + '
Please enter an answer between {{'+minlength+'}} to {{'+maxlength+'}} characters long.
'+ + '
'; } if(question.type === 'multiplechoice'){ choices = question.choices.split(/\n/); diff --git a/awx/ui/static/js/helpers/Survey.js b/awx/ui/static/js/helpers/Survey.js index 78af9d3a7f..cbd67d0904 100644 --- a/awx/ui/static/js/helpers/Survey.js +++ b/awx/ui/static/js/helpers/Survey.js @@ -332,9 +332,13 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', defaultValue = $filter('sanitize')(defaultValue); defaultValue = scope.serialize(defaultValue); html+='
'+ - '
'+ - ''+ - '
'; + '
'+ + ''+ + ''+ + ''+ + ''+ + '
'+ + '
'; } if(question.type === 'integer'){ diff --git a/awx/ui/static/less/survey-maker.less b/awx/ui/static/less/survey-maker.less index 7c485bf2d7..cc8b5971fa 100644 --- a/awx/ui/static/less/survey-maker.less +++ b/awx/ui/static/less/survey-maker.less @@ -39,7 +39,11 @@ border-radius: 4px; padding: 5px; position: relative; - + + .survey-maker-password{ + margin-left: 30px; + } + .final{ margin-left: 15px; margin-top: 5px;