Skip to content

Commit

Permalink
saving filters and sorts
Browse files Browse the repository at this point in the history
  • Loading branch information
dvargas92495 committed Mar 15, 2022
1 parent 97942fa commit 0e34bcc
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 136 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
"roamjs-components": "^0.51.2"
"roamjs-components": "^0.52.6"
}
}
56 changes: 33 additions & 23 deletions src/components/QueryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@ const QueryPage = ({ pageUid }: Props) => {
() => queryNode.children.map((s) => s.text),
[queryNode]
);
const [loading, setLoading] = useState(false);
const [results, setResults] = useState<SearchResult[]>([]);
const { returnNode, conditionNodes, selectionNodes } = useMemo(
() => parseQuery(query),
[parseQuery, query]
);
useEffect(() => {
const results = fireQuery({
returnNode,
conditions: conditionNodes,
selections: selectionNodes,
});
setResults(results);
setLoading(true);
setTimeout(() => {
const results = fireQuery({
returnNode,
conditions: conditionNodes,
selections: selectionNodes,
});
setResults(results);
setLoading(false);
}, 1);
}, [setResults]);
return (
<Card
Expand Down Expand Up @@ -103,10 +108,14 @@ const QueryPage = ({ pageUid }: Props) => {
/>
</Tooltip>
)}
<ResultsView
header={
<div>
{/*<Tooltip content={"Export"}>
{loading ? (
<p>Loading results...</p>
) : (
<ResultsView
parentUid={pageUid}
header={
<div>
{/*<Tooltip content={"Export"}>
<Button
icon={"export"}
disabled
Expand Down Expand Up @@ -138,19 +147,20 @@ const QueryPage = ({ pageUid }: Props) => {
}}
/>
</Tooltip>*/}
</div>
}
results={results.map(({ id, ...a }) => a)}
resultContent={
<div style={{ fontSize: 10, position: "relative" }}>
{query.map((q, i) => (
<p key={i} style={{ margin: 0 }}>
{q}
</p>
))}
</div>
}
/>
</div>
}
results={results.map(({ id, ...a }) => a)}
resultContent={
<div style={{ fontSize: 10, position: "relative" }}>
{query.map((q, i) => (
<p key={i} style={{ margin: 0 }}>
{q}
</p>
))}
</div>
}
/>
)}
</Card>
);
};
Expand Down
Loading

0 comments on commit 0e34bcc

Please sign in to comment.