From 5e286cf0374ce15484f14c111ce893be46bcbc7b Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Mon, 6 Dec 2021 21:35:32 +0100 Subject: [PATCH] Fix CreateXML --- misc/entity_state_test_data.py | 14 ++++++++++++-- src/core/js/caosdb.js | 21 ++++++++++++--------- src/core/xsl/entity.xsl | 8 +++++++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/misc/entity_state_test_data.py b/misc/entity_state_test_data.py index 400b7374..ff06452c 100755 --- a/misc/entity_state_test_data.py +++ b/misc/entity_state_test_data.py @@ -3,7 +3,7 @@ import sys import caosdb as db -_PASSWORD = "password1A!" +_PASSWORD = "Password1!" def teardown(): @@ -49,6 +49,8 @@ def setup_users(): "Grant", "STATE:TRANSITION:Edit"), db.administration.PermissionRule( "Grant", "STATE:TRANSITION:Start Review"), + db.administration.PermissionRule( + "Grant", "STATE:ASSIGN:Publish Life-cycle"), ]) db.administration._set_permissions( @@ -180,9 +182,17 @@ def setup_test_data(): # any record of this type will have the unpublished state rt = db.RecordType("TestRT") rt.state = db.State(model="Publish Life-cycle", name="Unpublished") + rt.acl = db.ACL() + rt.acl.grant(role="normal", permission="RETRIEVE:ENTITY") + rt.acl.grant(role="normal", permission="USE:AS_PARENT") rt.insert() - db.Property("TestProperty", datatype=db.TEXT).insert() + prop = db.Property("TestProperty", datatype=db.TEXT) + prop.acl = db.ACL() + prop.acl.grant(role="normal", permission="RETRIEVE:ENTITY") + prop.acl.grant(role="normal", permission="USE:AS_PROPERTY") + prop.insert() + rec = db.Record().add_parent("TestRT") rec.description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." rec.add_property("TestProperty", "TestValue") diff --git a/src/core/js/caosdb.js b/src/core/js/caosdb.js index 7c3c4300..3ecbc58f 100644 --- a/src/core/js/caosdb.js +++ b/src/core/js/caosdb.js @@ -554,6 +554,9 @@ function getPropertyFromElement(propertyelement, names = undefined) { property.html = propertyelement; // name property.name = getPropertyName(propertyelement); + // description + property.description = propertyelement.getElementsByClassName("caosdb-property-description")[0]; + // id if (idel === undefined) { @@ -888,13 +891,16 @@ function getProperty(element, property_name, case_sensitive = true) { * @param parentElement The element which is to recieve the attributes. * @param parent The object possibly containing an id and or a name. */ -function setNameID(parentElement, parent) { +function _setDescriptionNameID(parentElement, parent) { if (typeof parent.id !== 'undefined' && parent.id !== '') { parentElement.setAttribute("id", parent.id); } if (typeof parent.name !== 'undefined' && parent.name !== '') { parentElement.setAttribute("name", parent.name); } + if (typeof parent.description !== 'undefined' && parent.description !== '') { + parentElement.setAttribute("description", parent.description); + } } /** @@ -906,7 +912,7 @@ function setNameID(parentElement, parent) { */ function appendParent(doc, element, parent) { var parentElement = document.createElementNS(undefined, "Parent"); - setNameID(parentElement, parent); + _setDescriptionNameID(parentElement, parent); element.appendChild(parentElement); } @@ -933,7 +939,7 @@ function appendValueNode(doc, element, name, value) { */ function appendProperty(doc, element, property, append_datatype = false) { var propertyElement = document.createElementNS(undefined, "Property"); - setNameID(propertyElement, property); + _setDescriptionNameID(propertyElement, property); if (append_datatype && typeof property.datatype !== "undefined") { propertyElement.setAttribute("datatype", property.datatype); } @@ -995,19 +1001,16 @@ function createEntityXML(role, name, id, properties, parents, var doc = _createDocument(role); var nelnode = doc.children[0]; - setNameID(nelnode, { + _setDescriptionNameID(nelnode, { name: name, - id: id + id: id, + description: description, }); if (typeof datatype !== 'undefined' && datatype.length > 0) { $(nelnode).attr("datatype", datatype); } - if (typeof description !== 'undefined' && description.length > 0) { - $(nelnode).attr("description", description); - } - if (typeof unit !== 'undefined' && unit.length > 0) { $(nelnode).attr("unit", unit); } diff --git a/src/core/xsl/entity.xsl b/src/core/xsl/entity.xsl index d8ba00a9..a09494e7 100644 --- a/src/core/xsl/entity.xsl +++ b/src/core/xsl/entity.xsl @@ -266,7 +266,7 @@ </xsl:attribute> <hr class="caosdb-subproperty-divider"/> <dl class="row caosdb-v-entity-property-attributes"> - <xsl:apply-templates mode="property-attributes" select="@description"/> + <xsl:apply-templates mode="property-attributes-desc" select="@description"/> <xsl:apply-templates mode="property-attributes-id" select="@id"/> <xsl:apply-templates mode="property-attributes-type" select="@datatype"/> <xsl:apply-templates mode="property-attributes" select="@*[not(contains('+cuid+id+name+description+datatype+',concat('+',name(),'+')))]"/> @@ -470,6 +470,12 @@ <xsl:value-of select="."/> </dd> </xsl:template> + <xsl:template match="@description" mode="property-attributes-desc"> + <dt class="col-6 col-md-4 mb-0">description</dt> + <dd class="col-6 col-md-8 mb-0 caosdb-property-description"> + <xsl:value-of select="."/> + </dd> + </xsl:template> <xsl:template match="@id" mode="property-attributes-id"> <dt class="col-6 col-md-4 mb-0">id</dt> <dd class="col-6 col-md-8 mb-0"> -- GitLab