preload parent, child data

tree@624cc78
This commit is contained in:
Anton Dyudin 2016-05-03 14:23:01 -07:00
parent 998b7baca6
commit 7983d369b1
3 changed files with 45 additions and 15 deletions

View File

@ -3,7 +3,10 @@
:: ::
/? 310 /? 310
/= dat /% /tree-json/ :: default include /= dat /% /tree-json/ :: default include
/= dat-sen /| /: /%%/ /% /tree-json/ :: default include
/~ ~
==
^- marl ^- marl
;= ;script(type "text/javascript"): window.tree = {(pojo (joba %data dat))} ;= ;script(type "text/javascript"): window.tree = {(pojo (jobe data+dat sein+dat-sen ~))}
;div#tree; ;div#tree;
== ==

View File

@ -75,7 +75,7 @@
:: ::
[tree .] [tree .]
^- json ^- json
=+ default='spur.t_mime.m_body.r_comt.j_plan.j_beak.t_kids.name.t' =+ default='spur.t_mime.m_body.r_comt.j_plan.j_beak.t_meta.j_kids_meta.j_head.r'
=+ ^= schem =+ ^= schem
=+ seh=(fall (~(get by qix.gas) 'q') default) =+ seh=(fall (~(get by qix.gas) 'q') default)
~|(bad-noun+seh ;;(schema (rash seh read-schem))) ~|(bad-noun+seh ;;(schema (rash seh read-schem)))

View File

@ -13,6 +13,13 @@ module.exports = {
type: "loadPath" type: "loadPath"
}); });
}, },
loadSein: function(path, data) {
return TreeDispatcher.handleServerAction({
path: path,
data: data,
type: "loadSein"
});
},
clearData: function() { clearData: function() {
TreePersistence.refresh(); TreePersistence.refresh();
return TreeDispatcher.handleServerAction({ return TreeDispatcher.handleServerAction({
@ -2073,7 +2080,6 @@ ref = React.DOM, ul = ref.ul, li = ref.li, a = ref.a;
module.exports = query({ module.exports = query({
path: 't', path: 't',
kids: { kids: {
snip: 'r',
head: 'r', head: 'r',
meta: 'j' meta: 'j'
} }
@ -2354,6 +2360,9 @@ $(function() {
frag = util.fragpath(window.location.pathname.replace(/\.[^\/]*$/, '')); frag = util.fragpath(window.location.pathname.replace(/\.[^\/]*$/, ''));
window.tree.actions.setCurr(frag); window.tree.actions.setCurr(frag);
window.tree.actions.loadPath(frag, window.tree.data); window.tree.actions.loadPath(frag, window.tree.data);
if (window.tree.sein != null) {
window.tree.actions.loadSein(frag, window.tree.sein);
}
window.urb.ondataupdate = function(dep) { window.urb.ondataupdate = function(dep) {
var dat; var dat;
for (dat in window.urb.datadeps) { for (dat in window.urb.datadeps) {
@ -2516,17 +2525,17 @@ TreeStore = _.extend((new EventEmitter).setMaxListeners(50), {
} }
data[k] = have[k]; data[k] = have[k];
} }
if (query.kids) { }
if (have.kids === false) { if (query.kids) {
data.kids = {}; if ((have != null ? have.kids : void 0) === false) {
} else { data.kids = {};
for (k in tree) { } else {
sub = tree[k]; for (k in tree) {
if (data.kids == null) { sub = tree[k];
data.kids = {}; if (data.kids == null) {
} data.kids = {};
data.kids[k] = this.fulfillAt(sub, path + "/" + k, query.kids);
} }
data.kids[k] = this.fulfillAt(sub, path + "/" + k, query.kids);
} }
} }
} }
@ -2574,13 +2583,24 @@ TreeStore = _.extend((new EventEmitter).setMaxListeners(50), {
_data = {}; _data = {};
return _tree = {}; return _tree = {};
}, },
loadSein: function(arg) {
var data, path, sein;
path = arg.path, data = arg.data;
sein = this.getPare(path);
if (sein != null) {
return this.loadPath({
path: sein,
data: data
});
}
},
loadPath: function(arg) { loadPath: function(arg) {
var data, path; var data, path;
path = arg.path, data = arg.data; path = arg.path, data = arg.data;
return this.loadValues(this.getTree(path.split('/'), true), path, data); return this.loadValues(this.getTree(path.split('/'), true), path, data);
}, },
loadValues: function(tree, path, data) { loadValues: function(tree, path, data) {
var k, old, ref, ref1, v; var _path, k, old, ref, ref1, v;
old = (ref = _data[path]) != null ? ref : {}; old = (ref = _data[path]) != null ? ref : {};
for (k in data) { for (k in data) {
if (QUERIES[k]) { if (QUERIES[k]) {
@ -2593,7 +2613,11 @@ TreeStore = _.extend((new EventEmitter).setMaxListeners(50), {
if (tree[k] == null) { if (tree[k] == null) {
tree[k] = {}; tree[k] = {};
} }
this.loadValues(tree[k], path + "/" + k, v); _path = path;
if (_path === "/") {
_path = "";
}
this.loadValues(tree[k], _path + "/" + k, v);
} }
if (data.kids && _.isEmpty(data.kids)) { if (data.kids && _.isEmpty(data.kids)) {
old.kids = false; old.kids = false;
@ -2621,6 +2645,9 @@ TreeStore = _.extend((new EventEmitter).setMaxListeners(50), {
tree = _tree; tree = _tree;
for (i = 0, len = _path.length; i < len; i++) { for (i = 0, len = _path.length; i < len; i++) {
sub = _path[i]; sub = _path[i];
if (!sub) {
continue;
}
if (tree[sub] == null) { if (tree[sub] == null) {
if (!make) { if (!make) {
return null; return null;