mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Default multiplechoice answer fix
the default answer for a multiplechoice question was not saving correctly.
This commit is contained in:
@@ -28,7 +28,6 @@ import Permissions from "tower/forms/Permissions";
|
|||||||
import ProjectStatus from "tower/forms/ProjectStatus";
|
import ProjectStatus from "tower/forms/ProjectStatus";
|
||||||
import Projects from "tower/forms/Projects";
|
import Projects from "tower/forms/Projects";
|
||||||
import Source from "tower/forms/Source";
|
import Source from "tower/forms/Source";
|
||||||
import SurveyMaker from "tower/forms/SurveyMaker";
|
|
||||||
import SurveyQuestion from "tower/forms/SurveyQuestion";
|
import SurveyQuestion from "tower/forms/SurveyQuestion";
|
||||||
import Teams from "tower/forms/Teams";
|
import Teams from "tower/forms/Teams";
|
||||||
import Users from "tower/forms/Users";
|
import Users from "tower/forms/Users";
|
||||||
@@ -59,7 +58,6 @@ export
|
|||||||
ProjectStatus,
|
ProjectStatus,
|
||||||
Projects,
|
Projects,
|
||||||
Source,
|
Source,
|
||||||
SurveyMaker,
|
|
||||||
SurveyQuestion,
|
SurveyQuestion,
|
||||||
Teams,
|
Teams,
|
||||||
Users
|
Users
|
||||||
|
|||||||
@@ -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: '<div class="row">'+
|
|
||||||
// '<div class="col-sm-6">
|
|
||||||
// <div class="form-group">'+
|
|
||||||
// '<label for="survey_name"><span class="label-text prepend-asterisk">Survey Name</span></label>
|
|
||||||
// <div>'+
|
|
||||||
// '<input type="text" ng-model="survey_name" name="survey_name" id="survey_maker_survey_name" class="form-control ng-pristine ng-invalid ng-invalid-required" required="" capitalize>'+
|
|
||||||
// '<div class="error ng-hide" id="survey_maker-survey_name-required-error" ng-show="survey_maker_form.survey_name.$dirty && survey_maker_form.survey_name.$error.required">Please enter a survey name.</div>'+
|
|
||||||
// '<div class="error api-error ng-binding" id="survey_maker-survey_name-api-error" ng-bind="survey_name_api_error"></div>'+
|
|
||||||
// '</div></div></div>'+
|
|
||||||
// '<div class="col-sm-6"><div class="form-group">'+
|
|
||||||
// '<label for="survey_description"><span class="label-text">Survey Description</span></label><div>'+
|
|
||||||
// '<input type="text" ng-model="survey_description" name="survey_description" id="survey_maker_survey_description" class="form-control ng-pristine ng-valid">'+
|
|
||||||
// '<div class="error api-error ng-binding" id="survey_maker-survey_description-api-error" ng-bind="survey_description_api_error"></div>'+
|
|
||||||
// '</div></div></div>'+
|
|
||||||
'<div class="col-sm-12">'+
|
|
||||||
'<label for="survey"><span class="label-text prepend-asterisk">Questions</span></label>'+
|
|
||||||
'<div id="survey_maker_question_area"></div>'+
|
|
||||||
'<div id="finalized_questions"></div>'+
|
|
||||||
'<button style="display:none" type="button" class="btn btn-sm btn-primary" id="add_question_btn" ng-click="addNewQuestion()" aw-tool-tip="Create a new question" data-placement="top" data-original-title="" title="" disabled><i class="fa fa-plus fa-lg"></i> Add Question</button>'+
|
|
||||||
'<div id="new_question"></div>'+
|
|
||||||
'</div>'+
|
|
||||||
'</div>'//</div>'
|
|
||||||
// label: 'Survey Name',
|
|
||||||
// type: 'text',
|
|
||||||
// addRequired: true,
|
|
||||||
// editRequired: true,
|
|
||||||
// capitalize: false,
|
|
||||||
// // column: 1
|
|
||||||
},
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
// buttons: { //for now always generates <button> tags
|
|
||||||
// save: {
|
|
||||||
// ngClick: 'formSave()', //$scope.function to call on click, optional
|
|
||||||
// ngDisabled: true //Disable when $pristine or $invalid, optional
|
|
||||||
// }
|
|
||||||
// reset: {
|
|
||||||
// ngClick: 'formReset()',
|
|
||||||
// ngDisabled: true //Disabled when $pristine
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -36,27 +36,14 @@ export default
|
|||||||
realName: 'question_description',
|
realName: 'question_description',
|
||||||
label: 'Description',
|
label: 'Description',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
// rows: 2,
|
|
||||||
addRequired: false,
|
addRequired: false,
|
||||||
editRequired: false,
|
editRequired: false,
|
||||||
column: 1
|
column: 1
|
||||||
},
|
},
|
||||||
// variable: {
|
|
||||||
// label: 'Answer Variable Name',
|
|
||||||
// type: 'text',
|
|
||||||
// addRequired: true,
|
|
||||||
// editRequired: true,
|
|
||||||
// column: 1,
|
|
||||||
// awPopOver: '<p>The suggested format for variable names are lowercase, underscore-separated descriptive nouns.</p>'+
|
|
||||||
// '<p>For example: <br>foo_bar<br>\n user_id<br>\n host_name<br>' ,
|
|
||||||
// dataTitle: 'Answer Variable Name',
|
|
||||||
// dataPlacement: 'right',
|
|
||||||
// dataContainer: "body"
|
|
||||||
// },
|
|
||||||
variable: {
|
variable: {
|
||||||
ealName: 'variable',
|
ealName: 'variable',
|
||||||
type: 'custom',
|
type: 'custom',
|
||||||
control:'<label for="variable"><span class="label-text prepend-asterisk">Answer Variable Name</span>'+
|
control:'<label for="variable"><span class="label-text prepend-asterisk"> Answer Variable Name</span>'+
|
||||||
'<a id="awp-variable" href="" aw-pop-over="<p>The suggested format for variable names is lowercase and underscore-separated. Also note that this field cannot accept variable names with spaces.</p><p>For example: <br>foo_bar<br>'+
|
'<a id="awp-variable" href="" aw-pop-over="<p>The suggested format for variable names is lowercase and underscore-separated. Also note that this field cannot accept variable names with spaces.</p><p>For example: <br>foo_bar<br>'+
|
||||||
'user_id<br>host_name<br><div class="popover-footer"><span class="key">esc</span> or click to close</div>" '+
|
'user_id<br>host_name<br><div class="popover-footer"><span class="key">esc</span> or click to close</div>" '+
|
||||||
'data-placement="right" data-container="body" data-title="Answer Variable Name" class="help-link" data-original-title="" title="" tabindex="-1"><i class="fa fa-question-circle"></i></a> </label>'+
|
'data-placement="right" data-container="body" data-title="Answer Variable Name" class="help-link" data-original-title="" title="" tabindex="-1"><i class="fa fa-question-circle"></i></a> </label>'+
|
||||||
@@ -281,28 +268,13 @@ export default
|
|||||||
'<span class="input-group-btn">'+
|
'<span class="input-group-btn">'+
|
||||||
'<button class="btn btn-default" id="default_password_show_input_button" aw-tool-tip="Toggle the display of plaintext." aw-tip-placement="top" ng-click="toggleInput("#default_password")" data-original-title="" title="">ABC</button>'+
|
'<button class="btn btn-default" id="default_password_show_input_button" aw-tool-tip="Toggle the display of plaintext." aw-tip-placement="top" ng-click="toggleInput("#default_password")" data-original-title="" title="">ABC</button>'+
|
||||||
'</span>'+
|
'</span>'+
|
||||||
'<input id="default_password" type="password" ng-model="default_password" name="default_password" class="form-control ng-pristine ng-valid-api-error ng-invalid ng-invalid-required" chk-pass="" required="" autocomplete="false">'+
|
'<input id="default_password" type="password" ng-model="default_password" name="default_password" class="form-control ng-pristine ng-valid-api-error ng-invalid" autocomplete="false">'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'<div class="error ng-hide" id="survey_question-default-duplicate-error"" ng-show="invalidChoice">'+
|
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="minTextError">The answer is shorter than the minimium length. Please make the answer longer. </div>' +
|
||||||
'Please enter an answer from the choices listed.</div><div class="error ng-hide" id="survey_question-default-duplicate-error"" ng-show="minTextError">'+
|
'<div class="error ng-hide" id=survey_question-default-password-duplicate-error" ng-show="maxTextError">The answer is longer than the maximum length. Please make the answer shorter. </div>' +
|
||||||
'The answer is shorter than the minimium length. Please make the answer longer.</div>'+
|
'<div class="error api-error ng-binding" id="survey_question-default-password-api-error" ng-bind="default_api_error"></div>'+
|
||||||
'<div class="error ng-hide" id="survey_question-default-duplicate-error"" ng-show="maxTextError">'+
|
|
||||||
'The answer is longer than the maximum length. Please make the answer shorter.</div>'+
|
|
||||||
'<div class="error api-error ng-binding" id="survey_question-default-api-error" ng-bind="default_api_error"></div>'+
|
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'</div>',
|
'</div>',
|
||||||
|
|
||||||
// control: '<div class="form-group" >'+
|
|
||||||
// '<label for="default"><span class="label-text">Default Password</span></label>'+
|
|
||||||
// '<div>'+
|
|
||||||
// '<input type="password" ng-model="default_password" name="default_password" id="default_password" class="form-control" ng-hide="pwcheckbox">'+
|
|
||||||
// '<input type="text" ng-model="default_password" name="default_password" id="default_password" class="form-control" ng-show="pwcheckbox">'+
|
|
||||||
// '<label style="font-weight:normal"><input type="checkbox" ng-model="pwcheckbox" name="pwcheckbox" id="survey_question_pwcheckbox" ng-checked="false"> <span>Show Password</span></label>'+
|
|
||||||
// '<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="minTextError">The answer is shorter than the minimium length. Please make the answer longer. </div>' +
|
|
||||||
// '<div class="error ng-hide" id=survey_question-default-password-duplicate-error" ng-show="maxTextError">The answer is longer than the maximum length. Please make the answer shorter. </div>' +
|
|
||||||
// '<div class="error api-error ng-binding" id="survey_question-default-password-api-error" ng-bind="default_api_error"></div>'+
|
|
||||||
// '</div>'+
|
|
||||||
// '</div>',
|
|
||||||
column: 2,
|
column: 2,
|
||||||
ngShow: 'type.type === "password" '
|
ngShow: 'type.type === "password" '
|
||||||
},
|
},
|
||||||
@@ -323,7 +295,7 @@ export default
|
|||||||
},
|
},
|
||||||
submit_question: {
|
submit_question: {
|
||||||
ngClick: 'submitQuestion($event)',
|
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',
|
'class': 'btn btn-sm btn-primary',
|
||||||
label: 'Add Question'
|
label: 'Add Question'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ngdoc function
|
* @ngdoc function
|
||||||
* @name helpers.function:JobSubmission
|
* @name helpers.function:JobSubmission
|
||||||
@@ -526,8 +526,10 @@ function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm,
|
|||||||
requiredAsterisk = (question.required===true) ? "prepend-asterisk" : "";
|
requiredAsterisk = (question.required===true) ? "prepend-asterisk" : "";
|
||||||
requiredClasses = (question.required===true) ? "ng-pristine ng-invalid-required ng-invalid" : "";
|
requiredClasses = (question.required===true) ? "ng-pristine ng-invalid-required ng-invalid" : "";
|
||||||
|
|
||||||
html+='<div id="taker_'+question.index+'" class="form-group '+requiredAsterisk+' ">';
|
html+='<div id="taker_'+question.index+'" class="form-group">';
|
||||||
html += '<label for="'+question.variable+'">'+question.question_name+'</label>\n';
|
html += '<label for="'+question.variable+'"><span class="label-text '+requiredAsterisk+'"> '+question.question_name+'</span></label>';
|
||||||
|
|
||||||
|
// html += '<label for="'+question.variable+'"> '+ question.question_name+'</label>\n';
|
||||||
|
|
||||||
if(!Empty(question.question_description)){
|
if(!Empty(question.question_description)){
|
||||||
html += '<div class="survey_taker_description"><i>'+question.question_description+'</i></div>\n';
|
html += '<div class="survey_taker_description"><i>'+question.question_description+'</i></div>\n';
|
||||||
|
|||||||
@@ -285,7 +285,10 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
}
|
}
|
||||||
|
|
||||||
required = (question.required===true) ? "prepend-asterisk" : "";
|
required = (question.required===true) ? "prepend-asterisk" : "";
|
||||||
html = '<div class="question_title col-xs-12 '+required+'"><b>'+question.question_name+'</b></div>\n';
|
html = '<div class="question_title col-xs-12">';
|
||||||
|
html += '<label for="'+question.variable+'"><span class="label-text '+required+'"> '+question.question_name+'</span></label>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
if(!Empty(question.question_description)){
|
if(!Empty(question.question_description)){
|
||||||
html += '<div class="col-xs-12 description"><i>'+question.question_description+'</i></div>\n';
|
html += '<div class="col-xs-12 description"><i>'+question.question_description+'</i></div>\n';
|
||||||
}
|
}
|
||||||
@@ -326,7 +329,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
|
|
||||||
if(question.type === 'password'){
|
if(question.type === 'password'){
|
||||||
defaultValue = (question.default) ? question.default : "";
|
defaultValue = (question.default) ? question.default : "";
|
||||||
defaultValue = $filter('defaultValue')(choices[i]);
|
defaultValue = $filter('sanitize')(defaultValue);
|
||||||
defaultValue = scope.serialize(defaultValue);
|
defaultValue = scope.serialize(defaultValue);
|
||||||
html+='<div class="row">'+
|
html+='<div class="row">'+
|
||||||
'<div class="col-xs-8">'+
|
'<div class="col-xs-8">'+
|
||||||
@@ -925,7 +928,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set the data.default depending on which type
|
//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;
|
data.default = scope.default;
|
||||||
} else if (scope.type.type === 'textarea') {
|
} else if (scope.type.type === 'textarea') {
|
||||||
data.default = scope.default_textarea;
|
data.default = scope.default_textarea;
|
||||||
@@ -985,7 +988,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
scope.resetForm = function(){
|
scope.resetForm = function(){
|
||||||
html = '<div class="row">'+
|
html = '<div class="row">'+
|
||||||
'<div class="col-sm-12">'+
|
'<div class="col-sm-12">'+
|
||||||
'<label for="survey"><span class="label-text prepend-asterisk">Questions</span></label>'+
|
'<label for="survey"><span class="label-text prepend-asterisk"> Questions</span></label>'+
|
||||||
'<div id="survey_maker_question_area"></div>'+
|
'<div id="survey_maker_question_area"></div>'+
|
||||||
'<div id="finalized_questions"></div>'+
|
'<div id="finalized_questions"></div>'+
|
||||||
'<button style="display:none" type="button" class="btn btn-sm btn-primary" id="add_question_btn" ng-click="addNewQuestion()" aw-tool-tip="Create a new question" data-placement="top" data-original-title="" title="" disabled><i class="fa fa-plus fa-lg"></i> New Question</button>'+
|
'<button style="display:none" type="button" class="btn btn-sm btn-primary" id="add_question_btn" ng-click="addNewQuestion()" aw-tool-tip="Create a new question" data-placement="top" data-original-title="" title="" disabled><i class="fa fa-plus fa-lg"></i> New Question</button>'+
|
||||||
|
|||||||
@@ -37,10 +37,9 @@
|
|||||||
border-top: 1px dashed;
|
border-top: 1px dashed;
|
||||||
border-color: rgb(204,204,204);
|
border-color: rgb(204,204,204);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
.final{
|
.final{
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
@@ -87,13 +86,3 @@
|
|||||||
.survey_taker_description{
|
.survey_taker_description{
|
||||||
margin-bottom:10px
|
margin-bottom:10px
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user