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

Merge branch 'r-v0.2rc1' of gitlab.com:caosdb/caosdb-webui into r-v0.2rc1

parents 9a4ba97b 30878f32
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -25,6 +25,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
information (like plots, video players, thumbnails...) can be shown. information (like plots, video players, thumbnails...) can be shown.
* Enable with build property `BUILD_MODULE_EXT_BOTTOM_LINE=ENABLED`. * Enable with build property `BUILD_MODULE_EXT_BOTTOM_LINE=ENABLED`.
* More documentation in `src/core/js/ext_bottom_line.js`. * More documentation in `src/core/js/ext_bottom_line.js`.
* ext_revisions (v0.1 - EXPERIMENTAL)
* Creates a backup copy of each entity which is updated via the edit_mode.
* Enable via the build property `BUILD_MODULE_EXT_REVISIONS=ENABLED`.
* Needs two special entities. A RecordType "Obsolete" and a reference
property "revisionOf" with data type "Obsolete".
* Map (v0.3) * Map (v0.3)
* Adds a button to the navbar which toggles a map in the top of the main * Adds a button to the navbar which toggles a map in the top of the main
panel. The map currently shows all known entities which have geolocation panel. The map currently shows all known entities which have geolocation
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* ** header v3.0 * ** header v3.0
* This file is a part of the CaosDB Project. * This file is a part of the CaosDB Project.
* *
* Copyright (C) 2019 IndiScale GmbH (info@indiscale.com) * Copyright (C) 2020 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2019 Timm Fitschen (t.fitschen@indiscale.com) * Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* proxy (or wrapper) function adds further functionality. * proxy (or wrapper) function adds further functionality.
* *
* The extended update function creates a back-up version of the updated entity * The extended update function creates a back-up version of the updated entity
* and and adds a revisionOf property to the updated entity which references * and adds a revisionOf property to the updated entity which references
* the back-up. The back-up entity loses all of its original parents and gets * the back-up. The back-up entity loses all of its original parents and gets
* an "Obsolete" as only parent instead. * an "Obsolete" as only parent instead.
* *
...@@ -55,8 +55,6 @@ var ext_revisions = function ($, logger, edit_mode, getEntityID, transaction, _c ...@@ -55,8 +55,6 @@ var ext_revisions = function ($, logger, edit_mode, getEntityID, transaction, _c
/** /**
* Default names for the two entities which are required by this module. * Default names for the two entities which are required by this module.
*
* TODO: rename
*/ */
var _datamodel = { obsolete: "Obsolete", revisionOf: "revisionOf" }; var _datamodel = { obsolete: "Obsolete", revisionOf: "revisionOf" };
...@@ -75,16 +73,18 @@ var ext_revisions = function ($, logger, edit_mode, getEntityID, transaction, _c ...@@ -75,16 +73,18 @@ var ext_revisions = function ($, logger, edit_mode, getEntityID, transaction, _c
logger.debug("insert obsolete", id); logger.debug("insert obsolete", id);
// create new obsolete entity from the original // create new obsolete entity from the original
var obsolete = await transaction.retrieveEntityById(id); const obsolete = await transaction.retrieveEntityById(id);
$(obsolete).attr("id", "-1"); $(obsolete).attr("id", "-1");
$(obsolete).find("Permissions").remove(); $(obsolete).find("Permissions").remove();
$(obsolete).find("Parent").remove(); $(obsolete).find("Parent").remove();
$(obsolete).append(`<Parent name="${_datamodel.obsolete}"/>`); $(obsolete).append(`<Parent name="${_datamodel.obsolete}"/>`);
var doc = _createDocument("Request"); const doc = _createDocument("Request");
doc.firstElementChild.appendChild(obsolete); doc.firstElementChild.appendChild(obsolete);
var result = await transaction.insertEntitiesXml(doc); const result = await transaction.insertEntitiesXml(doc);
return $(result.firstElementChild).find("[id]").first().attr("id"); const obsolete_id = $(result.firstElementChild).find("[id]").first().attr("id");
logger.trace("leave _insert_obsolete", obsolete_id);
return obsolete_id;
}; };
/** /**
...@@ -98,11 +98,12 @@ var ext_revisions = function ($, logger, edit_mode, getEntityID, transaction, _c ...@@ -98,11 +98,12 @@ var ext_revisions = function ($, logger, edit_mode, getEntityID, transaction, _c
* @returns {string} A HTML represesentation of an entity property. * @returns {string} A HTML represesentation of an entity property.
*/ */
var _make_revision_of_property = async function (obsolete_id) { var _make_revision_of_property = async function (obsolete_id) {
logger.debug("_make_revision_of_property", obsolete_id); logger.trace("enter _make_revision_of_property", obsolete_id);
var ret = (await transformation.transformProperty(str2xml(`<Response><Property id="${_datamodel._revisionOfId}" name="${_datamodel.revisionOf}" datatype="${_datamodel.obsolete}"></Property></Response>`))).firstElementChild; const ret = (await transformation.transformProperty(str2xml(`<Response><Property id="${_datamodel._revisionOfId}" name="${_datamodel.revisionOf}" datatype="${_datamodel.obsolete}"></Property></Response>`))).firstElementChild;
$(ret).append(`<div class="caosdb-property-edit-value"><select><option value="${obsolete_id}" selected="selected"></option></select></div>`); $(ret).find(".caosdb-f-property-value").append(`<div class="caosdb-property-edit-value"><select><option value="${obsolete_id}" selected="selected"></option></select></div>`);
logger.trace("leave _make_revision_of_property", ret);
return ret; return ret;
} }
...@@ -215,6 +216,7 @@ var ext_revisions = function ($, logger, edit_mode, getEntityID, transaction, _c ...@@ -215,6 +216,7 @@ var ext_revisions = function ($, logger, edit_mode, getEntityID, transaction, _c
// private members, exposed for testing // private members, exposed for testing
_make_revision_of_property: _make_revision_of_property, _make_revision_of_property: _make_revision_of_property,
_datamodel: _datamodel, _datamodel: _datamodel,
_logger: logger,
} }
}($, log.getLogger("ext_revisions"), edit_mode, getEntityID, transaction, _createDocument); }($, log.getLogger("ext_revisions"), edit_mode, getEntityID, transaction, _createDocument);
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
* ** header v3.0 * ** header v3.0
* This file is a part of the CaosDB Project. * This file is a part of the CaosDB Project.
* *
* Copyright (C) 2019 IndiScale GmbH * Copyright (C) 2020 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
...@@ -33,6 +34,7 @@ var ext_revisions_test_suite = function ($, ext_revisions, QUnit, edit_mode) { ...@@ -33,6 +34,7 @@ var ext_revisions_test_suite = function ($, ext_revisions, QUnit, edit_mode) {
this.original_insert = transaction.insertEntitiesXml; this.original_insert = transaction.insertEntitiesXml;
this.original_retrieve = transaction.retrieveEntityById; this.original_retrieve = transaction.retrieveEntityById;
this.original_query = query; this.original_query = query;
ext_revisions._logger.setLevel("trace");
}, },
beforeEach: function (assert) { beforeEach: function (assert) {
// setup before each test // setup before each test
...@@ -80,6 +82,7 @@ var ext_revisions_test_suite = function ($, ext_revisions, QUnit, edit_mode) { ...@@ -80,6 +82,7 @@ var ext_revisions_test_suite = function ($, ext_revisions, QUnit, edit_mode) {
assert.equal(rec.id, "-1", "insert with tmp id"); assert.equal(rec.id, "-1", "insert with tmp id");
assert.equal($(rec).find("Parent").attr("name"), datamodel.obsolete, "Obsolete Parent"); assert.equal($(rec).find("Parent").attr("name"), datamodel.obsolete, "Obsolete Parent");
xml.firstElementChild.firstElementChild.id = "2345"; xml.firstElementChild.firstElementChild.id = "2345";
console.log(xml2str(xml));
done(); done();
return xml; return xml;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment