mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 05:01:19 -03: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:
parent
2e4fd96aef
commit
90ae405424
@ -594,7 +594,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
||||
// html+='<label class="'+element+'-inline">'+
|
||||
// '<input class="survey_taker_input" type="'+element+'" name="'+question.variable+ ' " id="" value=" '+choices[j]+' " '+checked+' >' +choices[j]+
|
||||
// '</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>' ;
|
||||
|
||||
}
|
||||
@ -612,7 +612,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
||||
|
||||
for( j = 0; j<choices.length; j++){
|
||||
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>' ;
|
||||
|
||||
}
|
||||
|
||||
@ -308,14 +308,14 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
choices = question.choices.split(/\n/);
|
||||
element = (question.type==="multiselect") ? "checkbox" : 'radio';
|
||||
question.default = (question.default) ? question.default : (question.default_multiselect) ? question.default_multiselect : "" ;
|
||||
|
||||
for( i = 0; i<choices.length; i++){
|
||||
checked = (!Empty(question.default) && question.default.indexOf(choices[i])!==-1) ? "checked" : "";
|
||||
html+='<label class="'+element+'-inline final">'+
|
||||
'<input type="'+element+'" name="'+question.variable+ ' " id="" value=" '+choices[i]+' " '+checked+' disabled>' +choices[i]+
|
||||
'</label>';
|
||||
html+= '<input type="'+element+'" class="mc" ng-required="!'+question.variable+'" name="'+question.variable+ ' " id="'+question.variable+'" value=" '+choices[i]+' " '+checked+' >' +
|
||||
'<span>'+choices[i] +'</span><br>' ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(question.type === 'integer'){
|
||||
min = (!Empty(question.min)) ? question.min : "";
|
||||
max = (!Empty(question.max)) ? question.max : "" ;
|
||||
@ -378,7 +378,10 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
|
||||
var scope = params.scope,
|
||||
index = params.index,
|
||||
element, fld, i,
|
||||
element,
|
||||
//fld,
|
||||
i,
|
||||
question = scope.survey_questions[index],
|
||||
form = SurveyQuestionForm;
|
||||
|
||||
$('#survey-save-button').attr('disabled', 'disabled');
|
||||
@ -391,33 +394,54 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
scope.int_max = null;
|
||||
scope.float_min = 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;
|
||||
// $("#int_min").val(scope.survey_questions[index].min);
|
||||
// $("#int_max").val(scope.survey_questions[index].max);
|
||||
}
|
||||
if( scope.survey_questions[index].type==='float' && fld === 'float_options' ) {
|
||||
scope.float_min = scope.survey_questions[index].min;
|
||||
scope.float_max = scope.survey_questions[index].max;
|
||||
// $("#float_min").val(scope.survey_questions[index].min);
|
||||
// $("#float_max").val(scope.survey_questions[index].max);
|
||||
}
|
||||
if( fld === 'default_int' || fld === 'default_float'){
|
||||
$("#"+fld ).val(scope.survey_questions[index].default);
|
||||
}
|
||||
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];
|
||||
|
||||
|
||||
|
||||
|
||||
//GenerateForm.inject(form, { id: 'question_'+index, mode: 'edit' , related: false, scope:scope, breadCrumbs: false});
|
||||
|
||||
|
||||
if (scope.removeFillQuestionForm) {
|
||||
scope.removeFillQuestionForm();
|
||||
}
|
||||
scope.removeFillQuestionForm = scope.$on('FillQuestionForm', function() {
|
||||
for( var fld in form.fields){
|
||||
scope[fld] = question[fld];
|
||||
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;
|
||||
padding: 5px;
|
||||
position: relative;
|
||||
|
||||
.final{
|
||||
margin-left: 15px;
|
||||
margin-top: 5px;
|
||||
@ -47,6 +48,11 @@
|
||||
.description{
|
||||
margin-left: 15px;
|
||||
}
|
||||
.mc{
|
||||
margin-left: 18px;
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#new_question{
|
||||
@ -65,13 +71,14 @@
|
||||
.survey_taker_input{
|
||||
margin-top: 5px;
|
||||
margin-left: 15px;
|
||||
|
||||
input{
|
||||
.mc{
|
||||
margin-left: 18px;
|
||||
margin-right: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.survey_taker_description{
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user