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