diff --git a/src/core/js/ext_bookmarks.js b/src/core/js/ext_bookmarks.js index 6f4f8029ee908e6194cfc399b4c0a327a1bdcec1..f9a1e7278cd80e9ea1975fae1f38bb7624b9f50e 100644 --- a/src/core/js/ext_bookmarks.js +++ b/src/core/js/ext_bookmarks.js @@ -574,7 +574,11 @@ var ext_bookmarks = function ($, logger, config) { if ($("#" + row_id).length > 0) { return; } - const button_html = $(`<div class="row" id=${row_id}><p class="text-end">Bookmark all query results</p></div>`)[0]; + const button_html = $(`<div class="row" id=${row_id}> + <p class="text-end"> + <button class="btn btn-link" onclick="ext_bookmarks.add_query_results_to_bookmarks();">Bookmark all query results</button> + </p> +</div>`)[0]; // Add to query results box $(".caosdb-query-response-heading").append(button_html); @@ -583,27 +587,17 @@ var ext_bookmarks = function ($, logger, config) { /** * Execute select query and add all new ids to bookmarks. */ - const add_query_results_to_bookmarks = function () { + const add_query_results_to_bookmarks = async 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 + const resp = await query(query_string); + for (const eid of resp) { + bookmark_storage.setItem(get_key(getEntityID(eid)), 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. *