diff --git a/src/core/js/ext_bookmarks.js b/src/core/js/ext_bookmarks.js index 1e8582031b9eaee6198bd9699e0a1f99985cea61..2bd37df6b29d93cb07039bdae6bdc7e003497909 100644 --- a/src/core/js/ext_bookmarks.js +++ b/src/core/js/ext_bookmarks.js @@ -662,19 +662,43 @@ $(document).ready(function () { return $(await transaction.retrieveEntityById(id)).find("Version").attr("id"); } + const get_name = async function (id) { + if (id.indexOf("@") > -1) { + const entity = $(`[data-bmval='${id}']`); + if (entity.length > 0) { + return getEntityName(entity[0]) || ""; + } + } + return $(await transaction.retrieveEntityById(id)).attr("name"); + } + + const get_rt = async function (id) { + if (id.indexOf("@") > -1) { + const entity = $(`[data-bmval='${id}']`); + if (entity.length > 0) { + return getParents(entity[0]).join("/"); + } + } + const parent_names = $(await transaction.retrieveEntityById(id)) + .find("Parent").toArray().map(x => x.getAttribute("name")) + return parent_names.join("/"); + } + // these columns will be in the export - const tsv_columns = ["ID", "Version", "URI", "Path"]; + const tsv_columns = ["ID", "Version", "URI", "Path", "Name", "RecordType"]; // functions for collecting the export data for a particular bookmarked id. const data_getters = { "ID": (id) => id.indexOf("@") > -1 ? id.split("@")[0] : id, "Version": async (id) => id.indexOf("@") > -1 ? id.split("@")[1] : await get_version(id), "Path": get_path, "URI": async (id) => get_context_root() + id + (id.indexOf("@") > -1 ? "" : ("@" + await get_version(id))), + "Name": get_name, + "RecordType": get_rt, }; // we cannot cache these because the the values might change unnoticed // when the head moves to a newer version. - const data_no_cache = ["ID", "Version", "URI", "Path"]; + const data_no_cache = ["ID", "Version", "URI", "Path", "Name", "RecordType"]; const config = { get_context_root: get_context_root, diff --git a/test/core/js/modules/ext_bookmarks.js.js b/test/core/js/modules/ext_bookmarks.js.js index fe880621047811f09983f409074079bc994484ea..831df74231e479d5b4550524f6bc0da617c98fb3 100644 --- a/test/core/js/modules/ext_bookmarks.js.js +++ b/test/core/js/modules/ext_bookmarks.js.js @@ -69,7 +69,7 @@ QUnit.test("get_export_table", async function (assert) { var table = await ext_bookmarks.get_export_table( ["123@ver1", "456@ver2", "789@ver3", "101112", "@131415"]); assert.equal(table, - `data:text/csv;charset=utf-8,ID${TAB}Version${TAB}URI${TAB}Path${NEWL}123${TAB}ver1${TAB}${context_root}123@ver1${TAB}testpath_123@ver1${NEWL}456${TAB}ver2${TAB}${context_root}456@ver2${TAB}testpath_456@ver2${NEWL}789${TAB}ver3${TAB}${context_root}789@ver3${TAB}testpath_789@ver3${NEWL}101112${TAB}abcHead${TAB}${context_root}101112@abcHead${TAB}testpath_101112${NEWL}${TAB}131415${TAB}${context_root}@131415${TAB}testpath_@131415`); + `data:text/csv;charset=utf-8,ID${TAB}Version${TAB}URI${TAB}Path${TAB}Name${TAB}RecordType${NEWL}123${TAB}ver1${TAB}${context_root}123@ver1${TAB}testpath_123@ver1${TAB}${TAB}${NEWL}456${TAB}ver2${TAB}${context_root}456@ver2${TAB}testpath_456@ver2${TAB}${TAB}${NEWL}789${TAB}ver3${TAB}${context_root}789@ver3${TAB}testpath_789@ver3${TAB}${TAB}${NEWL}101112${TAB}abcHead${TAB}${context_root}101112@abcHead${TAB}testpath_101112${TAB}${TAB}${NEWL}${TAB}131415${TAB}${context_root}@131415${TAB}testpath_@131415${TAB}${TAB}`); });