mirror of
https://github.com/ansible/awx.git
synced 2026-03-23 03:45:01 -02:30
Pass question directly for survey taker
This commit is contained in:
@@ -9,12 +9,13 @@
|
|||||||
* })
|
* })
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default
|
export default
|
||||||
function FinalizeQuestion(GetBasePath, Rest, Wait, ProcessErrors, $compile, Empty, $filter) {
|
function FinalizeQuestion(GetBasePath, Rest, Wait, ProcessErrors, $compile, Empty, $filter, questionScope) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
var scope = params.scope,
|
var question = params.question,
|
||||||
question = params.question,
|
scope = questionScope(question, params.scope),
|
||||||
index = params.index,
|
index = params.index,
|
||||||
required,
|
required,
|
||||||
element,
|
element,
|
||||||
@@ -80,7 +81,7 @@ export default
|
|||||||
html += '<div class="row">';
|
html += '<div class="row">';
|
||||||
html += '<div class="col-xs-8">';
|
html += '<div class="col-xs-8">';
|
||||||
html += '<div class="SurveyControls-selectWrapper">';
|
html += '<div class="SurveyControls-selectWrapper">';
|
||||||
html += '<survey-question type="' + question.type + '" index="' + question.index + '" survey-questions="survey_questions" ng-required="' + question.required + '" ng-model="' + defaultScopePropertyName + '"></survey-question>';
|
html += '<survey-question type="' + question.type + '" question="question" ng-required="' + question.required + '" ng-model="' + defaultScopePropertyName + '"></survey-question>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
@@ -132,8 +133,8 @@ export default
|
|||||||
element = angular.element(document.getElementById('question_'+question.index));
|
element = angular.element(document.getElementById('question_'+question.index));
|
||||||
// // element.html(html);
|
// // element.html(html);
|
||||||
//element.css('opacity', 0.7);
|
//element.css('opacity', 0.7);
|
||||||
|
|
||||||
$compile(element)(scope);
|
$compile(element)(scope);
|
||||||
// var questionScope = scope.$new;
|
|
||||||
|
|
||||||
$('#add_question_btn').show();
|
$('#add_question_btn').show();
|
||||||
$('#add_question_btn').removeAttr('disabled');
|
$('#add_question_btn').removeAttr('disabled');
|
||||||
@@ -187,5 +188,6 @@ FinalizeQuestion.$inject =
|
|||||||
'ProcessErrors',
|
'ProcessErrors',
|
||||||
'$compile',
|
'$compile',
|
||||||
'Empty',
|
'Empty',
|
||||||
'$filter'
|
'$filter',
|
||||||
|
'questionScope'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
import questionScope from './question-scope.factory';
|
||||||
import finalize from './finalize.factory';
|
import finalize from './finalize.factory';
|
||||||
import edit from './edit.factory';
|
import edit from './edit.factory';
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('jobTemplates.surveyMaker.questions', [])
|
angular.module('jobTemplates.surveyMaker.questions', [])
|
||||||
.factory('finalizeQuestion', finalize)
|
.factory('finalizeQuestion', finalize)
|
||||||
|
.factory('questionScope', questionScope)
|
||||||
.factory('editQuestion', edit);
|
.factory('editQuestion', edit);
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
var typesSupportingIsolatedScope =
|
||||||
|
[ 'multiselect',
|
||||||
|
'multiplechoice'
|
||||||
|
];
|
||||||
|
|
||||||
|
function typeSupportsIsolatedScope(type) {
|
||||||
|
return _.include(typesSupportingIsolatedScope, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIsolatedScope(question, oldScope) {
|
||||||
|
var newScope = oldScope.$new();
|
||||||
|
newScope.question = question;
|
||||||
|
return newScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default
|
||||||
|
function() {
|
||||||
|
return function(question, oldScope) {
|
||||||
|
if (typeSupportsIsolatedScope(question.type)) {
|
||||||
|
return getIsolatedScope(question, oldScope);
|
||||||
|
} else {
|
||||||
|
return oldScope;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -24,12 +24,13 @@ function findQuestionByIndex(questions, index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function link(scope, element, attrs) {
|
function link(scope, element, attrs) {
|
||||||
var question = findQuestionByIndex(scope.surveyQuestions, Number(attrs.index));
|
|
||||||
|
|
||||||
scope.question = question;
|
if (!scope.question) {
|
||||||
|
scope.question = findQuestionByIndex(scope.surveyQuestions, Number(attrs.index));
|
||||||
|
}
|
||||||
|
|
||||||
if (!_.isUndefined(question.choices)) {
|
if (!_.isUndefined(scope.question.choices)) {
|
||||||
scope.choices = question.choices.split('\n');
|
scope.choices = scope.question.choices.split('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,8 +39,9 @@ export default
|
|||||||
var directive =
|
var directive =
|
||||||
{ restrict: 'E',
|
{ restrict: 'E',
|
||||||
scope:
|
scope:
|
||||||
{ surveyQuestions: '=',
|
{ question: '=',
|
||||||
selectedValue: '=ngModel',
|
selectedValue: '=ngModel',
|
||||||
|
surveyQuestions: '=',
|
||||||
isRequired: '@ngRequired'
|
isRequired: '@ngRequired'
|
||||||
},
|
},
|
||||||
templateUrl: templateUrl('job-templates/survey-maker/render/survey-question'),
|
templateUrl: templateUrl('job-templates/survey-maker/render/survey-question'),
|
||||||
|
|||||||
Reference in New Issue
Block a user