Skip to content

Commit

Permalink
Sparql save custom (Closes #16) (#19)
Browse files Browse the repository at this point in the history
* save custom query

* 1.1.7
  • Loading branch information
mdroidian committed Jan 11, 2024
1 parent ce24668 commit 9436f26
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "developer",
"version": "1.1.6",
"version": "1.1.7",
"description": "Develop and publish your own Roam extensions with the help of RoamJS!",
"main": "./build/main.js",
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions src/features/sparql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,13 @@ const SparqlQuery = ({
icon={"bring-data"}
text={"Import"}
disabled={activeItem === "Custom Query" ? false : !radioValue}
className="flex-shrink-0"
onClick={async () => {
setLoading(true);
const importParentUid =
activeItem === "Current Page" ? parentUid : blockUid;
const isQuery = activeItem === "Custom Query";
if (!isQuery) {
const isCustom = activeItem === "Custom Query";
if (!isCustom) {
createBlock({
parentUid: importParentUid,
node: {
Expand All @@ -598,18 +599,18 @@ const SparqlQuery = ({
});
}
// get custom query at time of submit
const customQuery = isQuery
const customQuery = isCustom
? getCodeFromBlock(getTextByBlockUid(customQueryUid))
: "";
const labelUid = await createBlock({
node: {
text: getLabel({ outputFormat, label }),
},
parentUid: importParentUid,
order: isQuery ? 0 : 1,
order: isCustom ? 0 : 1,
});
const queryInfo = {
query: isQuery ? customQuery : query,
query: isCustom ? customQuery : query,
source: dataSource,
outputFormat,
};
Expand All @@ -629,7 +630,7 @@ const SparqlQuery = ({
node: {
text: labelUid,
children: [
{ text: query },
{ text: queryInfo.query },
{ text: queryInfo.source },
{ text: outputFormat },
],
Expand Down

0 comments on commit 9436f26

Please sign in to comment.