diff --git a/awx/ui/static/js/forms/SurveyQuestion.js b/awx/ui/static/js/forms/SurveyQuestion.js index b798b94cb3..5ce04d99bc 100644 --- a/awx/ui/static/js/forms/SurveyQuestion.js +++ b/awx/ui/static/js/forms/SurveyQuestion.js @@ -41,9 +41,30 @@ angular.module('SurveyQuestionFormDefinition', []) editRequired: false, column: 1 }, + // variable: { + // label: 'Answer Variable Name', + // type: 'text', + // addRequired: true, + // editRequired: true, + // column: 1, + // awPopOver: '

The suggested format for variable names are lowercase, underscore-seperated descriptive nouns.

'+ + // '

For example:
foo_bar
\n user_id
\n host_name
' , + // dataTitle: 'Answer Variable Name', + // dataPlacement: 'right', + // dataContainer: "body" + // }, variable: { - label: 'Answer Variable Name', - type: 'text', + ealName: 'variable', + type: 'custom', + control:''+ + '

'+ + '
A value is required!
'+ + '
Please remove spaces
'+ + '
'+ + '
', addRequired: true, editRequired: true, column: 1 diff --git a/awx/ui/static/lib/ansible/directives.js b/awx/ui/static/lib/ansible/directives.js index d98c9e9cf3..8282a43944 100644 --- a/awx/ui/static/lib/ansible/directives.js +++ b/awx/ui/static/lib/ansible/directives.js @@ -236,6 +236,26 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job }; }) + //the awSurveyVariableName directive checks if the field contains any spaces. + // this could be elaborated in the future for other things we want to check this field against + .directive('awSurveyVariableName', function() { + // var FLOAT_REGEXP = /^\-?\d+((\.|\,)\d+)?$/; + return { + require: 'ngModel', + link: function(scope, elm, attrs, ctrl) { + ctrl.$parsers.unshift(function(viewValue) { + if (viewValue.indexOf(' ') === -1) { + ctrl.$setValidity('variable', true); + return viewValue; + } else { + ctrl.$setValidity('variable', false); + return undefined; + } + }); + } + }; + }) + // // awRequiredWhen: { variable: "", init:"true|false" } //