diff --git a/core/modules/widgets/testcase-view.js b/core/modules/widgets/testcase-view.js index cc6e45735..bed0ff129 100644 --- a/core/modules/widgets/testcase-view.js +++ b/core/modules/widgets/testcase-view.js @@ -38,7 +38,7 @@ TestCaseViewWidget.prototype.render = function(parent,nextSibling) { } // Render the transclusion if(pointer && pointer.testcaseRawTiddler) { - pointer.testcaseRawTiddler(parent,nextSibling,this.testcaseViewTiddler) + pointer.testcaseRawTiddler(parent,nextSibling,this.testcaseViewTiddler,this.testcaseViewField) } }; @@ -47,6 +47,7 @@ Compute the internal state of the widget */ TestCaseViewWidget.prototype.execute = function() { this.testcaseViewTiddler = this.getAttribute("tiddler"); + this.testcaseViewField = this.getAttribute("field","text"); }; /* diff --git a/core/modules/widgets/testcase.js b/core/modules/widgets/testcase.js index b23d5c025..17275d092 100644 --- a/core/modules/widgets/testcase.js +++ b/core/modules/widgets/testcase.js @@ -67,8 +67,11 @@ TestCaseWidget.prototype.render = function(parent,nextSibling) { this.setVariable("transclusion",$tw.utils.hashString(this.testcaseWiki.getTiddlersAsJson("[all[tiddlers]]"))); // Generate a `testcaseInfo` variable that contains information about the subwiki in JSON format var testcaseInfoData = { - titles: this.testcaseWiki.allTitles() + tiddlers: {} // Hashmap of tiddler titles mapped to array of field names }; + this.testcaseWiki.each(function(tiddler,title) { + testcaseInfoData.tiddlers[title] = Object.keys(tiddler.fields); + }); this.setVariable("testcaseInfo",JSON.stringify(testcaseInfoData)); // Render children from the template this.renderChildren(parent,nextSibling); @@ -105,10 +108,14 @@ TestCaseWidget.prototype.testcaseRenderTiddler = function(parent,nextSibling,tit /* View a test case tiddler in plain text */ -TestCaseWidget.prototype.testcaseRawTiddler = function(parent,nextSibling,title) { +TestCaseWidget.prototype.testcaseRawTiddler = function(parent,nextSibling,title,field) { var self = this; // Render a text widget with the text of a tiddler - var text = this.testcaseWiki.getTiddlerText(title); + var text="", + tiddler = this.testcaseWiki.getTiddler(title); + if(tiddler) { + text = tiddler.getFieldString(field,""); + } parent.insertBefore(this.document.createTextNode(text),nextSibling); }; diff --git a/editions/tw5.com/tiddlers/widgets/TestCaseViewWidget.tid b/editions/tw5.com/tiddlers/widgets/TestCaseViewWidget.tid index 7ffae5da9..b4274eafa 100644 --- a/editions/tw5.com/tiddlers/widgets/TestCaseViewWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/TestCaseViewWidget.tid @@ -15,3 +15,4 @@ The content of the `<$testcase-view>` widget is not displayed. |!Attribute |!Description | |<<.attr tiddler>> |Title of the tiddler to be displayed | +|<<.attr field>> |Optional field to be displayed (defaults to "text") |