diff --git a/src/core/js/caosdb.js b/src/core/js/caosdb.js index c43a68de358a441c1bbfafe732bf576702e8585b..90d6bfd23b989bbff133a63d65e1e68d99f4b3bb 100644 --- a/src/core/js/caosdb.js +++ b/src/core/js/caosdb.js @@ -1074,17 +1074,13 @@ function createFileXML(name, id, parents, * @param {(Document|XMLDocumentFragment)} xmls The xml documents. * @return {Document} A new xml document. */ -function wrapXML(root, xmls, start_with_root=undefined) { +function wrapXML(root, xmls) { xmls = caosdb_utils.assert_array(xmls, "param `xmls`", true); caosdb_utils.assert_string(root, "param `root`"); var doc = _createDocument(root); for (var i = 0; i < xmls.length; i++) { - if (start_with_root === undefined || start_with_root != true){ - doc.firstElementChild.appendChild(xmls[i].firstElementChild); - }else { - doc.firstElementChild.appendChild(xmls[i]); - } + doc.firstElementChild.appendChild(xmls[i].firstElementChild); } return doc; @@ -1168,28 +1164,6 @@ async function update(xml) { return await transaction.updateEntitiesXml(wrapped); } - -/** - * Restore an old version of an entity using an xml representation. - * First, the old version is retrieved and the current version is set to the - * old one. - * @param versionid The version id (e.g. 123@abbabbaeff23322) of the version of - * the entity which shall be restored. - */ -async function restore_old_version(versionid){ - // retrieve entity - var ent = await transaction.retrieveEntityById(versionid); - // remove unwanted tags (Version and Permissions) - ent.getElementsByTagName("Version")[0].remove(); - var permissions = ent.getElementsByTagName("Permissions"); - for (let i = permissions.length-1; i >=0 ; i--) { - permissions[i].remove(); - } - // use XML to update entity/restore old version - reps = await transaction.updateEntitiesXml( - wrapXML("Request", [ent], start_with_root=true)) -} - /** * Insert an entity in xml representation. * diff --git a/src/core/js/webcaosdb.js b/src/core/js/webcaosdb.js index 1e2017d19574e8d9013cff735bec4c6ec5bb79c0..efa28c9b39921df3e02a25ec95d4601f752fa288 100644 --- a/src/core/js/webcaosdb.js +++ b/src/core/js/webcaosdb.js @@ -1035,7 +1035,6 @@ var version_history = new function () { .retrieve_history(entity_id_version); sparse.replaceWith(history_table); version_history.init_export_history_buttons(entity); - version_history.init_restore_version_buttons(entity); }); } } @@ -1073,7 +1072,7 @@ var version_history = new function () { for (let version_info of $(entity) .find(".caosdb-f-entity-version-info")) { $(version_info).find(".caosdb-f-entity-version-export-history-btn") - .click(() => { + .click(async () => { const html_table = $(version_info).find("table")[0]; const history_tsv = this.get_history_tsv(html_table); version_history._download_tsv(history_tsv); @@ -1081,29 +1080,6 @@ var version_history = new function () { } } - /** - * Initialize the export buttons of `entity`. - * - * The buttons are only visible when the version history is visible and - * trigger a download of a tsv file which contains the version history. - * - * The buttons trigger the download of a tsv file with the version history. - * - * @param {HTMLElement} [entity] - if undefined, the export buttons of all - * page entities are initialized. - */ - this.init_restore_version_buttons = function (entity) { - entity = entity || $(".caosdb-entity-panel"); - for (let version_info of $(entity) - .find(".caosdb-f-entity-version-info")) { - $(version_info).find(".caosdb-f-entity-version-restore-btn") - .click(async (eve) => { - const versionid = eve.target.getAttribute("data-version-id") - restore_old_version(versionid) - }); - } - } - this._download_tsv = function (tsv_link) { window.location.href = tsv_link; } @@ -1112,7 +1088,6 @@ var version_history = new function () { this.init = function () { this.init_load_history_buttons(); this.init_export_history_buttons(); - this.init_restore_version_buttons(); } } @@ -1952,4 +1927,4 @@ class _CaosDBModules { var caosdb_modules = new _CaosDBModules() -$(document).ready(initOnDocumentReady); +$(document).ready(initOnDocumentReady); \ No newline at end of file diff --git a/src/core/xsl/entity.xsl b/src/core/xsl/entity.xsl index 6344e7daee011c59fe96cb2a71707798701245a0..92f08ea70645a8282f97f364c9fc4143f37afd6a 100644 --- a/src/core/xsl/entity.xsl +++ b/src/core/xsl/entity.xsl @@ -644,14 +644,11 @@ <div class="modal-body"> <table class="table table-hover"> <thead> - <tr> - <th></th> - <th class="invisible"><div class="export-data">Entity ID</div></th> + <tr><th><div class="export-data">Entity ID</div></th> <th class="export-data">Version ID</th> <th class="export-data">Date</th> <th class="export-data">User</th> <th class="invisible"><div class="export-data">URI</div></th> - <th></th> </tr></thead> <tbody> <xsl:apply-templates mode="entity-version-modal-successor" select="Successor"> @@ -667,8 +664,6 @@ <xsl:value-of select="@username"/>@<xsl:value-of select="@realm"/> </td> <td class="invisible"><div class="export-data"><xsl:value-of select="concat($entitypath, $entityId, '@', @id)"/></div></td> - <td> - </td> </tr> <xsl:apply-templates mode="entity-version-modal-predecessor" select="Predecessor"> <xsl:with-param name="entityId" select="$entityId"/> @@ -750,11 +745,6 @@ <xsl:value-of select="@username"/>@<xsl:value-of select="@realm"/> </td> <td class="invisible"><div class="export-data"><xsl:value-of select="concat($entitypath, $entityId, '@', @id)"/></div></td> - <td> - <button type="button" class="caosdb-f-entity-version-restore-btn btn btn-primary" > - <xsl:attribute name="data-version-id"><xsl:value-of select="$entityId"/>@<xsl:value-of select="@id"/></xsl:attribute> - <i class="bi-arrow-counterclockwise"></i></button> - </td> </tr> </xsl:template>