AC-256 Fixed the out-of-sync tree issue, which leads to 'spurious error message'.

This commit is contained in:
chouseknecht 2013-07-24 11:45:34 -04:00
parent 7d0139d512
commit fb54484ed3
2 changed files with 32 additions and 10 deletions

View File

@ -373,7 +373,13 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
return {
addGroup: {
label: 'Add Group',
action: function(obj) { GroupsAdd({ "inventory_id": id, group_id: null }); }
action: function(obj) {
scope.group_id = null;
if (!scope.$$phase) {
scope.$digest();
}
GroupsAdd({ "inventory_id": id, group_id: null });
}
}
}
}
@ -381,16 +387,34 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
return {
addGroup: {
label: 'Add Group',
action: function(obj) { GroupsList({ "inventory_id": id, group_id: $(obj).attr('group_id') }); }
action: function(obj) {
scope.group_id = $(obj).attr('group_id');
if (!scope.$$phase) {
scope.$digest();
}
GroupsList({ "inventory_id": id, group_id: $(obj).attr('group_id') });
}
},
edit: {
label: 'Edit Group',
action: function(obj) { GroupsEdit({ "inventory_id": id, group_id: $(obj).attr('group_id') }); },
action: function(obj) {
scope.group_id = $(obj).attr('group_id');
if (!scope.$$phase) {
scope.$digest();
}
GroupsEdit({ "inventory_id": id, group_id: $(obj).attr('group_id') });
},
separator_before: true
},
"delete": {
label: 'Delete Group',
action: function(obj) { GroupsDelete({ scope: scope, "inventory_id": id, group_id: $(obj).attr('group_id') }) }
action: function(obj) {
scope.group_id = $(obj).attr('group_id');
if (!scope.$$phase) {
scope.$digest();
}
GroupsDelete({ scope: scope, "inventory_id": id, group_id: $(obj).attr('group_id') });
}
}
}
}

View File

@ -328,9 +328,9 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
.factory('GroupsDelete', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
'Prompt', 'ProcessErrors', 'GetBasePath',
'Prompt', 'ProcessErrors', 'GetBasePath', 'RefreshTree',
function($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
GetBasePath) {
GetBasePath, RefreshTree) {
return function(params) {
// Delete the selected group node. Disassociates it from its parent.
var scope = params.scope;
@ -338,9 +338,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
var inventory_id = params.inventory_id;
var obj = $('#tree-view li[group_id="' + group_id + '"]');
var parent = (obj.parent().last().prop('tagName') == 'LI') ? obj.parent().last() : obj.parent().parent().last();
//if (parent.length > 0) {
// parent = parent.last();
//}
var url;
if (parent.attr('type') == 'group') {
@ -354,7 +351,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
Rest.post({ id: group_id, disassociate: 1 })
.success( function(data, status, headers, config) {
$('#prompt-modal').modal('hide');
$('#tree-view').jstree("delete_node",obj);
RefreshTree({ scope: scope });
//$('#tree-view').jstree("delete_node",obj);
})
.error( function(data, status, headers, config) {
$('#prompt-modal').modal('hide');