mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 13:11:19 -03:30
fixing reset for CodeMirror instances
This commit is contained in:
parent
331be6c803
commit
63f27a120f
@ -171,26 +171,37 @@ export default [
|
||||
form.buttons.save.disabled = $rootScope.user_is_system_auditor;
|
||||
});
|
||||
|
||||
function startCodeMirrors(){
|
||||
// Attach codemirror to fields that need it
|
||||
function startCodeMirrors(key){
|
||||
|
||||
function createIt(name){
|
||||
ParseTypeChange({
|
||||
scope: $scope.$parent,
|
||||
variable: name,
|
||||
parse_variable: 'parseType',
|
||||
field_id: form.formDef.name + '_' + name
|
||||
});
|
||||
$scope.parseTypeChange('parseType', name);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
if(!key){
|
||||
// Attach codemirror to fields that need it
|
||||
_.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) {
|
||||
createIt(field.name)
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(key){
|
||||
createIt(key);
|
||||
}
|
||||
}
|
||||
|
||||
function addFieldInfo(form, key) {
|
||||
@ -252,6 +263,10 @@ export default [
|
||||
populateLDAPGroupType(flag);
|
||||
});
|
||||
|
||||
$scope.$on('codeMirror_populated', function(e, key) {
|
||||
startCodeMirrors(key);
|
||||
});
|
||||
|
||||
$scope.$on('populated', function() {
|
||||
startCodeMirrors();
|
||||
populateLDAPGroupType();
|
||||
|
||||
@ -300,12 +300,16 @@ export default [
|
||||
// after resetting the value. Example:
|
||||
$scope.$broadcast(key+'_populated', null, false);
|
||||
}
|
||||
if($scope[key + '_field'].reset === "CUSTOM_LOGO"){
|
||||
else if($scope[key + '_field'].reset === "CUSTOM_LOGO"){
|
||||
$scope.$broadcast(key+'_reverted');
|
||||
}
|
||||
if($scope[key + '_field'].type === "textarea" && _.isArray($scope.configDataResolve[key].default)){
|
||||
else if($scope[key + '_field'].type === "textarea" && _.isArray($scope.configDataResolve[key].default)){
|
||||
$scope[key] = ConfigurationUtils.arrayToList($scope[key], key);
|
||||
}
|
||||
else if($scope[key + '_field'].hasOwnProperty('codeMirror')){
|
||||
$scope[key] = '{}';
|
||||
$scope.$broadcast('codeMirror_populated', key);
|
||||
}
|
||||
loginUpdate();
|
||||
})
|
||||
.catch(function(error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user