unioned filters

This commit is contained in:
unknown 2021-03-27 09:38:54 -04:00
parent c3f9325a51
commit 0138a74aa9

View File

@ -181,16 +181,16 @@ let ElemTreeNode = ({node, tree}) =>
attributes = {onClick:e=>{ e.stopPropagation(); App.Update.Interact(node); }}; attributes = {onClick:e=>{ e.stopPropagation(); App.Update.Interact(node); }};
parts.unshift(h("span", null, node.Open?"-":"+")); parts.unshift(h("span", null, node.Open?"-":"+"));
} }
if(inButton)
parts.push( {
h("button", parts.push(
{ h("button",
disabled: (!inButton&&node.Active) ? true : false, {
onClick:e=>{ e.stopPropagation(); App.Update.Select(node, tree); } onClick:e=>{ e.stopPropagation(); App.Update.Select(node, tree); }
}, },
node.Active?"remove":"add") node.Active?"remove":"add")
); );
}
return h("div", attributes, parts); return h("div", attributes, parts);
} }
@ -312,6 +312,7 @@ var App = {
Topics: Topics:
{ {
Display:"Topics", Display:"Topics",
Results:[],
Active:[], Active:[],
Root: Root:
Node.Create("root", "All", [ Node.Create("root", "All", [
@ -330,6 +331,7 @@ var App = {
Bible: Bible:
{ {
Display:"Bible", Display:"Bible",
Results:[],
Active:[], Active:[],
Root: Root:
Node.Create("all", "All", [ Node.Create("all", "All", [
@ -404,8 +406,7 @@ var App = {
Node.Create("2 Corinthians"), Node.Create("2 Corinthians"),
Node.Create("Galatians"), Node.Create("Galatians"),
Node.Create("Ephesians"), Node.Create("Ephesians"),
Node.Create("1 Thessalonians"), Node.Create("1 Thessalonians")
Node.Create("Romans"),
]) ])
]) ])
} }
@ -416,22 +417,12 @@ var App = {
Render:()=>ReactDOM.render( h(App.RootComponent), App.RootDOM ), Render:()=>ReactDOM.render( h(App.RootComponent), App.RootDOM ),
ApplyFilters:()=> ApplyFilters:()=>
{ {
let topics = App.State.Topics; App.State.Items.Active = _.union(App.State.Topics.Results, App.State.Bible.Results);
let bible = App.State.Bible; if(App.State.Items.Active.length == 0)
let items = App.State.Items;
let itrCollect = inNode =>
{ {
items.Active = items.Active.concat( inNode.Leaves ); App.State.Items.Active = App.State.Items.All;
}; }
App.State.Pages.All = _.chunk(App.State.Items.Active, 10);
items.Active = [];
topics.Active.forEach(itrCollect);
bible.Active.forEach(itrCollect);
App.State.Pages.All = _.chunk(items.Active, 10);
App.State.Pages.Active = 0; App.State.Pages.Active = 0;
}, },
LeafStructure:(inTree)=> LeafStructure:(inTree)=>
@ -485,10 +476,6 @@ var App = {
if(inNode.Active) if(inNode.Active)
{ {
clear(inNode); clear(inNode);
if(inTree.Active.length == 0)
{
add(inTree.Root);
}
} }
else else
{ {
@ -496,6 +483,13 @@ var App = {
Node.IterateDown(inNode, itr); Node.IterateDown(inNode, itr);
add(inNode); add(inNode);
} }
inTree.Results = [];
inTree.Active.forEach(inNode =>
{
inTree.Results = inTree.Results.concat( inNode.Leaves );
});
App.ApplyFilters(); App.ApplyFilters();
App.Render(); App.Render();
}, },