|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ext.ns('Tine.widgets', 'Tine.widgets.tree'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tine.widgets.tree.Loader = Ext.extend(Ext.tree.TreeLoader, { |
|
|
|
|
|
|
|
displayLength: 25, |
|
|
|
|
|
|
|
|
|
app: null, |
|
|
|
|
|
|
|
|
|
|
|
method: null, |
|
|
|
|
|
|
|
|
|
|
|
filter: null, |
|
|
|
url: 'index.php', |
|
|
|
|
|
|
|
|
|
createNode: function() { |
|
this.inspectCreateNode.apply(this, arguments); |
|
return Tine.widgets.tree.Loader.superclass.createNode.apply(this, arguments); |
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getParams: function(node) { |
|
return { |
|
method: this.method, |
|
filter: this.filter |
|
}; |
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
inspectCreateNode: Ext.EmptyFn, |
|
|
|
processResponse: function(response, node, callback, scope) { |
|
|
|
var o = response.responseData || Ext.decode(response.responseText); |
|
response.responseData = o.hasOwnProperty('totalcount') ? o.results : o; |
|
|
|
|
|
var newResponse = []; |
|
|
|
|
|
Ext.each(response.responseData, function (node) { |
|
var parentNode = newResponse; |
|
|
|
if (! Ext.isString(node.name)) { |
|
parentNode.push(node); |
|
return; |
|
} |
|
|
|
|
|
var parts = Ext.isString(node.name) ? node.name.split("/") : ['']; |
|
var containerName = parts[parts.length-1]; |
|
|
|
|
|
|
|
if (parts[0] == "") { |
|
parts.shift(); |
|
} |
|
parts.pop(); |
|
|
|
Ext.each(parts, function (part, idx) { |
|
var child = this.findNodeByName(part, parentNode); |
|
|
|
if (! child) { |
|
var child = { |
|
'name': part, |
|
'id': part, |
|
'children': [], |
|
'leaf': false, |
|
'editable': false, |
|
'draggable': false, |
|
'allowDrag': false, |
|
'allowDrop': false, |
|
'singleClickExpand': true, |
|
'listeners': {'beforeclick' : function(n,e) {n.toggle(); return false}} |
|
}; |
|
parentNode.push(child); |
|
} |
|
|
|
parentNode = child.children; |
|
}, this); |
|
|
|
node.longName = node.name; |
|
|
|
|
|
|
|
node.text = node.name = containerName; |
|
|
|
parentNode.push(node); |
|
}, this); |
|
|
|
response.responseData = newResponse; |
|
|
|
return Tine.widgets.tree.Loader.superclass.processResponse.apply(this, arguments); |
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
findNodeByName: function (name, nodes) { |
|
var ret = false; |
|
Ext.each(nodes, function (node, idx) { |
|
if (node && node.name && node.name == name && Ext.isArray(node.children)) { |
|
ret = node; |
|
} |
|
}, this); |
|
return ret; |
|
} |
|
}); |
|
|