Added jsTree to show groups under Inventory/Edit

This commit is contained in:
chouseknecht
2013-05-07 11:49:33 -04:00
parent ced96a1bb3
commit 3c90f91453
78 changed files with 12964 additions and 99 deletions

View File

@@ -102,5 +102,28 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
listScope.toggle_organization(scope.organization);
}
}
}])
.factory('TreeInit', ['Alert', 'Rest', function(Alert, Rest) {
return function(groups) {
Rest.setUrl(groups);
Rest.get()
.success( function(data, status, headers, config) {
var treeData = [];
for (var i=0; i < data.results.length; i++) {
treeData.push({
data: data.results[i].name,
state: 'closed',
attr: { id: data.results[i] }
});
}
$('#tree-view').jstree({ "json_data": { data: treeData },
plugins: ['themes', 'json_data', 'ui'] });
})
.error( function(data, status, headers, config) {
Alert('Error', 'Failed to laod tree data. Url: ' + groups + ' GET status: ' + status);
});
}
}]);