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

@@ -185,7 +185,8 @@ InventoriesAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$lo
function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm,
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpOrganizationInit, Prompt)
RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpOrganizationInit, Prompt,
TreeInit)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@@ -215,7 +216,6 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + scope.orgnization_url + '. GET status: ' + status });
});
for (var set in relatedSets) {
console.log('inventory edit set: ' + set);
scope.search(relatedSets[set].iterator);
}
});
@@ -237,6 +237,10 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
}
}
// Load the tree view
TreeInit(related.groups);
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
@@ -247,7 +251,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to retrieve inventory: ' + $routeParams.id + '. GET status: ' + status });
});
// Save changes to the parent
scope.formSave = function() {
Rest.setUrl(defaultUrl + $routeParams.id);
@@ -316,5 +320,6 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
InventoriesEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryForm',
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpOrganizationInit', 'Prompt' ];
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpOrganizationInit', 'Prompt',
'TreeInit' ];

View File

@@ -98,42 +98,11 @@ angular.module('InventoryFormDefinition', [])
}
},
groups: {
type: 'collection',
groups: {
type: 'tree',
title: 'Groups',
iterator: 'group',
open: false,
actions: {
add: {
ngClick: "add('groups')",
icon: 'icon-plus',
awToolTip: 'Create a new group'
},
},
fields: {
name: {
key: true,
label: 'Name'
},
description: {
label: 'Description'
}
},
fieldActions: {
edit: {
ngClick: "edit('groups', \{\{ group.id \}\}, '\{\{ group.name \}\}')",
icon: 'icon-edit'
},
delete: {
ngClick: "delete('groups', \{\{ group.id \}\}, '\{\{ group.name \}\}', 'groups')",
icon: 'icon-remove',
class: 'btn-danger'
}
}
}
open: true
}
}
}); //InventoryForm

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);
});
}
}]);