Skip to content
Snippets Groups Projects
Commit 8eb922ee authored by florian's avatar florian
Browse files

ENH: Use specific class for query string

parent 6b77b064
No related branches found
No related tags found
2 merge requests!47Release v0.4.0,!44ENH: Add all query results to bookmarks
......@@ -580,6 +580,30 @@ var ext_bookmarks = function ($, logger, config) {
$(".caosdb-query-response-heading").append(button_html);
}
/**
* Execute select query and add all new ids to bookmarks.
*/
const add_query_results_to_bookmarks = function () {
const query_string = get_query_from_response();
// const resp = await query(query_string);
// for (const eid of resp) {
// add_to_bookmarks(getEntityID(eid));
// }
// // re-init for correct display of counter and entities on page
init();
}
/**
* Add value to bookmarks if its key is new. Do nothing otherwise.
*
* @param {string} value
*/
const add_to_bookmarks = function (value) {
const key = get_key(value);
}
/**
* Transform a given query it to a "SELECT ID FROM ..." query.
*
......@@ -603,14 +627,9 @@ var ext_bookmarks = function ($, logger, config) {
* Return the SELECT query created from the contents of the query response field
*/
const get_query_from_response = function () {
// Go through divs in response field and extract the query string.
const divs = $(".caosdb-query-response-heading").find("div");
for (const div of divs) {
if (div.innerText.startsWith("Query:") && !div.innerText.includes("Results:")) {
return get_select_id_query_string(
div.innerText.slice(div.innerText.indexOf(" ") + 1));
}
}
const orig_query = $(".caosdb-query-response-string")[0].innerText;
return get_select_id_query_string(orig_query);
}
/**
......@@ -705,6 +724,7 @@ var ext_bookmarks = function ($, logger, config) {
get_bookmark_data: get_bookmark_data,
get_select_id_query_string: get_select_id_query_string,
get_query_from_response: get_query_from_response,
add_query_results_to_bookmarks: add_query_results_to_bookmarks,
}
};
......
......@@ -56,7 +56,9 @@
<div class="col-sm-10 caosdb-overflow-box">
<div class="caosdb-overflow-content">
<span>Query: </span>
<xsl:value-of select="@string"/>
<span class="caosdb-query-response-string">
<xsl:value-of select="@string"/>
</span>
</div>
</div>
<div class="col-sm-2 text-end">
......
......@@ -209,7 +209,8 @@ QUnit.test("select-query extraction", function (assert) {
<div class="row">
<div class="col-sm-10 caosdb-overflow-box">
<div class="caosdb-overflow-content">
<span>Query: </span>SELECT name, id FROM RECORD MusicalAnalysis
<span>Query: </span>
<span class = "caosdb-query-response-string">SELECT name, id FROM RECORD MusicalAnalysis</span>
</div>
</div>
<div class="col-sm-2 text-end">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment