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