1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-20 04:50:03 +00:00

Fixed problem with cancelling editing the tiddler $:/StoryList

This commit is contained in:
Jermolene 2013-12-06 08:45:24 +00:00
parent d4e6516a61
commit 48f8046cf5

View File

@ -284,24 +284,24 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
// Take a tiddler out of edit mode without saving the changes // Take a tiddler out of edit mode without saving the changes
NavigatorWidget.prototype.handleCancelTiddlerEvent = function(event) { NavigatorWidget.prototype.handleCancelTiddlerEvent = function(event) {
this.getStoryList(); this.getStoryList();
var title = event.param || event.tiddlerTitle, var storyTiddlerModified = false;
storyTiddlerModified = false; // Flip the specified tiddler from draft back to the original
for(var t=0; t<this.storyList.length; t++) { var draftTitle = event.param || event.tiddlerTitle,
if(this.storyList[t] === title) { draftTiddler = this.wiki.getTiddler(draftTitle);
var tiddler = this.wiki.getTiddler(title); if(draftTiddler && draftTiddler.hasField("draft.of")) {
if(tiddler && tiddler.hasField("draft.title")) { var originalTitle = draftTiddler.fields["draft.of"];
// Remove the draft tiddler // Remove the draft tiddler
this.wiki.deleteTiddler(title); this.wiki.deleteTiddler(draftTitle);
// Swap the draft for the original in the story
for(var t=0; t<this.storyList.length; t++) {
if(this.storyList[t] === draftTitle) {
// Make the story record point to the original tiddler // Make the story record point to the original tiddler
this.storyList[t] = tiddler.fields["draft.title"]; this.storyList[t] = originalTitle;
// Check if we're modifying the story tiddler itself storyTiddlerModified = true;
if(tiddler.fields["draft.title"] === this.storyTitle) {
storyTiddlerModified = true;
}
} }
} }
} }
if(!storyTiddlerModified) { if(storyTiddlerModified) {
this.saveStoryList(); this.saveStoryList();
} }
return false; return false;