diff --git a/src/core/xsl/entity.xsl b/src/core/xsl/entity.xsl index 9b485331fb4d4b40a2de3cac9ea50b82b57457ee..ae195afc07920bce0aac84da0027911017840502 100644 --- a/src/core/xsl/entity.xsl +++ b/src/core/xsl/entity.xsl @@ -347,7 +347,7 @@ </xsl:call-template> </span> <span class="spacer"></span> - <summary><div title="show more"><span class="caosdb-f-property-text-value"><xsl:value-of select="substring(normalize-space($value),0,$long-text-threshold)"/></span></div></summary> + <summary><div title="show more"><span class="caosdb-f-property-text-value"><xsl:value-of select="substring(normalize-space($value),0,$long-text-threshold + 1)"/></span></div></summary> </details> </xsl:when> <xsl:otherwise> diff --git a/test/core/js/modules/entity.xsl.js b/test/core/js/modules/entity.xsl.js index 04ec35a6fc14cbad81c731908e28f788999c3563..69f553c76c57143ea7b10560c304ba2ffa7da209 100644 --- a/test/core/js/modules/entity.xsl.js +++ b/test/core/js/modules/entity.xsl.js @@ -168,6 +168,27 @@ QUnit.test("single-value template with reference property.", function(assert) { assert.equal($(link).find('.caosdb-id').length, 1, 'has caosdb-id span'); }) +QUnit.test("single-value template with long text property.", function(assert) { + assert.equal(xml2str(callTemplate(this.entityXSL, 'single-value', { + 'value': 'the feature is disabled', + 'reference': 'false', + 'boolean': 'false', + 'long-text-threshold': 'DISABLED' + })), "<span xmlns=\"http://www.w3.org/1999/xhtml\" class=\"caosdb-f-property-single-raw-value caosdb-property-text-value caosdb-f-property-text-value caosdb-v-property-text-value\">the feature is disabled</span>", "disabled -> not in details tag"); + assert.equal(xml2str(callTemplate(this.entityXSL, 'single-value', { + 'value': 'this is too long', + 'reference': 'false', + 'boolean': 'false', + 'long-text-threshold': '4' + })), "<details xmlns=\"http://www.w3.org/1999/xhtml\"><span class=\"caosdb-f-property-single-raw-value caosdb-property-text-value caosdb-f-property-text-value caosdb-v-property-text-value\">this is too long</span><span class=\"spacer\"></span><summary><div title=\"show more\"><span class=\"caosdb-f-property-text-value\">this</span></div></summary></details>", "too long -> shorted to 'this'"); + assert.equal(xml2str(callTemplate(this.entityXSL, 'single-value', { + 'value': 'this is not too long', + 'reference': 'false', + 'boolean': 'false', + 'long-text-threshold': '140' + })), "<span xmlns=\"http://www.w3.org/1999/xhtml\" class=\"caosdb-f-property-single-raw-value caosdb-property-text-value caosdb-f-property-text-value caosdb-v-property-text-value\">this is not too long</span>", "not too long -> not details tag."); +}) + QUnit.test("old version warning", function(assert) { // with successor tag var xmlstr = '<Record id="2345"><Version id="abcd1234"><Successor id="bcde2345"/></Version></Record>';