From 931d47e50c35b5b54feb800a6a39af2d84121f1d Mon Sep 17 00:00:00 2001 From: Jermolene Date: Tue, 18 Nov 2014 14:13:34 +0000 Subject: [PATCH] Fix problem with cloning tiddlers We were ignoring the tags on the template tiddler. Fixes #1097 --- core/modules/widgets/navigator.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index 6901d4715..05a8c2b5c 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -376,7 +376,7 @@ NavigatorWidget.prototype.handleCancelTiddlerEvent = function(event) { NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) { // Get the story details var storyList = this.getStoryList(), - templateTiddler, additionalFields, title, draftTitle, existingTiddler, mergedTags; + templateTiddler, additionalFields, title, draftTitle, existingTiddler; // Get the template tiddler (if any) if(typeof event.param === "string") { // Get the template tiddler @@ -406,13 +406,17 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) { existingTiddler = this.wiki.getTiddler(title); } // Merge the tags - if(existingTiddler && existingTiddler.fields.tags && additionalFields && additionalFields.tags) { + var mergedTags = []; + if(existingTiddler && existingTiddler.fields.tags) { + $tw.utils.pushTop(mergedTags,existingTiddler.fields.tags) + } + if(additionalFields && additionalFields.tags) { // Merge tags - mergedTags = $tw.utils.pushTop($tw.utils.parseStringArray(additionalFields.tags),existingTiddler.fields.tags); - } else if(existingTiddler && existingTiddler.fields.tags) { - mergedTags = existingTiddler.fields.tags; - } else if(additionalFields && additionalFields.tags) { - mergedTags = additionalFields.tags; + mergedTags = $tw.utils.pushTop(mergedTags,$tw.utils.parseStringArray(additionalFields.tags)); + } + if(templateTiddler && templateTiddler.fields.tags) { + // Merge tags + mergedTags = $tw.utils.pushTop(mergedTags,templateTiddler.fields.tags); } // Save the draft tiddler var draftTiddler = new $tw.Tiddler({