-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
162 lines (138 loc) · 4.65 KB
/
index.html
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>gumga-tree</title>
<link rel="stylesheet"
href="node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet"
href="dist/gumga-tree-ng.css">
</head>
<body ng-controller="ctrl"><br><br>
<!-- DEMO ITEM SELECTED -->
<style media="screen">
body {
background: #f5f5f5;
}
gumga-tree-ng gumga-tree-ng-child .gumga-tree-ng-item-child.tree-selected {
background: red;
}
</style>
<main>
<div class="container">
<div class="row">
<div class="col-md-6">
<gumga-tree-ng ng-model="pessoas"
selected-item="teste"
children="filhos"
disabled-drag-drop="true"
options="options">
<div style="width: 200px">
<span>{{$child.name}}</span>
<button ng-click="cliquei($child)"
style="float: right;">CLIQUE</button>
</div>
</gumga-tree-ng>
</div>
<div class="col-md-6">
<pre>{{teste|json}}</pre>
</div>
<div class="col-mg-2">
<button ng-click="coloca()">Coloca</button>
<button ng-click="adiciona()">Adiciona</button>
<button ng-click="options.actions.toggleAll()">Toggle all</button>
<button ng-click="options.actions.removeAll()">Remove all</button>
</div>
</div>
</div>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript"
src="node_modules/angular/angular.min.js"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<script type="text/javascript"
src="dist/gumga-tree-ng.js"></script>
<script type="text/javascript">
angular.module('app', ['gumga.tree']).controller('ctrl', function ($scope, $timeout) {
$scope.options = {
events: {
toggle: () => {
console.log("gusdbh")
}
},
actions: {
maxDepth: 3
},
conditions: {
disabled: (child) => {
return true
}
}
};
$timeout(function () {
$scope.options.actions.toggleAll()
})
$scope.pessoas = [
{
name: 'Maria',
filhos: [
{
name: "Regina",
filhos: [
{
name: "Mateus"
}
]
}
]
},
{
name: "Sonia",
filhos: [
{
name: "Lucas"
},
{
name: "Mariana"
}
]
}
]
$scope.coloca = () => {
$scope.pessoas.push({
name: "Joaquem",
filhos: [
{
name: "Rose"
},
{
name: "Mora"
}
]
})
}
$scope.adiciona = () => {
$scope.pessoas[0].filhos.push({
name: "Teste1",
filhos: [
{
name: "Teste2"
},
{
name: "Teste3"
}
]
})
}
$scope.cliquei = ($child) => {
$child.filhos.push({
name: "Inserindo"
})
console.log($child)
}
})
</script>
</body>
</html>