mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-14 11:15:41 +00:00
Extend testcase-view to be able to view other fields
This commit is contained in:
parent
c348924838
commit
3c61e8679d
@ -38,7 +38,7 @@ TestCaseViewWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
}
|
}
|
||||||
// Render the transclusion
|
// Render the transclusion
|
||||||
if(pointer && pointer.testcaseRawTiddler) {
|
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() {
|
TestCaseViewWidget.prototype.execute = function() {
|
||||||
this.testcaseViewTiddler = this.getAttribute("tiddler");
|
this.testcaseViewTiddler = this.getAttribute("tiddler");
|
||||||
|
this.testcaseViewField = this.getAttribute("field","text");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -67,8 +67,11 @@ TestCaseWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
this.setVariable("transclusion",$tw.utils.hashString(this.testcaseWiki.getTiddlersAsJson("[all[tiddlers]]")));
|
this.setVariable("transclusion",$tw.utils.hashString(this.testcaseWiki.getTiddlersAsJson("[all[tiddlers]]")));
|
||||||
// Generate a `testcaseInfo` variable that contains information about the subwiki in JSON format
|
// Generate a `testcaseInfo` variable that contains information about the subwiki in JSON format
|
||||||
var testcaseInfoData = {
|
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));
|
this.setVariable("testcaseInfo",JSON.stringify(testcaseInfoData));
|
||||||
// Render children from the template
|
// Render children from the template
|
||||||
this.renderChildren(parent,nextSibling);
|
this.renderChildren(parent,nextSibling);
|
||||||
@ -105,10 +108,14 @@ TestCaseWidget.prototype.testcaseRenderTiddler = function(parent,nextSibling,tit
|
|||||||
/*
|
/*
|
||||||
View a test case tiddler in plain text
|
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;
|
var self = this;
|
||||||
// Render a text widget with the text of a tiddler
|
// 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);
|
parent.insertBefore(this.document.createTextNode(text),nextSibling);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,3 +15,4 @@ The content of the `<$testcase-view>` widget is not displayed.
|
|||||||
|
|
||||||
|!Attribute |!Description |
|
|!Attribute |!Description |
|
||||||
|<<.attr tiddler>> |Title of the tiddler to be displayed |
|
|<<.attr tiddler>> |Title of the tiddler to be displayed |
|
||||||
|
|<<.attr field>> |Optional field to be displayed (defaults to "text") |
|
||||||
|
Loading…
Reference in New Issue
Block a user