1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Added survey buttons to the job templates form(s) and removed the checkbox

This commit is contained in:
Michael Abashian 2016-03-09 16:45:47 -05:00
parent 92f8885946
commit 0b531adaf3
6 changed files with 11 additions and 83 deletions

View File

@ -221,29 +221,6 @@ export default
dataTitle: 'Prompt for Extra Variables',
dataContainer: "body"
},
survey_enabled: {
label: 'Enable Survey',
type: 'checkbox',
addRequired: false,
editRequird: false,
awFeature: 'surveys',
ngChange: "surveyEnabled()",
ngHide: "job_type.value === 'scan'",
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,
ngHide: "job_type.value === 'scan'" ,
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>'+
'<div class="error ng-hide" id="job-template-survey-error" ng-show="invalid_survey">A survey is enabled but it does not exist. Create a survey or uncheck the Enable Survey box to disable the survey. </div>'
},
become_enabled: {
label: 'Enable Privilege Escalation',
type: 'checkbox',
@ -294,6 +271,13 @@ export default
dataPlacement: 'right',
dataTitle: "Host Config Key",
dataContainer: "body"
},
survey: {
type: 'custom',
column: 2,
ngHide: "job_type.value === 'scan'" ,
control: '<button type="button" class="btn btn-sm Form-buttonDefault" id="job_templates_create_survey_btn" ng-show="!survey_exists" ng-click="addSurvey()">ADD SURVEY</button>'+
'<button type="button" class="btn btn-sm Form-buttonDefault" id="job_templates_edit_survey_btn" ng-show="survey_exists" ng-click="editSurvey()">EDIT SURVEY</button>'
}
},

View File

@ -487,7 +487,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', listGenerator.name,
minWidth: 400,
title: 'Host Properties',
id: 'host-modal-dialog',
clonseOnEscape: false,
closeOnEscape: false,
form: form_scope.host_form,
onClose: function() {
Wait('stop');

View File

@ -92,17 +92,7 @@ angular.module('JobTemplatesHelper', ['Utilities'])
} else {
scope[fld] = data[fld];
if(fld ==='survey_enabled'){
// $scope.$emit('EnableSurvey', fld);
$('#job_templates_survey_enabled_chbox').attr('checked', scope[fld]);
if(Empty(data.summary_fields.survey)) {
$('#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();
if(!Empty(data.summary_fields.survey)) {
scope.survey_exists = true;
}
}

View File

@ -139,7 +139,7 @@ export default
minWidth: 400,
title: 'Inventory Properties',
id: 'inventory-edit-modal-dialog',
clonseOnEscape: false,
closeOnEscape: false,
form: form_scope.inventory_form,
onClose: function() {
Wait('stop');

View File

@ -299,11 +299,6 @@
Wait('stop');
$scope.survey_exists = true;
$scope.invalid_survey = false;
$('#job_templates_survey_enabled_chbox').attr('checked', true);
$('#job_templates_delete_survey_btn').show();
$('#job_templates_edit_survey_btn').show();
$('#job_templates_create_survey_btn').hide();
});

View File

@ -316,16 +316,8 @@ export default
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 {
if(data && data.name){
$scope.survey_exists = true;
$('#job_templates_delete_survey_btn').show();
$('#job_templates_edit_survey_btn').show();
$('#job_templates_create_survey_btn').hide();
}
})
.error(function (data, status) {
@ -343,11 +335,6 @@ export default
Wait('stop');
$scope.survey_exists = true;
$scope.invalid_survey = false;
$('#job_templates_survey_enabled_chbox').attr('checked', true);
$('#job_templates_delete_survey_btn').show();
$('#job_templates_edit_survey_btn').show();
$('#job_templates_create_survey_btn').hide();
});
if ($scope.removeLoadJobs) {
@ -564,33 +551,5 @@ export default
});
}
};
// handler for 'Enable Survey' button
$scope.surveyEnabled = function(){
Rest.setUrl(defaultUrl + id+ '/');
Rest.patch({"survey_enabled": $scope.survey_enabled})
.success(function (data) {
if(Empty(data.summary_fields.survey)){
$('#job_templates_delete_survey_btn').hide();
$('#job_templates_edit_survey_btn').hide();
$('#job_templates_create_survey_btn').show();
}
else{
$scope.survey_exists = true;
$('#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 save survey_enabled: ' + $stateParams.template_id + '. GET status: ' + status
});
});
};
}
];