-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAngularEx.ModulesDumper.Plugin.Sample.js
More file actions
70 lines (60 loc) · 2.41 KB
/
AngularEx.ModulesDumper.Plugin.Sample.js
File metadata and controls
70 lines (60 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(function (angular) {
var mi = angular.module('angularEx.directives', ['angularTreeview']);
angularEx.addRequiretongApp('angularEx.directives');
mi.directive('angularex', angularExFactory);
function angularExFactory() {
var module = angularEx.getModulesTree(),
tv = [convertToTreeview(module)];
function convertToTreeview(module) {
var tv = {
"label": module.name,
"id": module.name,
"children": []
},
requires = { "label": 'requires', "id": 'requires', "children": [] };
getItems('controllers', module, tv);
getItems('directives', module, tv);
getItems('filter', module, tv);
getItems('animation', module, tv);
getItems('provider', module, tv);
getItems('factory', module, tv);
getItems('service', module, tv);
getItems('constant', module, tv);
if (module.requires) {
tv.children.push(requires);
module.requires.forEach(function(r) {
requires.children.push(convertToTreeview(r));
});
}
return tv;
}
function getItems(name, amodule, treeitem) {
var children = [],
item = {
"label": name,
"id": name,
"children": children
}
if (amodule[name] && Array.isArray(amodule[name])) {
amodule[name].forEach(function(item) {
children.push({ "label": item, "id": item, "children": [] });
});
}
if (children.length > 0) {
treeitem.children.push(item);
}
}
return {
repelace: true,
template: '<div ng-click="open()" class="btn navbar-fixed-top" style="width:50px;"> + </div><div ng-if="isOpen" angular-treeview="true" tree-id="abc" tree-model="treedata" node-id="id" node-label="label" node-children="children" ></div>',
link: function (scope, element, attr) {
scope.isOpen = false;
scope.treedata = tv;
scope.open = function() {
scope.isOpen = !scope.isOpen;
return scope.isOpen;
};
}
};
}
})(angular);