mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
Revert all should only revert the fields on the current tab
instead of reverting all the settings, throughout CTiT
This commit is contained in:
parent
2d9df199c6
commit
d6c1842de9
@ -450,12 +450,39 @@ export default [
|
||||
};
|
||||
|
||||
var resetAll = function() {
|
||||
var keys = _.keys(formDefs[formTracker.getCurrent()].fields);
|
||||
var payload = {};
|
||||
clearApiErrors();
|
||||
_.each(keys, function(key) {
|
||||
payload[key] = $scope.configDataResolve[key].default;
|
||||
});
|
||||
|
||||
Wait('start');
|
||||
ConfigurationService.resetAll()
|
||||
ConfigurationService.patchConfiguration(payload)
|
||||
.then(function() {
|
||||
populateFromApi();
|
||||
$scope[formTracker.currentFormName()].$setPristine();
|
||||
$scope.$broadcast('CUSTOM_LOGO_reverted');
|
||||
|
||||
let keys = _.keys(formDefs[formTracker.getCurrent()].fields);
|
||||
_.each(keys, function(key) {
|
||||
$scope[key] = $scope.configDataResolve[key].default;
|
||||
if($scope[key + '_field'].type === "select"){
|
||||
// We need to re-instantiate the Select2 element
|
||||
// after resetting the value. Example:
|
||||
$scope.$broadcast(key+'_populated', null, false);
|
||||
}
|
||||
else if($scope[key + '_field'].reset === "CUSTOM_LOGO"){
|
||||
$scope.$broadcast(key+'_reverted');
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
.catch(function(error) {
|
||||
ProcessErrors($scope, error, status, formDefs[formTracker.getCurrent()],
|
||||
|
||||
@ -68,21 +68,6 @@ export default ['$rootScope', 'GetBasePath', 'ProcessErrors', '$q', '$http', 'Re
|
||||
deferred.reject(error);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
resetAll: function() {
|
||||
var deferred = $q.defer();
|
||||
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
.success(function(data) {
|
||||
deferred.resolve(data);
|
||||
})
|
||||
.error(function(error) {
|
||||
deferred.reject(error);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user