AC-657 Fixed order of operations for prompting user to approve delete, starting spinner, sending request to API, stoping spinner and refreshing page. The key is starting the spinner using the modal.on.hidden.bs.modal to start the spinner and then not stopping it until inside postrefresh event. Applied the fix to all controllers and tested.

This commit is contained in:
Chris Houseknecht
2013-11-20 06:06:13 +00:00
parent 4bc15a4392
commit 0127680805
8 changed files with 65 additions and 42 deletions

View File

@@ -36,6 +36,10 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
scope.removePostRefresh();
}
scope.removePostRefresh = scope.$on('PostRefresh', function() {
// Cleanup after a delete
Wait('stop');
$('#prompt-modal').off();
if (scope.projects) {
for (var i=0; i < scope.projects.length; i++) {
if (scope.projects[i].status == 'ok') {
@@ -114,20 +118,18 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
scope.deleteProject = function(id, name) {
var action = function() {
Wait('start');
$('#prompt-modal').on('hiden.bs.modal', function(){ Wait('start'); });
$('#prompt-modal').modal('hide');
var url = defaultUrl + id + '/';
Rest.setUrl(url);
Rest.destroy()
.success( function(data, status, headers, config) {
Wait('stop');
$('#prompt-modal').modal('hide');
scope.search(list.iterator);
})
.error( function(data, status, headers, config) {
Wait('stop');
$('#prompt-modal').modal('hide');
ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
});
};