Improve action-createtiddler to return a draft title too

This commit is contained in:
Jeremy Ruston
2019-06-04 12:33:01 +01:00
parent 72c64013c7
commit 28c732d2be
4 changed files with 22 additions and 10 deletions
@@ -37,6 +37,7 @@ Compute the internal state of the widget
CreateTiddlerWidget.prototype.execute = function() {
this.actionBaseTitle = this.getAttribute("$basetitle");
this.actionSaveTitle = this.getAttribute("$savetitle");
this.actionSaveDraftTitle = this.getAttribute("$savedrafttitle");
this.actionTimestamp = this.getAttribute("$timestamp","yes") === "yes";
};
@@ -73,6 +74,9 @@ CreateTiddlerWidget.prototype.invokeAction = function(triggeringWidget,event) {
if(this.actionSaveTitle) {
this.wiki.setTextReference(this.actionSaveTitle,title,this.getVariable("currentTiddler"));
}
if(this.actionSaveDraftTitle) {
this.wiki.setTextReference(this.actionSaveDraftTitle,this.wiki.generateDraftTitle(title),this.getVariable("currentTiddler"));
}
return true; // Action was invoked
};
+1 -9
View File
@@ -279,15 +279,7 @@ NavigatorWidget.prototype.makeDraftTiddler = function(targetTitle) {
Generate a title for the draft of a given tiddler
*/
NavigatorWidget.prototype.generateDraftTitle = function(title) {
var c = 0,
draftTitle,
username = this.wiki.getTiddlerText("$:/status/UserName"),
attribution = username ? " by " + username : "";
do {
draftTitle = "Draft " + (c ? (c + 1) + " " : "") + "of '" + title + "'" + attribution;
c++;
} while(this.wiki.tiddlerExists(draftTitle));
return draftTitle;
return this.wiki.generateDraftTitle(title);
};
// Take a tiddler out of edit mode, saving the changes