blob: bc27a9021cc8499c0ff0f2eebbbcd8710b30d492 (
plain)
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
|
odoo.define("web.collections", function (require) {
"use strict";
var Class = require("web.Class");
/**
* Allows to build a tree representation of a data.
*/
var Tree = Class.extend({
/**
* @constructor
* @param {*} data - the data associated to the root node
*/
init: function (data) {
this._data = data;
this._children = [];
},
//----------------------------------------------------------------------
// Public
//----------------------------------------------------------------------
/**
* Returns the root's associated data.
*
* @returns {*}
*/
getData: function () {
return this._data;
},
/**
* Adds a child tree.
*
* @param {Tree} tree
*/
addChild: function (tree) {
this._children.push(tree);
},
});
return {
Tree: Tree,
};
});
|