mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 02:47:36 -02:30
fixed some styling and issue with default values
adjusted some of the survey styling, and made edit questions stronger by ensuring that the question form has been loaded before pushing all the values to the form. Made sure for a multiselect that default value showed correctly
This commit is contained in:
@@ -594,7 +594,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
// html+='<label class="'+element+'-inline">'+
|
// html+='<label class="'+element+'-inline">'+
|
||||||
// '<input class="survey_taker_input" type="'+element+'" name="'+question.variable+ ' " id="" value=" '+choices[j]+' " '+checked+' >' +choices[j]+
|
// '<input class="survey_taker_input" type="'+element+'" name="'+question.variable+ ' " id="" value=" '+choices[j]+' " '+checked+' >' +choices[j]+
|
||||||
// '</label>';
|
// '</label>';
|
||||||
html+= '<input type="'+element+'" ng-model="'+question.variable+'" ng-required="!'+question.variable+'" name="'+question.variable+ ' " id="'+question.variable+'" value=" '+choices[j]+' " '+checked+' >' +
|
html+= '<input type="'+element+'" class="mc" ng-model="'+question.variable+'" ng-required="!'+question.variable+'" name="'+question.variable+ ' " id="'+question.variable+'" value=" '+choices[j]+' " '+checked+' >' +
|
||||||
'<span>'+choices[j] +'</span><br>' ;
|
'<span>'+choices[j] +'</span><br>' ;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -612,7 +612,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
|
|
||||||
for( j = 0; j<choices.length; j++){
|
for( j = 0; j<choices.length; j++){
|
||||||
checked = (!Empty(question.default) && question.default.indexOf(choices[j])!==-1) ? "checked" : "";
|
checked = (!Empty(question.default) && question.default.indexOf(choices[j])!==-1) ? "checked" : "";
|
||||||
html+= '<input type="checkbox" ng-required="!'+question.variable+'" name="'+question.variable+ ' " id="'+question.variable+'" value=" '+choices[j]+' " '+checked+' >' +
|
html+= '<input type="checkbox" class="mc" ng-required="!'+question.variable+'" name="'+question.variable+ ' " id="'+question.variable+'" value=" '+choices[j]+' " '+checked+' >' +
|
||||||
'<span>'+choices[j] +'</span><br>' ;
|
'<span>'+choices[j] +'</span><br>' ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,14 +308,14 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
choices = question.choices.split(/\n/);
|
choices = question.choices.split(/\n/);
|
||||||
element = (question.type==="multiselect") ? "checkbox" : 'radio';
|
element = (question.type==="multiselect") ? "checkbox" : 'radio';
|
||||||
question.default = (question.default) ? question.default : (question.default_multiselect) ? question.default_multiselect : "" ;
|
question.default = (question.default) ? question.default : (question.default_multiselect) ? question.default_multiselect : "" ;
|
||||||
|
|
||||||
for( i = 0; i<choices.length; i++){
|
for( i = 0; i<choices.length; i++){
|
||||||
checked = (!Empty(question.default) && question.default.indexOf(choices[i])!==-1) ? "checked" : "";
|
checked = (!Empty(question.default) && question.default.indexOf(choices[i])!==-1) ? "checked" : "";
|
||||||
html+='<label class="'+element+'-inline final">'+
|
html+= '<input type="'+element+'" class="mc" ng-required="!'+question.variable+'" name="'+question.variable+ ' " id="'+question.variable+'" value=" '+choices[i]+' " '+checked+' >' +
|
||||||
'<input type="'+element+'" name="'+question.variable+ ' " id="" value=" '+choices[i]+' " '+checked+' disabled>' +choices[i]+
|
'<span>'+choices[i] +'</span><br>' ;
|
||||||
'</label>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(question.type === 'integer'){
|
if(question.type === 'integer'){
|
||||||
min = (!Empty(question.min)) ? question.min : "";
|
min = (!Empty(question.min)) ? question.min : "";
|
||||||
max = (!Empty(question.max)) ? question.max : "" ;
|
max = (!Empty(question.max)) ? question.max : "" ;
|
||||||
@@ -378,7 +378,10 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
|
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
index = params.index,
|
index = params.index,
|
||||||
element, fld, i,
|
element,
|
||||||
|
//fld,
|
||||||
|
i,
|
||||||
|
question = scope.survey_questions[index],
|
||||||
form = SurveyQuestionForm;
|
form = SurveyQuestionForm;
|
||||||
|
|
||||||
$('#survey-save-button').attr('disabled', 'disabled');
|
$('#survey-save-button').attr('disabled', 'disabled');
|
||||||
@@ -391,33 +394,54 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
|||||||
scope.int_max = null;
|
scope.int_max = null;
|
||||||
scope.float_min = null;
|
scope.float_min = null;
|
||||||
scope.float_max = null;
|
scope.float_max = null;
|
||||||
GenerateForm.inject(form, { id: 'question_'+index, mode: 'edit' , related: false, scope:scope, breadCrumbs: false});
|
|
||||||
for(fld in form.fields){
|
|
||||||
if( scope.survey_questions[index].type==='integer' && fld === 'int_options'){
|
|
||||||
scope.int_min = scope.survey_questions[index].min;
|
|
||||||
scope.int_max = scope.survey_questions[index].max;
|
//GenerateForm.inject(form, { id: 'question_'+index, mode: 'edit' , related: false, scope:scope, breadCrumbs: false});
|
||||||
// $("#int_min").val(scope.survey_questions[index].min);
|
|
||||||
// $("#int_max").val(scope.survey_questions[index].max);
|
|
||||||
}
|
if (scope.removeFillQuestionForm) {
|
||||||
if( scope.survey_questions[index].type==='float' && fld === 'float_options' ) {
|
scope.removeFillQuestionForm();
|
||||||
scope.float_min = scope.survey_questions[index].min;
|
}
|
||||||
scope.float_max = scope.survey_questions[index].max;
|
scope.removeFillQuestionForm = scope.$on('FillQuestionForm', function() {
|
||||||
// $("#float_min").val(scope.survey_questions[index].min);
|
for( var fld in form.fields){
|
||||||
// $("#float_max").val(scope.survey_questions[index].max);
|
scope[fld] = question[fld];
|
||||||
}
|
if(form.fields[fld].type === 'select'){
|
||||||
if( fld === 'default_int' || fld === 'default_float'){
|
for (i = 0; i < scope.answer_types.length; i++) {
|
||||||
$("#"+fld ).val(scope.survey_questions[index].default);
|
if (scope.survey_questions[index][fld] === scope.answer_types[i].type) {
|
||||||
}
|
scope[fld] = scope.answer_types[i];
|
||||||
if(form.fields[fld].type === 'select'){
|
}
|
||||||
for (i = 0; i < scope.answer_types.length; i++) {
|
|
||||||
if (scope.survey_questions[index][fld] === scope.answer_types[i].type) {
|
|
||||||
scope[fld] = scope.answer_types[i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
scope[fld] = scope.survey_questions[index][fld];
|
|
||||||
}
|
}
|
||||||
|
if( question.type === 'integer'){
|
||||||
|
scope.int_min = question.min;
|
||||||
|
scope.int_max = question.max;
|
||||||
|
scope.default_int = question.default;
|
||||||
|
}
|
||||||
|
else if( question.type === 'float' ) {
|
||||||
|
scope.float_min = question.min;
|
||||||
|
scope.float_max = question.max;
|
||||||
|
scope.default_int = question.default;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ( question.type === 'multiselect'){
|
||||||
|
scope.default_multiselect = question.default;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (scope.removeGenerateForm) {
|
||||||
|
scope.removeGenerateForm();
|
||||||
}
|
}
|
||||||
|
scope.removeGenerateForm = scope.$on('GenerateForm', function() {
|
||||||
|
GenerateForm.inject(form, { id: 'question_'+index, mode: 'edit' , related: false, scope:scope, breadCrumbs: false});
|
||||||
|
scope.$emit('FillQuestionForm');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
scope.$emit('GenerateForm');
|
||||||
|
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
.final{
|
.final{
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
@@ -47,6 +48,11 @@
|
|||||||
.description{
|
.description{
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
}
|
}
|
||||||
|
.mc{
|
||||||
|
margin-left: 18px;
|
||||||
|
margin-right: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#new_question{
|
#new_question{
|
||||||
@@ -65,13 +71,14 @@
|
|||||||
.survey_taker_input{
|
.survey_taker_input{
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
|
.mc{
|
||||||
input{
|
|
||||||
margin-left: 18px;
|
margin-left: 18px;
|
||||||
margin-right: 7px;
|
margin-right: 7px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.survey_taker_description{
|
.survey_taker_description{
|
||||||
padding-left: 30px;
|
padding-left: 30px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user