AC-221 No longer refreshing the tree after a group edit. Just refreshing the modified node's title. Also, changed Inventory save (on edit) to stay on page, update tree inventory node title and flash a 'success' message. Makes much more sense.

This commit is contained in:
chouseknecht 2013-07-23 11:41:44 -04:00
parent 6e2a5bb722
commit 8ffc6870c3
3 changed files with 32 additions and 8 deletions

View File

@ -184,7 +184,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt,
OrganizationList, TreeInit, GetBasePath, GroupsList, GroupsAdd, GroupsEdit, LoadInventory,
GroupsDelete, HostsList, HostsAdd, HostsEdit, HostsDelete, RefreshTree, ParseTypeChange)
GroupsDelete, HostsList, HostsAdd, HostsEdit, HostsDelete, RefreshGroupName, ParseTypeChange)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@ -247,6 +247,23 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
RefreshTree({ scope: scope });
}
function PostSave() {
// Make sure the inventory name in the tree is correct
RefreshGroupName($('#inventory-node'), scope['inventory_name'], scope['inventory_description']);
// Reset the form to disable the form action buttons
scope[form.name + '_form'].$setPristine();
// Show the flash message for 5 seconds, letting the user know the save worked
scope['flashMessage'] = 'Your changes were successfully saved!';
setTimeout(function() {
scope['flashMessage'] = null;
if (!scope.$$phase) {
scope.$digest();
}
}, 5000);
}
// Save
scope.formSave = function() {
try {
@ -282,7 +299,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
Rest.setUrl(data.related.variable_data);
Rest.put(json_data)
.success( function(data, status, headers, config) {
$location.path('/inventories');
PostSave();
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form,
@ -290,7 +307,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
});
}
else {
$location.path('/inventories');
PostSave();
}
})
.error( function(data, status, headers, config) {
@ -471,7 +488,7 @@ InventoriesEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$l
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt',
'OrganizationList', 'TreeInit', 'GetBasePath', 'GroupsList', 'GroupsAdd', 'GroupsEdit', 'LoadInventory',
'GroupsDelete', 'HostsList', 'HostsAdd', 'HostsEdit', 'HostsDelete', 'RefreshTree',
'GroupsDelete', 'HostsList', 'HostsAdd', 'HostsEdit', 'HostsDelete', 'RefreshGroupName',
'ParseTypeChange'
];

View File

@ -180,9 +180,9 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
.factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
'Prompt', 'ProcessErrors', 'GetBasePath', 'RefreshTree', 'ParseTypeChange',
'Prompt', 'ProcessErrors', 'GetBasePath', 'RefreshGroupName', 'ParseTypeChange',
function($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
GetBasePath, RefreshTree, ParseTypeChange) {
GetBasePath, RefreshGroupName, ParseTypeChange) {
return function(params) {
var group_id = params.group_id;
@ -293,7 +293,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
Rest.put(json_data)
.success( function(data, status, headers, config) {
$('#form-modal').modal('hide');
RefreshTree({ scope: scope });
RefreshGroupName($('li[group_id="' + group_id + '"]'), scope['name'])
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form,
@ -302,7 +302,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
}
else {
$('#form-modal').modal('hide');
RefreshTree({ scope: scope });
RefreshGroupName($('li[group_id="' + group_id + '"]'), scope['name']);
}
})
.error( function(data, status, headers, config) {

View File

@ -243,6 +243,13 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
}
}])
.factory('RefreshGroupName', [ function() {
return function(node, name, description) {
// Call after GroupsEdit controller saves changes
$('#tree-view').jstree('rename_node', node, name);
node.attr('description', description);
}
}])
.factory('RefreshTree', ['Alert', 'Rest', 'Authorization', '$http', 'TreeInit', 'LoadInventory',
function(Alert, Rest, Authorization, $http, TreeInit, LoadInventory) {