Skip to content
Snippets Groups Projects
Verified Commit 0d993d68 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Bookmarks: Add name and recordtype to export data

parent 0df50b6f
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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}`);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment