mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -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:
@@ -450,12 +450,39 @@ export default [
|
|||||||
};
|
};
|
||||||
|
|
||||||
var resetAll = function() {
|
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');
|
Wait('start');
|
||||||
ConfigurationService.resetAll()
|
ConfigurationService.patchConfiguration(payload)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
populateFromApi();
|
populateFromApi();
|
||||||
$scope[formTracker.currentFormName()].$setPristine();
|
$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) {
|
.catch(function(error) {
|
||||||
ProcessErrors($scope, error, status, formDefs[formTracker.getCurrent()],
|
ProcessErrors($scope, error, status, formDefs[formTracker.getCurrent()],
|
||||||
|
|||||||
@@ -68,21 +68,6 @@ export default ['$rootScope', 'GetBasePath', 'ProcessErrors', '$q', '$http', 'Re
|
|||||||
deferred.reject(error);
|
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;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user