mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
adding add/edit survey
This commit is contained in:
parent
e427234aec
commit
ddd88b95b5
@ -163,14 +163,14 @@ angular.module('Tower', [
|
||||
controller: 'JobTemplatesEdit'
|
||||
}).
|
||||
|
||||
when('/job_templates/add/survey', {
|
||||
when('/job_templates/:template_id/survey/add', {
|
||||
templateUrl: urlPrefix + 'partials/survey_maker.html',
|
||||
controller: 'SurveyMakerAdd'
|
||||
}).
|
||||
|
||||
when('/job_templates/:template_id/survey', {
|
||||
when('/job_templates/:template_id/survey/edit', {
|
||||
templateUrl: urlPrefix + 'partials/survey_maker.html',
|
||||
controller: 'SurveyMakerAdd'
|
||||
controller: 'SurveyMakerEdit'
|
||||
}).
|
||||
|
||||
when('/job_templates/:id/schedules', {
|
||||
|
@ -337,8 +337,8 @@ function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routePa
|
||||
};
|
||||
|
||||
//navigate to the survey maker
|
||||
$scope.navigateToSurvey = function() {
|
||||
$location.path($location.path() + '/survey');
|
||||
$scope.addSurvey = function() {
|
||||
$location.path($location.path() + '/survey/add');
|
||||
};
|
||||
}
|
||||
|
||||
@ -591,6 +591,33 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
|
||||
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) {
|
||||
$scope.rmoveLoadJobs();
|
||||
}
|
||||
@ -615,6 +642,9 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
}
|
||||
} else {
|
||||
$scope[fld] = data[fld];
|
||||
if(fld ==='survey_enabled' && $scope[fld]===true){
|
||||
$scope.$emit('EnableSurvey', fld);
|
||||
}
|
||||
}
|
||||
master[fld] = $scope[fld];
|
||||
}
|
||||
@ -819,8 +849,34 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
};
|
||||
|
||||
//navigate to the survey maker
|
||||
$scope.navigateToSurvey = function() {
|
||||
$location.path($location.path() + '/survey');
|
||||
$scope.addSurvey = function() {
|
||||
$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
|
||||
|
@ -23,28 +23,34 @@ function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routePar
|
||||
// Inject dynamic view
|
||||
var generator = GenerateForm,
|
||||
form = SurveyMakerForm,
|
||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||
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: 'text'},
|
||||
{name: 'Multiple Choice (single select)', type: 'mc'},
|
||||
{name: 'Multiple Choice (multiple select)', type: 'mc'},
|
||||
{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: 'number'},
|
||||
{name: 'Integer', type: 'integer'},
|
||||
{name: 'Float', type: 'number'}
|
||||
];
|
||||
|
||||
|
||||
generator.inject(form, { mode: 'add', 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});
|
||||
|
||||
GenerateForm.inject(SurveyQuestionForm, {mode:'modal', id:'new_question', scope:$scope, breadCrumbs: false});
|
||||
};
|
||||
$scope.addQuestion();
|
||||
|
||||
@ -84,49 +90,54 @@ function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routePar
|
||||
// "border-radius": "4px"
|
||||
// });
|
||||
// });
|
||||
$scope.finalizeQuestion= function(data){
|
||||
var html = '<div class="question_final">';
|
||||
// angular.forEach(data, function(value, key) {
|
||||
// html+='<label for="question_text"><span class="label-text">'+data.label+'</span></label>'+data.question_text;
|
||||
// });
|
||||
html+='<label for="question_text"><span class="label-text">Question Text</span></label>'+data.question_text;
|
||||
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;
|
||||
$scope.finalizeQuestion= function(data, labels){
|
||||
var key,
|
||||
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');
|
||||
$('#add_question_btn').on("click" , function(){
|
||||
$('#survey_maker_save_btn').removeAttr('disabled');
|
||||
};
|
||||
|
||||
$('#add_question_btn').on("click" , function(){
|
||||
$scope.addQuestion();
|
||||
$('#add_question_btn').attr('disabled', 'disabled');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.submitQuestion = function(){
|
||||
var form = SurveyQuestionForm,
|
||||
data = {}, labels={}, fld;
|
||||
data = {},
|
||||
labels={},
|
||||
min= "min",
|
||||
max = "max",
|
||||
fld;
|
||||
//generator.clearApiErrors();
|
||||
Wait('start');
|
||||
|
||||
try {
|
||||
for (fld in form.fields) {
|
||||
if($scope[fld]){
|
||||
data[fld] = $scope[fld];
|
||||
// labels[fld] = form.fields[fld].label;
|
||||
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;
|
||||
}
|
||||
// if (form.fields[fld].type === 'select' && fld !== 'playbook') {
|
||||
// data[fld] = $scope[fld].value;
|
||||
// } else {
|
||||
// if (fld !== 'variables') {
|
||||
// data[fld] = $scope[fld];
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Wait('stop');
|
||||
$scope.survey_questions.push(data);
|
||||
@ -145,22 +156,17 @@ function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routePar
|
||||
$scope.formSave = function () {
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
var url = GetBasePath(base);
|
||||
url += (base !== 'organizations') ? $routeParams.project_id + '/organizations/' : '';
|
||||
var url = GetBasePath(base)+ id + '/survey_spec/';
|
||||
|
||||
Rest.setUrl(url);
|
||||
Rest.post({ name: $scope.name, description: $scope.description })
|
||||
.success(function (data) {
|
||||
Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions })
|
||||
.success(function () {
|
||||
Wait('stop');
|
||||
if (base === 'organizations') {
|
||||
$rootScope.flashMessage = "New organization successfully created!";
|
||||
$location.path('/organizations/' + data.id);
|
||||
} else {
|
||||
ReturnToCaller(1);
|
||||
}
|
||||
$location.path("/job_templates/"+id);
|
||||
})
|
||||
.error(function (data, status) {
|
||||
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'
|
||||
];
|
||||
|
||||
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,
|
||||
// Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, Prompt, ClearScope, GetBasePath, Wait, Stream) {
|
||||
|
@ -240,19 +240,51 @@ angular.module('JobTemplateFormDefinition', ['SchedulesListDefinition', 'Complet
|
||||
dataTitle: 'Prompt for Extra Variables',
|
||||
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',
|
||||
column: 2,
|
||||
control: '<div class="form-group">'+
|
||||
'<div class="checkbox">'+
|
||||
'<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">'+
|
||||
'<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>'+
|
||||
'<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-enable_survey-api-error" ng-bind="enable_survey_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> Edit Survey</button>'+
|
||||
'</div>'+
|
||||
'</div>'
|
||||
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>'+
|
||||
'<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>'+
|
||||
'<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>'
|
||||
// label: 'Create Survey',
|
||||
// type: 'text',
|
||||
// addRequired: false,
|
||||
// editRequired: false,
|
||||
// // readonly: true,
|
||||
// // ngShow: "survey_enabled",
|
||||
// column: 2,
|
||||
// awPopOver: "survey_help",
|
||||
// awPopOverWatch: "survey_help",
|
||||
// dataPlacement: 'right',
|
||||
// dataTitle: 'Provisioning Callback URL',
|
||||
// dataContainer: "body"
|
||||
},
|
||||
allow_callbacks: {
|
||||
label: 'Allow Provisioning Callbacks',
|
||||
|
@ -18,32 +18,33 @@ angular.module('SurveyMakerFormDefinition', [])
|
||||
editTitle: 'Edit Survey', //Title in edit mode
|
||||
name: 'survey_maker', //entity or model name in singular form
|
||||
well: true,
|
||||
collapse: true,
|
||||
collapseTitle: "Properties",
|
||||
collapseMode: 'edit',
|
||||
collapseOpen: true,
|
||||
//breadCrumbs:true,
|
||||
// collapse: true,
|
||||
// collapseTitle: "Properties",
|
||||
// collapseMode: 'edit',
|
||||
// collapseOpen: true,
|
||||
|
||||
actions: {
|
||||
stream: {
|
||||
'class': "btn-primary btn-xs activity-btn",
|
||||
ngClick: "showActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
}
|
||||
},
|
||||
// actions: {
|
||||
// stream: {
|
||||
// 'class': "btn-primary btn-xs activity-btn",
|
||||
// ngClick: "showActivity()",
|
||||
// awToolTip: "View Activity Stream",
|
||||
// dataPlacement: "top",
|
||||
// icon: "icon-comments-alt",
|
||||
// mode: 'edit',
|
||||
// iconSize: 'large'
|
||||
// }
|
||||
// },
|
||||
|
||||
fields: {
|
||||
name: {
|
||||
survey_name: {
|
||||
label: 'Survey Name',
|
||||
type: 'text',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
capitalize: false
|
||||
},
|
||||
description: {
|
||||
survey_description: {
|
||||
label: 'Survey Description',
|
||||
type: 'text',
|
||||
addRequired: false,
|
||||
|
@ -15,7 +15,7 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
.value('SurveyQuestionForm', {
|
||||
|
||||
addTitle: 'Add Question',
|
||||
editTitle: '{{ inventory_name }}',
|
||||
editTitle: '{{ survey_name }}',
|
||||
name: 'question_unique',
|
||||
well: true,
|
||||
twoColumns: true,
|
||||
@ -33,13 +33,13 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
// },
|
||||
|
||||
fields: {
|
||||
question_text: {
|
||||
question_name: {
|
||||
realName: 'question_text',
|
||||
label: 'Question Text',
|
||||
type: 'text',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
capitalize: true,
|
||||
capitalize: false,
|
||||
column: 1
|
||||
},
|
||||
question_description: {
|
||||
@ -51,7 +51,7 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
editRequired: false,
|
||||
column: 2
|
||||
},
|
||||
response_variable_name: {
|
||||
variable: {
|
||||
label: 'Answer Variable Name',
|
||||
type: 'text',
|
||||
addRequired: true,
|
||||
@ -65,7 +65,7 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
// init: "true"
|
||||
// }
|
||||
},
|
||||
answer_type: {
|
||||
type: {
|
||||
realName: 'answer_type',
|
||||
label: 'Answer Type',
|
||||
type: 'select',
|
||||
@ -75,23 +75,23 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
column: 1
|
||||
|
||||
},
|
||||
answer_options_text: {
|
||||
realName: 'answer_options',
|
||||
label: 'Answer Options',
|
||||
type: 'text',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
ngHide: 'answer_type.type!=="text" ',
|
||||
column: 1
|
||||
},
|
||||
answer_options_multiple_choice: {
|
||||
// answer_options_text: {
|
||||
// realName: 'answer_options',
|
||||
// label: 'Answer Options',
|
||||
// type: 'text',
|
||||
// addRequired: true,
|
||||
// editRequired: true,
|
||||
// ngHide: 'answer_type.type!=="text" ',
|
||||
// column: 1
|
||||
// },
|
||||
choices: {
|
||||
realName: 'answer_options',
|
||||
label: 'Multiple Choice Options',
|
||||
type: 'textarea',
|
||||
rows: 3,
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
ngShow: 'answer_type.type==="mc" ',
|
||||
ngShow: 'type.type==="multipleselect" || type.type==="multiplechoice" ',
|
||||
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'+
|
||||
'<ol><li>Apple</li><li>Banana</li><li>Cherry</li><ol>',
|
||||
@ -107,26 +107,26 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
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">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,
|
||||
editRequired: true,
|
||||
column: 1
|
||||
},
|
||||
answer_options_json: {
|
||||
realName: 'answer_options',
|
||||
label: 'Answer Options',
|
||||
type: 'textarea',
|
||||
rows: 3,
|
||||
ngShow: 'answer_type.type==="json" ',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
awPopOver: '<p>Insert some good JSON!</p>',
|
||||
dataTitle: 'Answer Options',
|
||||
dataPlacement: 'right',
|
||||
dataContainer: "body",
|
||||
column: 1
|
||||
},
|
||||
default_answer: {
|
||||
// answer_options_json: {
|
||||
// realName: 'answer_options',
|
||||
// label: 'Answer Options',
|
||||
// type: 'textarea',
|
||||
// rows: 3,
|
||||
// ngShow: 'type.type==="json" ',
|
||||
// addRequired: true,
|
||||
// editRequired: true,
|
||||
// awPopOver: '<p>Insert some good JSON!</p>',
|
||||
// dataTitle: 'Answer Options',
|
||||
// dataPlacement: 'right',
|
||||
// dataContainer: "body",
|
||||
// column: 1
|
||||
// },
|
||||
default: {
|
||||
realName: 'default_answer',
|
||||
label: 'Default Answer',
|
||||
type: 'text',
|
||||
@ -134,12 +134,19 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
editRequired: false,
|
||||
column: 1
|
||||
},
|
||||
is_required: {
|
||||
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>',
|
||||
required: {
|
||||
realName: 'default_answer',
|
||||
label: 'Required',
|
||||
type: 'checkbox',
|
||||
// checked: true,
|
||||
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: {
|
||||
|
@ -405,8 +405,10 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
||||
// url = GetBasePath('jobs');
|
||||
// }
|
||||
// url += id + '/';
|
||||
|
||||
url = GetBasePath('job_templates')+ id + '/launch/';
|
||||
|
||||
|
||||
if (scope.removePostTheJob) {
|
||||
scope.removePostTheJob();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user