diff --git a/src/core/js/caosdb.js b/src/core/js/caosdb.js index 5be29d5f50cf3d1c9a6894b6824a6170fed2a060..7c3c4300f971eae16d30748e6787843334708baa 100644 --- a/src/core/js/caosdb.js +++ b/src/core/js/caosdb.js @@ -1071,20 +1071,16 @@ function createFileXML(name, id, parents, * Update, Response, Delete. * * @param {string} root - The name of the newly created document root node. - * @param {(Document|XMLDocumentFragment)} xmls The xml documents. + * @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; @@ -1188,9 +1184,11 @@ async function restore_old_version(versionid){ 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)) + const doc = _createDocument("Request"); + doc.firstElementChild.appendChild(ent); + reps = await transaction.updateEntitiesXml(doc); if (reps.getElementsByTagName("Error").length>0) { throw new Error(`Could not restore the Entity to the version ${versionid}.`); }