mirror of
https://github.com/ansible/awx.git
synced 2026-03-29 06:45:09 -02:30
adding add/edit survey
This commit is contained in:
@@ -163,14 +163,14 @@ angular.module('Tower', [
|
|||||||
controller: 'JobTemplatesEdit'
|
controller: 'JobTemplatesEdit'
|
||||||
}).
|
}).
|
||||||
|
|
||||||
when('/job_templates/add/survey', {
|
when('/job_templates/:template_id/survey/add', {
|
||||||
templateUrl: urlPrefix + 'partials/survey_maker.html',
|
templateUrl: urlPrefix + 'partials/survey_maker.html',
|
||||||
controller: 'SurveyMakerAdd'
|
controller: 'SurveyMakerAdd'
|
||||||
}).
|
}).
|
||||||
|
|
||||||
when('/job_templates/:template_id/survey', {
|
when('/job_templates/:template_id/survey/edit', {
|
||||||
templateUrl: urlPrefix + 'partials/survey_maker.html',
|
templateUrl: urlPrefix + 'partials/survey_maker.html',
|
||||||
controller: 'SurveyMakerAdd'
|
controller: 'SurveyMakerEdit'
|
||||||
}).
|
}).
|
||||||
|
|
||||||
when('/job_templates/:id/schedules', {
|
when('/job_templates/:id/schedules', {
|
||||||
|
|||||||
@@ -337,8 +337,8 @@ function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
};
|
};
|
||||||
|
|
||||||
//navigate to the survey maker
|
//navigate to the survey maker
|
||||||
$scope.navigateToSurvey = function() {
|
$scope.addSurvey = function() {
|
||||||
$location.path($location.path() + '/survey');
|
$location.path($location.path() + '/survey/add');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -591,6 +591,33 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
|
if ($scope.removeEnableSurvey) {
|
||||||
|
$scope.removeEnableSurvey();
|
||||||
|
}
|
||||||
|
$scope.removeEnableSurvey = $scope.$on('EnableSurvey', function(fld) {
|
||||||
|
$('#job_templates_survey_enabled_chbox').attr('checked', $scope[fld]);
|
||||||
|
Rest.setUrl(defaultUrl + id+ '/survey_spec/');
|
||||||
|
Rest.get()
|
||||||
|
.success(function (data) {
|
||||||
|
if(!data || !data.name){
|
||||||
|
$('#job_templates_delete_survey_btn').hide();
|
||||||
|
$('#job_templates_edit_survey_btn').hide();
|
||||||
|
$('#job_templates_create_survey_btn').show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#job_templates_delete_survey_btn').show();
|
||||||
|
$('#job_templates_edit_survey_btn').show();
|
||||||
|
$('#job_templates_create_survey_btn').hide();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, form, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve job template: ' + $routeParams.template_id + '. GET status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if ($scope.removeLoadJobs) {
|
if ($scope.removeLoadJobs) {
|
||||||
$scope.rmoveLoadJobs();
|
$scope.rmoveLoadJobs();
|
||||||
}
|
}
|
||||||
@@ -615,6 +642,9 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$scope[fld] = data[fld];
|
$scope[fld] = data[fld];
|
||||||
|
if(fld ==='survey_enabled' && $scope[fld]===true){
|
||||||
|
$scope.$emit('EnableSurvey', fld);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
master[fld] = $scope[fld];
|
master[fld] = $scope[fld];
|
||||||
}
|
}
|
||||||
@@ -819,8 +849,34 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
};
|
};
|
||||||
|
|
||||||
//navigate to the survey maker
|
//navigate to the survey maker
|
||||||
$scope.navigateToSurvey = function() {
|
$scope.addSurvey = function() {
|
||||||
$location.path($location.path() + '/survey');
|
$location.path($location.path() + '/survey/add');
|
||||||
|
};
|
||||||
|
|
||||||
|
//navigate to the survey maker
|
||||||
|
$scope.editSurvey = function() {
|
||||||
|
$location.path($location.path() + '/survey/edit');
|
||||||
|
};
|
||||||
|
|
||||||
|
//delete a survey by posting a blank survey
|
||||||
|
$scope.deleteSurvey = function() {
|
||||||
|
// $location.path($location.path() + '/survey/add');
|
||||||
|
Wait('start');
|
||||||
|
var url = defaultUrl+ id + '/survey_spec/';
|
||||||
|
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post({})
|
||||||
|
.success(function () {
|
||||||
|
Wait('stop');
|
||||||
|
$('#job_templates_delete_survey_btn').hide();
|
||||||
|
$('#job_templates_edit_survey_btn').hide();
|
||||||
|
$('#job_templates_create_survey_btn').show();
|
||||||
|
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to add new survey. Post returned status: ' + status });
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Related set: Delete button
|
// Related set: Delete button
|
||||||
|
|||||||
@@ -23,28 +23,34 @@ function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routePar
|
|||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var generator = GenerateForm,
|
var generator = GenerateForm,
|
||||||
form = SurveyMakerForm,
|
form = SurveyMakerForm,
|
||||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
id = $location.path().replace(/^\//, '').split('/')[1];
|
||||||
|
|
||||||
$scope.survey_questions=[];
|
$scope.survey_questions=[];
|
||||||
|
|
||||||
$scope.answer_types=[
|
$scope.answer_types=[
|
||||||
{name: 'Text' , type: 'text'},
|
{name: 'Text' , type: 'text'},
|
||||||
{name: 'Textarea', type: 'text'},
|
{name: 'Textarea', type: 'textarea'},
|
||||||
{name: 'Multiple Choice (single select)', type: 'mc'},
|
{name: 'Multiple Choice (single select)', type: 'multiplechoice'},
|
||||||
{name: 'Multiple Choice (multiple select)', type: 'mc'},
|
{name: 'Multiple Choice (multiple select)', type: 'multiselect'},
|
||||||
{name: 'JSON', type: 'json'},
|
{name: 'JSON', type: 'json'},
|
||||||
{name: 'Integer', type: 'number'},
|
{name: 'Integer', type: 'integer'},
|
||||||
{name: 'Float', type: 'number'}
|
{name: 'Float', type: 'number'}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
generator.inject(form, { mode: 'add', related: false, scope: $scope});
|
generator.inject(form, { mode: 'add', related: false, scope: $scope});
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
// LoadBreadCrumbs();
|
// LoadBreadCrumbs();
|
||||||
|
// LoadBreadCrumbs({
|
||||||
|
// path: '/job_templates/' + id + '/survey',
|
||||||
|
// title: 'jared rocks', // $scope.job_id + ' - ', //+ data.summary_fields.job_template.name,
|
||||||
|
// altPath: '/job_templates/' + id + '/survey',
|
||||||
|
// });
|
||||||
|
|
||||||
$scope.addQuestion = function(){
|
$scope.addQuestion = function(){
|
||||||
GenerateForm.inject(SurveyQuestionForm, {mode:'add', id:'new_question', scope:$scope, breadCrumbs: false});
|
|
||||||
|
GenerateForm.inject(SurveyQuestionForm, {mode:'modal', id:'new_question', scope:$scope, breadCrumbs: false});
|
||||||
};
|
};
|
||||||
$scope.addQuestion();
|
$scope.addQuestion();
|
||||||
|
|
||||||
@@ -84,49 +90,54 @@ function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routePar
|
|||||||
// "border-radius": "4px"
|
// "border-radius": "4px"
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
$scope.finalizeQuestion= function(data){
|
$scope.finalizeQuestion= function(data, labels){
|
||||||
var html = '<div class="question_final">';
|
var key,
|
||||||
// angular.forEach(data, function(value, key) {
|
html = '<div class="question_final row">';
|
||||||
// html+='<label for="question_text"><span class="label-text">'+data.label+'</span></label>'+data.question_text;
|
|
||||||
// });
|
for (key in data) {
|
||||||
html+='<label for="question_text"><span class="label-text">Question Text</span></label>'+data.question_text;
|
html+='<div class="col-xs-6"><label for="question_text"><span class="label-text">'+labels[key] +': </span></label>'+data[key]+'</div>\n';
|
||||||
html+='<label for="question_text"><span class="label-text">Question Question</span></label>'+data.question_description;
|
}
|
||||||
html+='<label for="question_text"><span class="label-text">Answer Response Variable</span></label>'+data.response_variable_name;
|
|
||||||
html+='<label for="question_text"><span class="label-text">Answer Type</span></label>'+data.answer_type;
|
|
||||||
html+='<label for="question_text"><span class="label-text">Answer Options</span></label>'+data.answer_option_text;
|
|
||||||
html+='<label for="question_text"><span class="label-text">Answer Options</span></label>'+data.answer_option_number;
|
|
||||||
html+='<label for="question_text"><span class="label-text">Answer Options</span></label>'+data.answer_option_multiple_choice;
|
|
||||||
html+='<label for="question_text"><span class="label-text">Default Answer</span></label>'+data.default_answer;
|
|
||||||
html+='<label for="question_text"><span class="label-text">Answer Required</span></label>'+data.is_required;
|
|
||||||
html+='</div>';
|
html+='</div>';
|
||||||
|
|
||||||
$('#finalized_questions').before(html);
|
$('#finalized_questions').before(html);
|
||||||
$('#add_question_btn').show();
|
$('#add_question_btn').show();
|
||||||
$('#add_question_btn').removeAttr('disabled');
|
$('#add_question_btn').removeAttr('disabled');
|
||||||
$('#add_question_btn').on("click" , function(){
|
$('#survey_maker_save_btn').removeAttr('disabled');
|
||||||
|
};
|
||||||
|
|
||||||
|
$('#add_question_btn').on("click" , function(){
|
||||||
$scope.addQuestion();
|
$scope.addQuestion();
|
||||||
$('#add_question_btn').attr('disabled', 'disabled');
|
$('#add_question_btn').attr('disabled', 'disabled');
|
||||||
});
|
});
|
||||||
};
|
|
||||||
$scope.submitQuestion = function(){
|
$scope.submitQuestion = function(){
|
||||||
var form = SurveyQuestionForm,
|
var form = SurveyQuestionForm,
|
||||||
data = {}, labels={}, fld;
|
data = {},
|
||||||
|
labels={},
|
||||||
|
min= "min",
|
||||||
|
max = "max",
|
||||||
|
fld;
|
||||||
//generator.clearApiErrors();
|
//generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if($scope[fld]){
|
if($scope[fld]){
|
||||||
data[fld] = $scope[fld];
|
if(fld === "type"){
|
||||||
// labels[fld] = form.fields[fld].label;
|
data[fld] = $scope[fld].type;
|
||||||
|
if($scope[fld].type==="integer" || $scope[fld].type==="float"){
|
||||||
|
data[min] = $('#answer_min').val();
|
||||||
|
data[max] = $('#answer_max').val();
|
||||||
|
labels[min]= "Min";
|
||||||
|
labels[max]= "Max";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
data[fld] = $scope[fld];
|
||||||
|
}
|
||||||
|
labels[fld] = form.fields[fld].label;
|
||||||
}
|
}
|
||||||
// if (form.fields[fld].type === 'select' && fld !== 'playbook') {
|
|
||||||
// data[fld] = $scope[fld].value;
|
|
||||||
// } else {
|
|
||||||
// if (fld !== 'variables') {
|
|
||||||
// data[fld] = $scope[fld];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$scope.survey_questions.push(data);
|
$scope.survey_questions.push(data);
|
||||||
@@ -145,22 +156,17 @@ function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routePar
|
|||||||
$scope.formSave = function () {
|
$scope.formSave = function () {
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var url = GetBasePath(base);
|
var url = GetBasePath(base)+ id + '/survey_spec/';
|
||||||
url += (base !== 'organizations') ? $routeParams.project_id + '/organizations/' : '';
|
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post({ name: $scope.name, description: $scope.description })
|
Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions })
|
||||||
.success(function (data) {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
if (base === 'organizations') {
|
$location.path("/job_templates/"+id);
|
||||||
$rootScope.flashMessage = "New organization successfully created!";
|
|
||||||
$location.path('/organizations/' + data.id);
|
|
||||||
} else {
|
|
||||||
ReturnToCaller(1);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||||
msg: 'Failed to add new organization. Post returned status: ' + status });
|
msg: 'Failed to add new survey. Post returned status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -175,6 +181,226 @@ SurveyMakerAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log
|
|||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'Wait', 'SurveyQuestionForm'
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'Wait', 'SurveyQuestionForm'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function SurveyMakerEdit($scope, $rootScope, $compile, $location, $log, $routeParams, SurveyMakerForm,
|
||||||
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath,
|
||||||
|
ReturnToCaller, Wait, SurveyQuestionForm) {
|
||||||
|
|
||||||
|
ClearScope();
|
||||||
|
|
||||||
|
// Inject dynamic view
|
||||||
|
var generator = GenerateForm,
|
||||||
|
form = SurveyMakerForm,
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
id = $location.path().replace(/^\//, '').split('/')[1];
|
||||||
|
|
||||||
|
$scope.survey_questions=[];
|
||||||
|
|
||||||
|
$scope.answer_types=[
|
||||||
|
{name: 'Text' , type: 'text'},
|
||||||
|
{name: 'Textarea', type: 'textarea'},
|
||||||
|
{name: 'Multiple Choice (single select)', type: 'multiplechoice'},
|
||||||
|
{name: 'Multiple Choice (multiple select)', type: 'multiselect'},
|
||||||
|
{name: 'JSON', type: 'json'},
|
||||||
|
{name: 'Integer', type: 'integer'},
|
||||||
|
{name: 'Float', type: 'number'}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
generator.inject(form, { mode: 'edit', related: false, scope: $scope});
|
||||||
|
generator.reset();
|
||||||
|
// LoadBreadCrumbs();
|
||||||
|
// LoadBreadCrumbs({
|
||||||
|
// path: '/job_templates/' + id + '/survey',
|
||||||
|
// title: 'jared rocks', // $scope.job_id + ' - ', //+ data.summary_fields.job_template.name,
|
||||||
|
// altPath: '/job_templates/' + id + '/survey',
|
||||||
|
// });
|
||||||
|
|
||||||
|
$scope.addQuestion = function(){
|
||||||
|
|
||||||
|
GenerateForm.inject(SurveyQuestionForm, {mode:'add', id:'new_question', scope:$scope, breadCrumbs: false});
|
||||||
|
};
|
||||||
|
// $scope.addQuestion();
|
||||||
|
|
||||||
|
// $('#question_shadow').mouseenter(function(){
|
||||||
|
// $('#question_shadow').css({
|
||||||
|
// "opacity": "1",
|
||||||
|
// "border": "1px solid",
|
||||||
|
// "border-color": "rgb(204,204,204)",
|
||||||
|
// "border-radius": "4px"
|
||||||
|
// });
|
||||||
|
// $('#question_add_btn').show();
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $('#question_shadow').mouseleave(function(){
|
||||||
|
// $('#question_shadow').css({
|
||||||
|
// "opacity": ".4",
|
||||||
|
// "border": "1px dashed",
|
||||||
|
// "border-color": "rgb(204,204,204)",
|
||||||
|
// "border-radius": "4px"
|
||||||
|
// });
|
||||||
|
// $('#question_add_btn').hide();
|
||||||
|
// })
|
||||||
|
|
||||||
|
|
||||||
|
// $('#question_shadow').on("click" , function(){
|
||||||
|
// // var survey_width = $('#survey_maker_question_area').width()-10,
|
||||||
|
// // html = "";
|
||||||
|
|
||||||
|
// // $('#add_question_btn').attr('disabled', 'disabled')
|
||||||
|
// // $('#survey_maker_question_area').append(html);
|
||||||
|
// addQuestion();
|
||||||
|
// $('#question_shadow').hide();
|
||||||
|
// $('#question_shadow').css({
|
||||||
|
// "opacity": ".4",
|
||||||
|
// "border": "1px dashed",
|
||||||
|
// "border-color": "rgb(204,204,204)",
|
||||||
|
// "border-radius": "4px"
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
$scope.finalizeQuestion= function(data){
|
||||||
|
var key,
|
||||||
|
labels={
|
||||||
|
"type": "Type",
|
||||||
|
"question_name": "Question Text",
|
||||||
|
"question_description": "Question Description",
|
||||||
|
"variable": "Answer Varaible Name",
|
||||||
|
"choices": "Choices",
|
||||||
|
"min": "Min",
|
||||||
|
"max": "Max",
|
||||||
|
"required": "Required",
|
||||||
|
"default": "Default Answer"
|
||||||
|
},
|
||||||
|
html = '<div class="question_final row">';
|
||||||
|
|
||||||
|
for (key in data) {
|
||||||
|
html+='<div class="col-xs-6"><label for="question_text"><span class="label-text">'+labels[key] +': </span></label>'+data[key]+'</div>\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
html+='</div>';
|
||||||
|
|
||||||
|
$('#finalized_questions').before(html);
|
||||||
|
$('#add_question_btn').show();
|
||||||
|
$('#add_question_btn').removeAttr('disabled');
|
||||||
|
$('#survey_maker_save_btn').removeAttr('disabled');
|
||||||
|
};
|
||||||
|
|
||||||
|
$('#add_question_btn').on("click" , function(){
|
||||||
|
$scope.addQuestion();
|
||||||
|
$('#add_question_btn').attr('disabled', 'disabled');
|
||||||
|
});
|
||||||
|
|
||||||
|
Wait('start');
|
||||||
|
|
||||||
|
Rest.setUrl(GetBasePath(base)+ id + '/survey_spec/');
|
||||||
|
Rest.get()
|
||||||
|
.success(function (data) {
|
||||||
|
var i;
|
||||||
|
$scope.survey_name = data.name;
|
||||||
|
$scope.survey_description = data.description;
|
||||||
|
$scope.survey_questions = data.spec;
|
||||||
|
for(i=0; i<$scope.survey_questions.length; i++){
|
||||||
|
$scope.finalizeQuestion($scope.survey_questions[i]);
|
||||||
|
}
|
||||||
|
Wait('stop');
|
||||||
|
// LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name });
|
||||||
|
// for (fld in form.fields) {
|
||||||
|
// if (data[fld]) {
|
||||||
|
// $scope[fld] = data[fld];
|
||||||
|
// master[fld] = data[fld];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// related = data.related;
|
||||||
|
// for (set in form.related) {
|
||||||
|
// if (related[set]) {
|
||||||
|
// relatedSets[set] = {
|
||||||
|
// url: related[set],
|
||||||
|
// iterator: form.related[set].iterator
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
|
// RelatedSearchInit({ scope: $scope, form: form, relatedSets: relatedSets });
|
||||||
|
// RelatedPaginateInit({ scope: $scope, relatedSets: relatedSets });
|
||||||
|
// $scope.$emit('organizationLoaded');
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve organization: ' + $routeParams.id + '. GET status: ' + status });
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.submitQuestion = function(){
|
||||||
|
var form = SurveyQuestionForm,
|
||||||
|
data = {},
|
||||||
|
labels={},
|
||||||
|
min= "min",
|
||||||
|
max = "max",
|
||||||
|
fld;
|
||||||
|
//generator.clearApiErrors();
|
||||||
|
Wait('start');
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (fld in form.fields) {
|
||||||
|
if($scope[fld]){
|
||||||
|
if(fld === "type"){
|
||||||
|
data[fld] = $scope[fld].type;
|
||||||
|
if($scope[fld].type==="integer" || $scope[fld].type==="float"){
|
||||||
|
data[min] = $('#answer_min').val();
|
||||||
|
data[max] = $('#answer_max').val();
|
||||||
|
labels[min]= "Min";
|
||||||
|
labels[max]= "Max";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
data[fld] = $scope[fld];
|
||||||
|
}
|
||||||
|
labels[fld] = form.fields[fld].label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Wait('stop');
|
||||||
|
$scope.survey_questions.push(data);
|
||||||
|
$('#new_question .aw-form-well').remove();
|
||||||
|
// for(fld in form.fields){
|
||||||
|
// $scope[fld] = '';
|
||||||
|
// }
|
||||||
|
$scope.finalizeQuestion(data , labels);
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
Wait('stop');
|
||||||
|
Alert("Error", "Error parsing extra variables. Parser returned: " + err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Save
|
||||||
|
$scope.formSave = function () {
|
||||||
|
generator.clearApiErrors();
|
||||||
|
Wait('start');
|
||||||
|
var url = GetBasePath(base)+ id + '/survey_spec/';
|
||||||
|
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions })
|
||||||
|
.success(function () {
|
||||||
|
Wait('stop');
|
||||||
|
$location.path("/job_templates/"+id);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to add new survey. Post returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cancel
|
||||||
|
$scope.formReset = function () {
|
||||||
|
$rootScope.flashMessage = null;
|
||||||
|
generator.reset();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
SurveyMakerEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'SurveyMakerForm',
|
||||||
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'Wait', 'SurveyQuestionForm'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// function OrganizationsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm, GenerateForm, Rest,
|
// function OrganizationsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm, GenerateForm, Rest,
|
||||||
// Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, Prompt, ClearScope, GetBasePath, Wait, Stream) {
|
// Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, Prompt, ClearScope, GetBasePath, Wait, Stream) {
|
||||||
|
|||||||
@@ -240,19 +240,51 @@ angular.module('JobTemplateFormDefinition', ['SchedulesListDefinition', 'Complet
|
|||||||
dataTitle: 'Prompt for Extra Variables',
|
dataTitle: 'Prompt for Extra Variables',
|
||||||
dataContainer: "body"
|
dataContainer: "body"
|
||||||
},
|
},
|
||||||
enable_survey: {
|
// survey_enabled: {
|
||||||
|
// type: 'custom',
|
||||||
|
// column: 2,
|
||||||
|
// control: '<div class="form-group">'+
|
||||||
|
// '<div class="checkbox">'+
|
||||||
|
// '<label><input type="checkbox" ng-model="survey_enabled" name="survey_enabled" id="job_templates_survey_enabled_chbox" class="ng-valid ng-valid-api-error ng-dirty" ng-true-value="true" ng-false-value="false">'+
|
||||||
|
// '<span class="label-text">Enable Survey</span><a id="awp-survey_enabled" href="" aw-pop-over="<p>If checked, user will be prompted at job launch with a survey of questions related to the job.</p>'+
|
||||||
|
// '<div class="popover-footer"><span class="key">esc</span> or click to close</div>" data-placement="right" data-container="body" data-title="Enable Survey" class="help-link" data-original-title="" title="" tabindex="-1">'+
|
||||||
|
// '<i class="fa fa-question-circle"></i></a> </label>'+
|
||||||
|
// '<div class="error api-error ng-binding" id="job_templates-survey_enabled-api-error" ng-bind="survey_enabled_api_error"></div>'+
|
||||||
|
// '<button type="button" class="btn btn-sm btn-default" id="job_templates_edit_survey_btn" ng-click="navigateToSurvey()"><i class="fa fa-pencil"></i> Create Survey</button>'+
|
||||||
|
// '</div>'+
|
||||||
|
// '</div>'
|
||||||
|
// },
|
||||||
|
survey_enabled: {
|
||||||
|
label: 'Enable Survey',
|
||||||
|
type: 'checkbox',
|
||||||
|
addRequired: false,
|
||||||
|
editRequird: false,
|
||||||
|
trueValue: 'true',
|
||||||
|
falseValue: 'false',
|
||||||
|
column: 2,
|
||||||
|
awPopOver: "<p>If checked, user will be prompted at job launch with a series of questions related to the job.</p>",
|
||||||
|
dataPlacement: 'right',
|
||||||
|
dataTitle: 'Enable Survey',
|
||||||
|
dataContainer: "body"
|
||||||
|
},
|
||||||
|
create_survey: {
|
||||||
type: 'custom',
|
type: 'custom',
|
||||||
column: 2,
|
column: 2,
|
||||||
control: '<div class="form-group">'+
|
control: '<button type="button" class="btn btn-sm btn-primary" id="job_templates_create_survey_btn" ng-show="survey_enabled" ng-click="addSurvey()"><i class="fa fa-pencil"></i> Create Survey</button>'+
|
||||||
'<div class="checkbox">'+
|
'<button style="display:none;" type="button" class="btn btn-sm btn-primary" id="job_templates_edit_survey_btn" ng-show="survey_enabled" ng-click="editSurvey()"><i class="fa fa-pencil"></i> Edit Survey</button>'+
|
||||||
'<label><input type="checkbox" ng-model="enable_survey" name="enable_survey" id="job_templates_enable_survey_chbox" class="ng-valid ng-valid-api-error ng-dirty" ng-true-value="true" ng-false-value="false">'+
|
'<button style="display:none;margin-left:5px" type="button" class="btn btn-sm btn-primary" id="job_templates_delete_survey_btn" ng-show="survey_enabled" ng-click="deleteSurvey()"><i class="fa fa-trash-o"></i> Delete Survey</button>'
|
||||||
'<span class="label-text">Enable Survey</span><a id="awp-enable_survey" href="" aw-pop-over="<p>If checked, user will be prompted at job launch with a survey of questions related to the job.</p>'+
|
// label: 'Create Survey',
|
||||||
'<div class="popover-footer"><span class="key">esc</span> or click to close</div>" data-placement="right" data-container="body" data-title="Enable Survey" class="help-link" data-original-title="" title="" tabindex="-1">'+
|
// type: 'text',
|
||||||
'<i class="fa fa-question-circle"></i></a> </label>'+
|
// addRequired: false,
|
||||||
'<div class="error api-error ng-binding" id="job_templates-enable_survey-api-error" ng-bind="enable_survey_api_error"></div>'+
|
// editRequired: false,
|
||||||
'<button type="button" class="btn btn-sm btn-default" id="job_templates_edit_survey_btn" ng-click="navigateToSurvey()"><i class="fa fa-pencil"></i> Edit Survey</button>'+
|
// // readonly: true,
|
||||||
'</div>'+
|
// // ngShow: "survey_enabled",
|
||||||
'</div>'
|
// column: 2,
|
||||||
|
// awPopOver: "survey_help",
|
||||||
|
// awPopOverWatch: "survey_help",
|
||||||
|
// dataPlacement: 'right',
|
||||||
|
// dataTitle: 'Provisioning Callback URL',
|
||||||
|
// dataContainer: "body"
|
||||||
},
|
},
|
||||||
allow_callbacks: {
|
allow_callbacks: {
|
||||||
label: 'Allow Provisioning Callbacks',
|
label: 'Allow Provisioning Callbacks',
|
||||||
|
|||||||
@@ -18,32 +18,33 @@ angular.module('SurveyMakerFormDefinition', [])
|
|||||||
editTitle: 'Edit Survey', //Title in edit mode
|
editTitle: 'Edit Survey', //Title in edit mode
|
||||||
name: 'survey_maker', //entity or model name in singular form
|
name: 'survey_maker', //entity or model name in singular form
|
||||||
well: true,
|
well: true,
|
||||||
collapse: true,
|
//breadCrumbs:true,
|
||||||
collapseTitle: "Properties",
|
// collapse: true,
|
||||||
collapseMode: 'edit',
|
// collapseTitle: "Properties",
|
||||||
collapseOpen: true,
|
// collapseMode: 'edit',
|
||||||
|
// collapseOpen: true,
|
||||||
|
|
||||||
actions: {
|
// actions: {
|
||||||
stream: {
|
// stream: {
|
||||||
'class': "btn-primary btn-xs activity-btn",
|
// 'class': "btn-primary btn-xs activity-btn",
|
||||||
ngClick: "showActivity()",
|
// ngClick: "showActivity()",
|
||||||
awToolTip: "View Activity Stream",
|
// awToolTip: "View Activity Stream",
|
||||||
dataPlacement: "top",
|
// dataPlacement: "top",
|
||||||
icon: "icon-comments-alt",
|
// icon: "icon-comments-alt",
|
||||||
mode: 'edit',
|
// mode: 'edit',
|
||||||
iconSize: 'large'
|
// iconSize: 'large'
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
name: {
|
survey_name: {
|
||||||
label: 'Survey Name',
|
label: 'Survey Name',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
addRequired: true,
|
addRequired: true,
|
||||||
editRequired: true,
|
editRequired: true,
|
||||||
capitalize: false
|
capitalize: false
|
||||||
},
|
},
|
||||||
description: {
|
survey_description: {
|
||||||
label: 'Survey Description',
|
label: 'Survey Description',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
addRequired: false,
|
addRequired: false,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ angular.module('SurveyQuestionFormDefinition', [])
|
|||||||
.value('SurveyQuestionForm', {
|
.value('SurveyQuestionForm', {
|
||||||
|
|
||||||
addTitle: 'Add Question',
|
addTitle: 'Add Question',
|
||||||
editTitle: '{{ inventory_name }}',
|
editTitle: '{{ survey_name }}',
|
||||||
name: 'question_unique',
|
name: 'question_unique',
|
||||||
well: true,
|
well: true,
|
||||||
twoColumns: true,
|
twoColumns: true,
|
||||||
@@ -33,13 +33,13 @@ angular.module('SurveyQuestionFormDefinition', [])
|
|||||||
// },
|
// },
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
question_text: {
|
question_name: {
|
||||||
realName: 'question_text',
|
realName: 'question_text',
|
||||||
label: 'Question Text',
|
label: 'Question Text',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
addRequired: true,
|
addRequired: true,
|
||||||
editRequired: true,
|
editRequired: true,
|
||||||
capitalize: true,
|
capitalize: false,
|
||||||
column: 1
|
column: 1
|
||||||
},
|
},
|
||||||
question_description: {
|
question_description: {
|
||||||
@@ -51,7 +51,7 @@ angular.module('SurveyQuestionFormDefinition', [])
|
|||||||
editRequired: false,
|
editRequired: false,
|
||||||
column: 2
|
column: 2
|
||||||
},
|
},
|
||||||
response_variable_name: {
|
variable: {
|
||||||
label: 'Answer Variable Name',
|
label: 'Answer Variable Name',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
addRequired: true,
|
addRequired: true,
|
||||||
@@ -65,7 +65,7 @@ angular.module('SurveyQuestionFormDefinition', [])
|
|||||||
// init: "true"
|
// init: "true"
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
answer_type: {
|
type: {
|
||||||
realName: 'answer_type',
|
realName: 'answer_type',
|
||||||
label: 'Answer Type',
|
label: 'Answer Type',
|
||||||
type: 'select',
|
type: 'select',
|
||||||
@@ -75,23 +75,23 @@ angular.module('SurveyQuestionFormDefinition', [])
|
|||||||
column: 1
|
column: 1
|
||||||
|
|
||||||
},
|
},
|
||||||
answer_options_text: {
|
// answer_options_text: {
|
||||||
realName: 'answer_options',
|
// realName: 'answer_options',
|
||||||
label: 'Answer Options',
|
// label: 'Answer Options',
|
||||||
type: 'text',
|
// type: 'text',
|
||||||
addRequired: true,
|
// addRequired: true,
|
||||||
editRequired: true,
|
// editRequired: true,
|
||||||
ngHide: 'answer_type.type!=="text" ',
|
// ngHide: 'answer_type.type!=="text" ',
|
||||||
column: 1
|
// column: 1
|
||||||
},
|
// },
|
||||||
answer_options_multiple_choice: {
|
choices: {
|
||||||
realName: 'answer_options',
|
realName: 'answer_options',
|
||||||
label: 'Multiple Choice Options',
|
label: 'Multiple Choice Options',
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
rows: 3,
|
rows: 3,
|
||||||
addRequired: true,
|
addRequired: true,
|
||||||
editRequired: true,
|
editRequired: true,
|
||||||
ngShow: 'answer_type.type==="mc" ',
|
ngShow: 'type.type==="multipleselect" || type.type==="multiplechoice" ',
|
||||||
awPopOver: '<p>Type an option on each line.</p>'+
|
awPopOver: '<p>Type an option on each line.</p>'+
|
||||||
'<p>For example the following input:<br><br>Apple<br>\n Banana<br>\n Cherry<br><br>would be displayed as:</p>\n'+
|
'<p>For example the following input:<br><br>Apple<br>\n Banana<br>\n Cherry<br><br>would be displayed as:</p>\n'+
|
||||||
'<ol><li>Apple</li><li>Banana</li><li>Cherry</li><ol>',
|
'<ol><li>Apple</li><li>Banana</li><li>Cherry</li><ol>',
|
||||||
@@ -107,26 +107,26 @@ angular.module('SurveyQuestionFormDefinition', [])
|
|||||||
control: '<div class="row">'+
|
control: '<div class="row">'+
|
||||||
'<div class="col-xs-6"><label for="minimum"><span class="label-text">Minimum</span></label><input id="answer_min" type="number" class="form-control"></div>'+
|
'<div class="col-xs-6"><label for="minimum"><span class="label-text">Minimum</span></label><input id="answer_min" type="number" class="form-control"></div>'+
|
||||||
'<div class="col-xs-6"><label for="minimum"><span class="label-text">Maximum</span></label><input id="answer_max" type="number" class="form-control"></div></div>',
|
'<div class="col-xs-6"><label for="minimum"><span class="label-text">Maximum</span></label><input id="answer_max" type="number" class="form-control"></div></div>',
|
||||||
ngShow: 'answer_type.type==="number" ',
|
ngShow: 'type.type==="integer" || type.type==="float" ',
|
||||||
addRequired: true,
|
addRequired: true,
|
||||||
editRequired: true,
|
editRequired: true,
|
||||||
column: 1
|
column: 1
|
||||||
},
|
},
|
||||||
answer_options_json: {
|
// answer_options_json: {
|
||||||
realName: 'answer_options',
|
// realName: 'answer_options',
|
||||||
label: 'Answer Options',
|
// label: 'Answer Options',
|
||||||
type: 'textarea',
|
// type: 'textarea',
|
||||||
rows: 3,
|
// rows: 3,
|
||||||
ngShow: 'answer_type.type==="json" ',
|
// ngShow: 'type.type==="json" ',
|
||||||
addRequired: true,
|
// addRequired: true,
|
||||||
editRequired: true,
|
// editRequired: true,
|
||||||
awPopOver: '<p>Insert some good JSON!</p>',
|
// awPopOver: '<p>Insert some good JSON!</p>',
|
||||||
dataTitle: 'Answer Options',
|
// dataTitle: 'Answer Options',
|
||||||
dataPlacement: 'right',
|
// dataPlacement: 'right',
|
||||||
dataContainer: "body",
|
// dataContainer: "body",
|
||||||
column: 1
|
// column: 1
|
||||||
},
|
// },
|
||||||
default_answer: {
|
default: {
|
||||||
realName: 'default_answer',
|
realName: 'default_answer',
|
||||||
label: 'Default Answer',
|
label: 'Default Answer',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
@@ -134,12 +134,19 @@ angular.module('SurveyQuestionFormDefinition', [])
|
|||||||
editRequired: false,
|
editRequired: false,
|
||||||
column: 1
|
column: 1
|
||||||
},
|
},
|
||||||
is_required: {
|
required: {
|
||||||
label: 'Answer required or optional',
|
realName: 'default_answer',
|
||||||
type: 'custom',
|
label: 'Required',
|
||||||
column: 2,
|
type: 'checkbox',
|
||||||
control: '<div><label for="required"><span class="label-text">Required</span></label><input id="answer_required" type="radio" checked=true></div>'+
|
// checked: true,
|
||||||
'<div><label for="optional"><span class="label-text">Optional</span></label><input id="answer_optional" type="radio"></div>',
|
addRequired: false,
|
||||||
|
editRequired: false,
|
||||||
|
column: 2
|
||||||
|
// label: 'Answer required or optional',
|
||||||
|
// type: 'custom',
|
||||||
|
// column: 2,
|
||||||
|
// control: '<div><label for="required"><span class="label-text">Required</span></label><input id="answer_required" type="radio" checked=true></div>'+
|
||||||
|
// '<div><label for="optional"><span class="label-text">Optional</span></label><input id="answer_optional" type="radio"></div>',
|
||||||
|
|
||||||
}
|
}
|
||||||
// answer_options: {
|
// answer_options: {
|
||||||
|
|||||||
@@ -405,8 +405,10 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
// url = GetBasePath('jobs');
|
// url = GetBasePath('jobs');
|
||||||
// }
|
// }
|
||||||
// url += id + '/';
|
// url += id + '/';
|
||||||
|
|
||||||
url = GetBasePath('job_templates')+ id + '/launch/';
|
url = GetBasePath('job_templates')+ id + '/launch/';
|
||||||
|
|
||||||
|
|
||||||
if (scope.removePostTheJob) {
|
if (scope.removePostTheJob) {
|
||||||
scope.removePostTheJob();
|
scope.removePostTheJob();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user