vigiboard / vigiboard / public / js / tree.js @ 2bcebf54
History | View | Annotate | Download (1.6 KB)
1 |
/**
|
---|---|
2 |
* VigiBoard, composant de Vigilo.
|
3 |
* Copyright (C) 2009-2016 CS-SI
|
4 |
* Licence : GNU GPL v2 ou superieure
|
5 |
*
|
6 |
*/
|
7 |
|
8 |
/*
|
9 |
* Affichage en arbre des groupes d'hôtes.
|
10 |
*/
|
11 |
var SelectGroupTree = new Class({ |
12 |
Implements: [Options, Events],
|
13 |
|
14 |
options: {
|
15 |
title: '', |
16 |
labelId: null, |
17 |
idId: null |
18 |
}, |
19 |
|
20 |
initialize: function(options) { |
21 |
this.setOptions(options);
|
22 |
|
23 |
/* L'objet tree se réfère à un élément div*/
|
24 |
this.container = new Element('div'); |
25 |
this.container.setStyle("padding", "0 10px 10px 10px"); |
26 |
this.tree = new Jx.Tree({parent: this.container}); |
27 |
|
28 |
this.tree = new GroupTree({ |
29 |
parent: this.container, |
30 |
url: app_path + '/get_groups', |
31 |
itemName: "item", |
32 |
groupsonly: true, |
33 |
onItemClick: this.itemSelected.bind(this), |
34 |
onGroupClick: this.itemSelected.bind(this) |
35 |
}); |
36 |
|
37 |
this.dlg = new Jx.Dialog({ |
38 |
label: this.options.title, |
39 |
modal: true, |
40 |
resize: true, |
41 |
content: this.container |
42 |
}); |
43 |
}, |
44 |
|
45 |
open: function() { |
46 |
this.dlg.open();
|
47 |
}, |
48 |
|
49 |
load: function() { |
50 |
this.tree.load();
|
51 |
}, |
52 |
|
53 |
reload: function() { |
54 |
this.tree.clear();
|
55 |
this.tree.load();
|
56 |
}, |
57 |
|
58 |
itemSelected: function(item) { |
59 |
if (this.options.labelId !== null) { |
60 |
$(this.options.labelId).set('value', item.name); |
61 |
} |
62 |
if (this.options.idId !== null) { |
63 |
$(this.options.idId).set('value', item.id); |
64 |
} |
65 |
this.dlg.close();
|
66 |
this.fireEvent("select", [item]); |
67 |
} |
68 |
|
69 |
}); |