mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 20:30:46 -03:30
Merge pull request #5394 from jaredevantabor/ctit-codemirror
CTiT CodeMirror Textareas
This commit is contained in:
commit
50add8e05f
@ -60,9 +60,11 @@ export default [
|
||||
}
|
||||
|
||||
var activeForm = function() {
|
||||
|
||||
if(!$scope.$parent[formTracker.currentFormName()].$dirty) {
|
||||
authVm.activeAuthForm = authVm.dropdownValue;
|
||||
formTracker.setCurrentAuth(authVm.activeAuthForm);
|
||||
startCodeMirrors();
|
||||
} else {
|
||||
var msg = i18n._('You have unsaved changes. Would you like to proceed <strong>without</strong> saving?');
|
||||
var title = i18n._('Warning: Unsaved Changes');
|
||||
@ -115,28 +117,36 @@ export default [
|
||||
|
||||
var authForms = [{
|
||||
formDef: configurationAzureForm,
|
||||
id: 'auth-azure-form'
|
||||
id: 'auth-azure-form',
|
||||
name: 'azure'
|
||||
}, {
|
||||
formDef: configurationGithubForm,
|
||||
id: 'auth-github-form'
|
||||
id: 'auth-github-form',
|
||||
name: 'github'
|
||||
}, {
|
||||
formDef: configurationGithubOrgForm,
|
||||
id: 'auth-github-org-form'
|
||||
id: 'auth-github-org-form',
|
||||
name: 'github_org'
|
||||
}, {
|
||||
formDef: configurationGithubTeamForm,
|
||||
id: 'auth-github-team-form'
|
||||
id: 'auth-github-team-form',
|
||||
name: 'github_team'
|
||||
}, {
|
||||
formDef: configurationGoogleForm,
|
||||
id: 'auth-google-form'
|
||||
id: 'auth-google-form',
|
||||
name: 'google_oauth'
|
||||
}, {
|
||||
formDef: configurationLdapForm,
|
||||
id: 'auth-ldap-form'
|
||||
id: 'auth-ldap-form',
|
||||
name: 'ldap'
|
||||
}, {
|
||||
formDef: configurationRadiusForm,
|
||||
id: 'auth-radius-form'
|
||||
id: 'auth-radius-form',
|
||||
name: 'radius'
|
||||
}, {
|
||||
formDef: configurationSamlForm,
|
||||
id: 'auth-saml-form'
|
||||
id: 'auth-saml-form',
|
||||
name: 'saml'
|
||||
}, ];
|
||||
|
||||
var forms = _.pluck(authForms, 'formDef');
|
||||
@ -161,6 +171,28 @@ export default [
|
||||
form.buttons.save.disabled = $rootScope.user_is_system_auditor;
|
||||
});
|
||||
|
||||
function startCodeMirrors(){
|
||||
// Attach codemirror to fields that need it
|
||||
let form = _.find(authForms, function(form){
|
||||
return form.name === $scope.authVm.activeAuthForm;
|
||||
});
|
||||
_.each(form.formDef.fields, function(field) {
|
||||
// Codemirror balks at empty values so give it one
|
||||
if($scope.$parent[field.name] === null && field.codeMirror) {
|
||||
$scope.$parent[field.name] = '{}';
|
||||
}
|
||||
if(field.codeMirror) {
|
||||
ParseTypeChange({
|
||||
scope: $scope.$parent,
|
||||
variable: field.name,
|
||||
parse_variable: 'parseType',
|
||||
field_id: form.formDef.name + '_' + field.name
|
||||
});
|
||||
$scope.parseTypeChange('parseType', field.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addFieldInfo(form, key) {
|
||||
_.extend(form.fields[key], {
|
||||
awPopOver: ($scope.$parent.configDataResolve[key].defined_in_file) ?
|
||||
@ -195,24 +227,7 @@ export default [
|
||||
var dropdownRendered = false;
|
||||
|
||||
$scope.$on('populated', function() {
|
||||
// Attach codemirror to fields that need it
|
||||
_.each(authForms, function(form) {
|
||||
_.each(form.formDef.fields, function(field) {
|
||||
// Codemirror balks at empty values so give it one
|
||||
if($scope.$parent[field.name] === null && field.codeMirror) {
|
||||
$scope.$parent[field.name] = '{}';
|
||||
}
|
||||
if(field.codeMirror) {
|
||||
ParseTypeChange({
|
||||
scope: $scope.$parent,
|
||||
variable: field.name,
|
||||
parse_variable: 'parseType',
|
||||
field_id: form.formDef.name + '_' + field.name,
|
||||
readonly: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
startCodeMirrors();
|
||||
|
||||
// Create Select2 fields
|
||||
var opts = [];
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
export default [
|
||||
'$scope', '$rootScope', '$state', '$stateParams', '$timeout', '$q', 'Alert', 'ClearScope',
|
||||
'ConfigurationService', 'ConfigurationUtils', 'CreateDialog', 'CreateSelect2', 'i18n', 'ParseTypeChange', 'ProcessErrors', 'Store',
|
||||
'Wait', 'configDataResolve',
|
||||
'Wait', 'configDataResolve', 'ToJSON',
|
||||
//Form definitions
|
||||
'configurationAzureForm',
|
||||
'configurationGithubForm',
|
||||
@ -25,7 +25,7 @@ export default [
|
||||
function(
|
||||
$scope, $rootScope, $state, $stateParams, $timeout, $q, Alert, ClearScope,
|
||||
ConfigurationService, ConfigurationUtils, CreateDialog, CreateSelect2, i18n, ParseTypeChange, ProcessErrors, Store,
|
||||
Wait, configDataResolve,
|
||||
Wait, configDataResolve, ToJSON,
|
||||
//Form definitions
|
||||
configurationAzureForm,
|
||||
configurationGithubForm,
|
||||
@ -363,7 +363,9 @@ export default [
|
||||
if($scope[key] === '') {
|
||||
payload[key] = {};
|
||||
} else {
|
||||
payload[key] = JSON.parse($scope[key]);
|
||||
// payload[key] = JSON.parse($scope[key]);
|
||||
payload[key] = ToJSON($scope.parseType,
|
||||
$scope[key]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user