diff --git a/src/core/js/ext_bookmarks.js b/src/core/js/ext_bookmarks.js index 676d25c5fc38e5fa58f96a0c1a25dd6a7115b612..6f4f8029ee908e6194cfc399b4c0a327a1bdcec1 100644 --- a/src/core/js/ext_bookmarks.js +++ b/src/core/js/ext_bookmarks.js @@ -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, } }; diff --git a/src/core/xsl/query.xsl b/src/core/xsl/query.xsl index 2b647c07bebe7f7cd72198baf27e45318e25a18e..e0fa224dcaa16bb2c2b516b77f8ddb8d2075ad9f 100644 --- a/src/core/xsl/query.xsl +++ b/src/core/xsl/query.xsl @@ -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"> diff --git a/test/core/js/modules/ext_bookmarks.js.js b/test/core/js/modules/ext_bookmarks.js.js index 3fec00bf1b543d6be953c1e05077e2022e963ede..a9397d1023b6423a24746da6be953fe561a5ee74 100644 --- a/test/core/js/modules/ext_bookmarks.js.js +++ b/test/core/js/modules/ext_bookmarks.js.js @@ -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">